Summary of lists of coordinates
I need to analyze a list of coordinates. The program should "summarize" the list.
from PIL import Image
im = Image.open('map.png')
rgb_im = im.convert('RGB')
l =
x = 0
y = 0
for y in range(im.size[1]):
for x in range(im.size[0]):
if sum(rgb_im.getpixel((x, y))) == 0:
a = [x, y]
l.append(a)
This generates a list of the coordinates of all black pixels from an image with several black rectangles on a white surface. The output is something like this:
[[599, 257], [600, 257], [601, 257], [602, 257], [603, 257], [604, 257], [605, 257], [606, 257], [599, 258], [600, 258], [601, 258], [602, 258], [603, 258], [604, 258], [605, 258], [606, 258], [599, 259], [600, 259], [601, 259], [602, 259], [603, 259], [604, 259], [605, 259], [606, 259], [599, 260], [600, 260], [601, 260], [602, 260], [603, 260], [604, 260], [605, 260], [606, 260], [599, 261], [600, 261], [601, 261], [602, 261], [603, 261], [604, 261], [605, 261], [606, 261], [599, 262], [600, 262], [601, 262], [602, 262], [603, 262], [604, 262], [605, 262], [606, 262], [599, 263], [600, 263], [601, 263], [602, 263], [603, 263], [604, 263], [605, 263], [606, 263], [622, 286], [623, 286], [624, 286], [625, 286], [626, 286], [627, 286], [622, 287], [623, 287], [624, 287], [625, 287], [626, 287], [627, 287], [622, 288], [623, 288], [624, 288], [625, 288], [626, 288], [627, 288], [622, 289], [623, 289], [624, 289], [625, 289], [626, 289], [627, 289], [622, 290], [623, 290], [624, 290], [625, 290], [626, 290], [627, 290], [622, 291], [623, 291], [624, 291], [625, 291], [626, 291], [627, 291]]
The "summaries" should be information about the black rectangles. The output should be: [x-coordinate, y-coordinate, length, height] for each rectangle, which requires the coordinates of the origin.
In this case: [[599, 257, 8, 7], [622, 287, 6, 6]]
I don't know if I should work with arrays or matrices or something completely different. I'm open to ideas. The important part is to get that information from these kind of images.
Thank you all in advance!
arrays python-3.x list coordinates shapes
add a comment |
I need to analyze a list of coordinates. The program should "summarize" the list.
from PIL import Image
im = Image.open('map.png')
rgb_im = im.convert('RGB')
l =
x = 0
y = 0
for y in range(im.size[1]):
for x in range(im.size[0]):
if sum(rgb_im.getpixel((x, y))) == 0:
a = [x, y]
l.append(a)
This generates a list of the coordinates of all black pixels from an image with several black rectangles on a white surface. The output is something like this:
[[599, 257], [600, 257], [601, 257], [602, 257], [603, 257], [604, 257], [605, 257], [606, 257], [599, 258], [600, 258], [601, 258], [602, 258], [603, 258], [604, 258], [605, 258], [606, 258], [599, 259], [600, 259], [601, 259], [602, 259], [603, 259], [604, 259], [605, 259], [606, 259], [599, 260], [600, 260], [601, 260], [602, 260], [603, 260], [604, 260], [605, 260], [606, 260], [599, 261], [600, 261], [601, 261], [602, 261], [603, 261], [604, 261], [605, 261], [606, 261], [599, 262], [600, 262], [601, 262], [602, 262], [603, 262], [604, 262], [605, 262], [606, 262], [599, 263], [600, 263], [601, 263], [602, 263], [603, 263], [604, 263], [605, 263], [606, 263], [622, 286], [623, 286], [624, 286], [625, 286], [626, 286], [627, 286], [622, 287], [623, 287], [624, 287], [625, 287], [626, 287], [627, 287], [622, 288], [623, 288], [624, 288], [625, 288], [626, 288], [627, 288], [622, 289], [623, 289], [624, 289], [625, 289], [626, 289], [627, 289], [622, 290], [623, 290], [624, 290], [625, 290], [626, 290], [627, 290], [622, 291], [623, 291], [624, 291], [625, 291], [626, 291], [627, 291]]
The "summaries" should be information about the black rectangles. The output should be: [x-coordinate, y-coordinate, length, height] for each rectangle, which requires the coordinates of the origin.
In this case: [[599, 257, 8, 7], [622, 287, 6, 6]]
I don't know if I should work with arrays or matrices or something completely different. I'm open to ideas. The important part is to get that information from these kind of images.
Thank you all in advance!
arrays python-3.x list coordinates shapes
Looks like a neat problem, just to clarify on the language by length and high do you mean width and height? Also, they don't count the same row/column of the x/y-coordinates? [599, 257, 7, 6] implies 7 • 6 = 42 pixels, but you seem to be covering 56 pixels with that particular group.
– TrebuchetMS
Nov 28 '18 at 4:52
You may want to look up floodfill. It may be a potential algorithm here.
– TrebuchetMS
Nov 28 '18 at 5:03
The adjective to rectangle is rectangular. I leave to you to look up what you used instead.
– Mr. T
Nov 28 '18 at 6:32
i could not solve the problem yet. but thanks
– tintin
Nov 29 '18 at 16:50
add a comment |
I need to analyze a list of coordinates. The program should "summarize" the list.
from PIL import Image
im = Image.open('map.png')
rgb_im = im.convert('RGB')
l =
x = 0
y = 0
for y in range(im.size[1]):
for x in range(im.size[0]):
if sum(rgb_im.getpixel((x, y))) == 0:
a = [x, y]
l.append(a)
This generates a list of the coordinates of all black pixels from an image with several black rectangles on a white surface. The output is something like this:
[[599, 257], [600, 257], [601, 257], [602, 257], [603, 257], [604, 257], [605, 257], [606, 257], [599, 258], [600, 258], [601, 258], [602, 258], [603, 258], [604, 258], [605, 258], [606, 258], [599, 259], [600, 259], [601, 259], [602, 259], [603, 259], [604, 259], [605, 259], [606, 259], [599, 260], [600, 260], [601, 260], [602, 260], [603, 260], [604, 260], [605, 260], [606, 260], [599, 261], [600, 261], [601, 261], [602, 261], [603, 261], [604, 261], [605, 261], [606, 261], [599, 262], [600, 262], [601, 262], [602, 262], [603, 262], [604, 262], [605, 262], [606, 262], [599, 263], [600, 263], [601, 263], [602, 263], [603, 263], [604, 263], [605, 263], [606, 263], [622, 286], [623, 286], [624, 286], [625, 286], [626, 286], [627, 286], [622, 287], [623, 287], [624, 287], [625, 287], [626, 287], [627, 287], [622, 288], [623, 288], [624, 288], [625, 288], [626, 288], [627, 288], [622, 289], [623, 289], [624, 289], [625, 289], [626, 289], [627, 289], [622, 290], [623, 290], [624, 290], [625, 290], [626, 290], [627, 290], [622, 291], [623, 291], [624, 291], [625, 291], [626, 291], [627, 291]]
The "summaries" should be information about the black rectangles. The output should be: [x-coordinate, y-coordinate, length, height] for each rectangle, which requires the coordinates of the origin.
In this case: [[599, 257, 8, 7], [622, 287, 6, 6]]
I don't know if I should work with arrays or matrices or something completely different. I'm open to ideas. The important part is to get that information from these kind of images.
Thank you all in advance!
arrays python-3.x list coordinates shapes
I need to analyze a list of coordinates. The program should "summarize" the list.
from PIL import Image
im = Image.open('map.png')
rgb_im = im.convert('RGB')
l =
x = 0
y = 0
for y in range(im.size[1]):
for x in range(im.size[0]):
if sum(rgb_im.getpixel((x, y))) == 0:
a = [x, y]
l.append(a)
This generates a list of the coordinates of all black pixels from an image with several black rectangles on a white surface. The output is something like this:
[[599, 257], [600, 257], [601, 257], [602, 257], [603, 257], [604, 257], [605, 257], [606, 257], [599, 258], [600, 258], [601, 258], [602, 258], [603, 258], [604, 258], [605, 258], [606, 258], [599, 259], [600, 259], [601, 259], [602, 259], [603, 259], [604, 259], [605, 259], [606, 259], [599, 260], [600, 260], [601, 260], [602, 260], [603, 260], [604, 260], [605, 260], [606, 260], [599, 261], [600, 261], [601, 261], [602, 261], [603, 261], [604, 261], [605, 261], [606, 261], [599, 262], [600, 262], [601, 262], [602, 262], [603, 262], [604, 262], [605, 262], [606, 262], [599, 263], [600, 263], [601, 263], [602, 263], [603, 263], [604, 263], [605, 263], [606, 263], [622, 286], [623, 286], [624, 286], [625, 286], [626, 286], [627, 286], [622, 287], [623, 287], [624, 287], [625, 287], [626, 287], [627, 287], [622, 288], [623, 288], [624, 288], [625, 288], [626, 288], [627, 288], [622, 289], [623, 289], [624, 289], [625, 289], [626, 289], [627, 289], [622, 290], [623, 290], [624, 290], [625, 290], [626, 290], [627, 290], [622, 291], [623, 291], [624, 291], [625, 291], [626, 291], [627, 291]]
The "summaries" should be information about the black rectangles. The output should be: [x-coordinate, y-coordinate, length, height] for each rectangle, which requires the coordinates of the origin.
In this case: [[599, 257, 8, 7], [622, 287, 6, 6]]
I don't know if I should work with arrays or matrices or something completely different. I'm open to ideas. The important part is to get that information from these kind of images.
Thank you all in advance!
arrays python-3.x list coordinates shapes
arrays python-3.x list coordinates shapes
edited Nov 29 '18 at 16:47
tintin
asked Nov 28 '18 at 3:58
tintintintin
112
112
Looks like a neat problem, just to clarify on the language by length and high do you mean width and height? Also, they don't count the same row/column of the x/y-coordinates? [599, 257, 7, 6] implies 7 • 6 = 42 pixels, but you seem to be covering 56 pixels with that particular group.
– TrebuchetMS
Nov 28 '18 at 4:52
You may want to look up floodfill. It may be a potential algorithm here.
– TrebuchetMS
Nov 28 '18 at 5:03
The adjective to rectangle is rectangular. I leave to you to look up what you used instead.
– Mr. T
Nov 28 '18 at 6:32
i could not solve the problem yet. but thanks
– tintin
Nov 29 '18 at 16:50
add a comment |
Looks like a neat problem, just to clarify on the language by length and high do you mean width and height? Also, they don't count the same row/column of the x/y-coordinates? [599, 257, 7, 6] implies 7 • 6 = 42 pixels, but you seem to be covering 56 pixels with that particular group.
– TrebuchetMS
Nov 28 '18 at 4:52
You may want to look up floodfill. It may be a potential algorithm here.
– TrebuchetMS
Nov 28 '18 at 5:03
The adjective to rectangle is rectangular. I leave to you to look up what you used instead.
– Mr. T
Nov 28 '18 at 6:32
i could not solve the problem yet. but thanks
– tintin
Nov 29 '18 at 16:50
Looks like a neat problem, just to clarify on the language by length and high do you mean width and height? Also, they don't count the same row/column of the x/y-coordinates? [599, 257, 7, 6] implies 7 • 6 = 42 pixels, but you seem to be covering 56 pixels with that particular group.
– TrebuchetMS
Nov 28 '18 at 4:52
Looks like a neat problem, just to clarify on the language by length and high do you mean width and height? Also, they don't count the same row/column of the x/y-coordinates? [599, 257, 7, 6] implies 7 • 6 = 42 pixels, but you seem to be covering 56 pixels with that particular group.
– TrebuchetMS
Nov 28 '18 at 4:52
You may want to look up floodfill. It may be a potential algorithm here.
– TrebuchetMS
Nov 28 '18 at 5:03
You may want to look up floodfill. It may be a potential algorithm here.
– TrebuchetMS
Nov 28 '18 at 5:03
The adjective to rectangle is rectangular. I leave to you to look up what you used instead.
– Mr. T
Nov 28 '18 at 6:32
The adjective to rectangle is rectangular. I leave to you to look up what you used instead.
– Mr. T
Nov 28 '18 at 6:32
i could not solve the problem yet. but thanks
– tintin
Nov 29 '18 at 16:50
i could not solve the problem yet. but thanks
– tintin
Nov 29 '18 at 16:50
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53511907%2fsummary-of-lists-of-coordinates%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53511907%2fsummary-of-lists-of-coordinates%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Looks like a neat problem, just to clarify on the language by length and high do you mean width and height? Also, they don't count the same row/column of the x/y-coordinates? [599, 257, 7, 6] implies 7 • 6 = 42 pixels, but you seem to be covering 56 pixels with that particular group.
– TrebuchetMS
Nov 28 '18 at 4:52
You may want to look up floodfill. It may be a potential algorithm here.
– TrebuchetMS
Nov 28 '18 at 5:03
The adjective to rectangle is rectangular. I leave to you to look up what you used instead.
– Mr. T
Nov 28 '18 at 6:32
i could not solve the problem yet. but thanks
– tintin
Nov 29 '18 at 16:50