Change all pixels that lie in a given color range to a new color
up vote
4
down vote
favorite
This is what I have so far but it's not perfect... Any input would be very helpful!
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = list(img.getdata())
red_list=
for i in pixels:
R= i[0]
G=i[1]
B=i[2]
if R >= from_color[0] and R<= to_color[0] and G >=from_color[1]
and G<= to_color[1] and B >= from_color[2] and B<=
to_color[2]:
red_list.append(target_color)
else:
red_list.append((round(R),round(G),round(B)))
red_image = Image.new(img.mode,img.size)
red_image.putdata(red_list)
return red_image
python python-3.x image
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
4
down vote
favorite
This is what I have so far but it's not perfect... Any input would be very helpful!
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = list(img.getdata())
red_list=
for i in pixels:
R= i[0]
G=i[1]
B=i[2]
if R >= from_color[0] and R<= to_color[0] and G >=from_color[1]
and G<= to_color[1] and B >= from_color[2] and B<=
to_color[2]:
red_list.append(target_color)
else:
red_list.append((round(R),round(G),round(B)))
red_image = Image.new(img.mode,img.size)
red_image.putdata(red_list)
return red_image
python python-3.x image
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Yourifstatement is split over three lines, in a way that I think is not valid in Python. If you put brackets around it, then you can break it up across lines: stackoverflow.com/questions/5253348/…
– Cris Luengo
9 hours ago
1
Also clarify whatimports apply. What areImageandround?
– 200_success
6 hours ago
1
@200_success round is a built-in function. For the Image my guess is it comes from pillow.
– Arthur Havlicek
5 hours ago
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
This is what I have so far but it's not perfect... Any input would be very helpful!
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = list(img.getdata())
red_list=
for i in pixels:
R= i[0]
G=i[1]
B=i[2]
if R >= from_color[0] and R<= to_color[0] and G >=from_color[1]
and G<= to_color[1] and B >= from_color[2] and B<=
to_color[2]:
red_list.append(target_color)
else:
red_list.append((round(R),round(G),round(B)))
red_image = Image.new(img.mode,img.size)
red_image.putdata(red_list)
return red_image
python python-3.x image
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
This is what I have so far but it's not perfect... Any input would be very helpful!
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = list(img.getdata())
red_list=
for i in pixels:
R= i[0]
G=i[1]
B=i[2]
if R >= from_color[0] and R<= to_color[0] and G >=from_color[1]
and G<= to_color[1] and B >= from_color[2] and B<=
to_color[2]:
red_list.append(target_color)
else:
red_list.append((round(R),round(G),round(B)))
red_image = Image.new(img.mode,img.size)
red_image.putdata(red_list)
return red_image
python python-3.x image
python python-3.x image
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 6 hours ago
200_success
127k15148410
127k15148410
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 11 hours ago
Victoria
211
211
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Yourifstatement is split over three lines, in a way that I think is not valid in Python. If you put brackets around it, then you can break it up across lines: stackoverflow.com/questions/5253348/…
– Cris Luengo
9 hours ago
1
Also clarify whatimports apply. What areImageandround?
– 200_success
6 hours ago
1
@200_success round is a built-in function. For the Image my guess is it comes from pillow.
– Arthur Havlicek
5 hours ago
add a comment |
2
Yourifstatement is split over three lines, in a way that I think is not valid in Python. If you put brackets around it, then you can break it up across lines: stackoverflow.com/questions/5253348/…
– Cris Luengo
9 hours ago
1
Also clarify whatimports apply. What areImageandround?
– 200_success
6 hours ago
1
@200_success round is a built-in function. For the Image my guess is it comes from pillow.
– Arthur Havlicek
5 hours ago
2
2
Your
if statement is split over three lines, in a way that I think is not valid in Python. If you put brackets around it, then you can break it up across lines: stackoverflow.com/questions/5253348/…– Cris Luengo
9 hours ago
Your
if statement is split over three lines, in a way that I think is not valid in Python. If you put brackets around it, then you can break it up across lines: stackoverflow.com/questions/5253348/…– Cris Luengo
9 hours ago
1
1
Also clarify what
imports apply. What are Image and round?– 200_success
6 hours ago
Also clarify what
imports apply. What are Image and round?– 200_success
6 hours ago
1
1
@200_success round is a built-in function. For the Image my guess is it comes from pillow.
– Arthur Havlicek
5 hours ago
@200_success round is a built-in function. For the Image my guess is it comes from pillow.
– Arthur Havlicek
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Improving the general implementation
Generally we want to avoid appending to a list too many times if we can help it. This is because lists are dynamic arrays, so appends can be unnecessarily expensive (though the dynamic part helps with the efficiency). Instead, when we know the size of the input set (i.e. the number of pixels in the image), we can take advantage of that information. But in this case, that will be unnecessary because Image provides us with some handy helper methods to handle this very situation:
from PIL import Image
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if all(pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3)):
pixels[i, j] = target_color + (255,)
return img
Assigning pixels to img.load() allows us to take advantage of directly editing the image. Since copying the image into another list was unnecessary originally (to clarify, the img variable doesn't affect the file on disk that img originated from, i.e. the file at location filename), editing directly is the best way.
Another general improvement I've taken advantage of in this implementation is using range to check if each of the RGB values of a pixel are between the two pixel boundaries of the input arguments. all() serves the purpose that the and statements in the original version served: it requires that all the pixels compared in the iterator pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3) are in the required range for the condition to be true.
Going beyond the current form
While I've shown you a way to use your current parameter requirements in a more efficient implementation, I think there are some improvements you can make so picture_reset_pixels has more functionality. I think combining from_color, to_color, and target_color into a single dict parameter color_replacements could make this more versatile (where the key-value pairs would derive something like {(from_color, to_color): target_color}; you could even create a custom ColorRange class to encapsulate the idea of a range of colors).
There's also another issue I find with your current implementation: it can only support certain image types. I tried your algorithm on a GIF file and it failed because the pixels in a GIF file are ints, not four-tuples like PNGs. You might want to consider investigating that further if you want to support multiple image types.
in range(), if I understand what you're doing, is a very bad idea. You're essentially constructing a list of numbers and then searching to see if apixelselement is in them. Instead, do a comparison of the formfrom_colour <= pixel <= to_colour.
– Reinderien
1 hour ago
add a comment |
up vote
0
down vote
The code is overall simple and good but could be improved in a few things that would make it a bit shorter and more readable
Inside the for loop, in the if / else, you are repeating append in both of your cases. You could do instead
to_add = (round(R), round(G), round(B))
if condition:
to_add = target_color
red_list.append(to_add)
On the condition, you can also refactor using chained comparison to improve readability, preferably in ascending order. If you break that line, do so aligning conditionals as follow :
if from_color[0] <= R <= to_color[0] and
from_color[1] <= G <= to_color[1] and
from_color[2] <= B <= to_color[2]:
Alternatively, but sightly less explicit, you can iterate over i.
if all((from_color[j] <= i[j] <= to_color[j] for j in range(3)))
R, G, B initialisation can be made a single line:
R, G, B = i
or, if working with a 4 tuples:
R, G, B, _ = i
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Your second-last line - ifiis a 3-tuple, you can simply writeR, G, B = i. It will unpack.
– Reinderien
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Improving the general implementation
Generally we want to avoid appending to a list too many times if we can help it. This is because lists are dynamic arrays, so appends can be unnecessarily expensive (though the dynamic part helps with the efficiency). Instead, when we know the size of the input set (i.e. the number of pixels in the image), we can take advantage of that information. But in this case, that will be unnecessary because Image provides us with some handy helper methods to handle this very situation:
from PIL import Image
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if all(pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3)):
pixels[i, j] = target_color + (255,)
return img
Assigning pixels to img.load() allows us to take advantage of directly editing the image. Since copying the image into another list was unnecessary originally (to clarify, the img variable doesn't affect the file on disk that img originated from, i.e. the file at location filename), editing directly is the best way.
Another general improvement I've taken advantage of in this implementation is using range to check if each of the RGB values of a pixel are between the two pixel boundaries of the input arguments. all() serves the purpose that the and statements in the original version served: it requires that all the pixels compared in the iterator pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3) are in the required range for the condition to be true.
Going beyond the current form
While I've shown you a way to use your current parameter requirements in a more efficient implementation, I think there are some improvements you can make so picture_reset_pixels has more functionality. I think combining from_color, to_color, and target_color into a single dict parameter color_replacements could make this more versatile (where the key-value pairs would derive something like {(from_color, to_color): target_color}; you could even create a custom ColorRange class to encapsulate the idea of a range of colors).
There's also another issue I find with your current implementation: it can only support certain image types. I tried your algorithm on a GIF file and it failed because the pixels in a GIF file are ints, not four-tuples like PNGs. You might want to consider investigating that further if you want to support multiple image types.
in range(), if I understand what you're doing, is a very bad idea. You're essentially constructing a list of numbers and then searching to see if apixelselement is in them. Instead, do a comparison of the formfrom_colour <= pixel <= to_colour.
– Reinderien
1 hour ago
add a comment |
up vote
1
down vote
Improving the general implementation
Generally we want to avoid appending to a list too many times if we can help it. This is because lists are dynamic arrays, so appends can be unnecessarily expensive (though the dynamic part helps with the efficiency). Instead, when we know the size of the input set (i.e. the number of pixels in the image), we can take advantage of that information. But in this case, that will be unnecessary because Image provides us with some handy helper methods to handle this very situation:
from PIL import Image
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if all(pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3)):
pixels[i, j] = target_color + (255,)
return img
Assigning pixels to img.load() allows us to take advantage of directly editing the image. Since copying the image into another list was unnecessary originally (to clarify, the img variable doesn't affect the file on disk that img originated from, i.e. the file at location filename), editing directly is the best way.
Another general improvement I've taken advantage of in this implementation is using range to check if each of the RGB values of a pixel are between the two pixel boundaries of the input arguments. all() serves the purpose that the and statements in the original version served: it requires that all the pixels compared in the iterator pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3) are in the required range for the condition to be true.
Going beyond the current form
While I've shown you a way to use your current parameter requirements in a more efficient implementation, I think there are some improvements you can make so picture_reset_pixels has more functionality. I think combining from_color, to_color, and target_color into a single dict parameter color_replacements could make this more versatile (where the key-value pairs would derive something like {(from_color, to_color): target_color}; you could even create a custom ColorRange class to encapsulate the idea of a range of colors).
There's also another issue I find with your current implementation: it can only support certain image types. I tried your algorithm on a GIF file and it failed because the pixels in a GIF file are ints, not four-tuples like PNGs. You might want to consider investigating that further if you want to support multiple image types.
in range(), if I understand what you're doing, is a very bad idea. You're essentially constructing a list of numbers and then searching to see if apixelselement is in them. Instead, do a comparison of the formfrom_colour <= pixel <= to_colour.
– Reinderien
1 hour ago
add a comment |
up vote
1
down vote
up vote
1
down vote
Improving the general implementation
Generally we want to avoid appending to a list too many times if we can help it. This is because lists are dynamic arrays, so appends can be unnecessarily expensive (though the dynamic part helps with the efficiency). Instead, when we know the size of the input set (i.e. the number of pixels in the image), we can take advantage of that information. But in this case, that will be unnecessary because Image provides us with some handy helper methods to handle this very situation:
from PIL import Image
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if all(pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3)):
pixels[i, j] = target_color + (255,)
return img
Assigning pixels to img.load() allows us to take advantage of directly editing the image. Since copying the image into another list was unnecessary originally (to clarify, the img variable doesn't affect the file on disk that img originated from, i.e. the file at location filename), editing directly is the best way.
Another general improvement I've taken advantage of in this implementation is using range to check if each of the RGB values of a pixel are between the two pixel boundaries of the input arguments. all() serves the purpose that the and statements in the original version served: it requires that all the pixels compared in the iterator pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3) are in the required range for the condition to be true.
Going beyond the current form
While I've shown you a way to use your current parameter requirements in a more efficient implementation, I think there are some improvements you can make so picture_reset_pixels has more functionality. I think combining from_color, to_color, and target_color into a single dict parameter color_replacements could make this more versatile (where the key-value pairs would derive something like {(from_color, to_color): target_color}; you could even create a custom ColorRange class to encapsulate the idea of a range of colors).
There's also another issue I find with your current implementation: it can only support certain image types. I tried your algorithm on a GIF file and it failed because the pixels in a GIF file are ints, not four-tuples like PNGs. You might want to consider investigating that further if you want to support multiple image types.
Improving the general implementation
Generally we want to avoid appending to a list too many times if we can help it. This is because lists are dynamic arrays, so appends can be unnecessarily expensive (though the dynamic part helps with the efficiency). Instead, when we know the size of the input set (i.e. the number of pixels in the image), we can take advantage of that information. But in this case, that will be unnecessary because Image provides us with some handy helper methods to handle this very situation:
from PIL import Image
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if all(pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3)):
pixels[i, j] = target_color + (255,)
return img
Assigning pixels to img.load() allows us to take advantage of directly editing the image. Since copying the image into another list was unnecessary originally (to clarify, the img variable doesn't affect the file on disk that img originated from, i.e. the file at location filename), editing directly is the best way.
Another general improvement I've taken advantage of in this implementation is using range to check if each of the RGB values of a pixel are between the two pixel boundaries of the input arguments. all() serves the purpose that the and statements in the original version served: it requires that all the pixels compared in the iterator pixels[i, j][k] in range(from_color[k], to_color[k] + 1) for k in range(3) are in the required range for the condition to be true.
Going beyond the current form
While I've shown you a way to use your current parameter requirements in a more efficient implementation, I think there are some improvements you can make so picture_reset_pixels has more functionality. I think combining from_color, to_color, and target_color into a single dict parameter color_replacements could make this more versatile (where the key-value pairs would derive something like {(from_color, to_color): target_color}; you could even create a custom ColorRange class to encapsulate the idea of a range of colors).
There's also another issue I find with your current implementation: it can only support certain image types. I tried your algorithm on a GIF file and it failed because the pixels in a GIF file are ints, not four-tuples like PNGs. You might want to consider investigating that further if you want to support multiple image types.
edited 4 hours ago
answered 4 hours ago
Graham
491112
491112
in range(), if I understand what you're doing, is a very bad idea. You're essentially constructing a list of numbers and then searching to see if apixelselement is in them. Instead, do a comparison of the formfrom_colour <= pixel <= to_colour.
– Reinderien
1 hour ago
add a comment |
in range(), if I understand what you're doing, is a very bad idea. You're essentially constructing a list of numbers and then searching to see if apixelselement is in them. Instead, do a comparison of the formfrom_colour <= pixel <= to_colour.
– Reinderien
1 hour ago
in range(), if I understand what you're doing, is a very bad idea. You're essentially constructing a list of numbers and then searching to see if a pixels element is in them. Instead, do a comparison of the form from_colour <= pixel <= to_colour.– Reinderien
1 hour ago
in range(), if I understand what you're doing, is a very bad idea. You're essentially constructing a list of numbers and then searching to see if a pixels element is in them. Instead, do a comparison of the form from_colour <= pixel <= to_colour.– Reinderien
1 hour ago
add a comment |
up vote
0
down vote
The code is overall simple and good but could be improved in a few things that would make it a bit shorter and more readable
Inside the for loop, in the if / else, you are repeating append in both of your cases. You could do instead
to_add = (round(R), round(G), round(B))
if condition:
to_add = target_color
red_list.append(to_add)
On the condition, you can also refactor using chained comparison to improve readability, preferably in ascending order. If you break that line, do so aligning conditionals as follow :
if from_color[0] <= R <= to_color[0] and
from_color[1] <= G <= to_color[1] and
from_color[2] <= B <= to_color[2]:
Alternatively, but sightly less explicit, you can iterate over i.
if all((from_color[j] <= i[j] <= to_color[j] for j in range(3)))
R, G, B initialisation can be made a single line:
R, G, B = i
or, if working with a 4 tuples:
R, G, B, _ = i
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Your second-last line - ifiis a 3-tuple, you can simply writeR, G, B = i. It will unpack.
– Reinderien
1 hour ago
add a comment |
up vote
0
down vote
The code is overall simple and good but could be improved in a few things that would make it a bit shorter and more readable
Inside the for loop, in the if / else, you are repeating append in both of your cases. You could do instead
to_add = (round(R), round(G), round(B))
if condition:
to_add = target_color
red_list.append(to_add)
On the condition, you can also refactor using chained comparison to improve readability, preferably in ascending order. If you break that line, do so aligning conditionals as follow :
if from_color[0] <= R <= to_color[0] and
from_color[1] <= G <= to_color[1] and
from_color[2] <= B <= to_color[2]:
Alternatively, but sightly less explicit, you can iterate over i.
if all((from_color[j] <= i[j] <= to_color[j] for j in range(3)))
R, G, B initialisation can be made a single line:
R, G, B = i
or, if working with a 4 tuples:
R, G, B, _ = i
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Your second-last line - ifiis a 3-tuple, you can simply writeR, G, B = i. It will unpack.
– Reinderien
1 hour ago
add a comment |
up vote
0
down vote
up vote
0
down vote
The code is overall simple and good but could be improved in a few things that would make it a bit shorter and more readable
Inside the for loop, in the if / else, you are repeating append in both of your cases. You could do instead
to_add = (round(R), round(G), round(B))
if condition:
to_add = target_color
red_list.append(to_add)
On the condition, you can also refactor using chained comparison to improve readability, preferably in ascending order. If you break that line, do so aligning conditionals as follow :
if from_color[0] <= R <= to_color[0] and
from_color[1] <= G <= to_color[1] and
from_color[2] <= B <= to_color[2]:
Alternatively, but sightly less explicit, you can iterate over i.
if all((from_color[j] <= i[j] <= to_color[j] for j in range(3)))
R, G, B initialisation can be made a single line:
R, G, B = i
or, if working with a 4 tuples:
R, G, B, _ = i
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The code is overall simple and good but could be improved in a few things that would make it a bit shorter and more readable
Inside the for loop, in the if / else, you are repeating append in both of your cases. You could do instead
to_add = (round(R), round(G), round(B))
if condition:
to_add = target_color
red_list.append(to_add)
On the condition, you can also refactor using chained comparison to improve readability, preferably in ascending order. If you break that line, do so aligning conditionals as follow :
if from_color[0] <= R <= to_color[0] and
from_color[1] <= G <= to_color[1] and
from_color[2] <= B <= to_color[2]:
Alternatively, but sightly less explicit, you can iterate over i.
if all((from_color[j] <= i[j] <= to_color[j] for j in range(3)))
R, G, B initialisation can be made a single line:
R, G, B = i
or, if working with a 4 tuples:
R, G, B, _ = i
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 12 mins ago
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 5 hours ago
Arthur Havlicek
2713
2713
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Arthur Havlicek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Your second-last line - ifiis a 3-tuple, you can simply writeR, G, B = i. It will unpack.
– Reinderien
1 hour ago
add a comment |
Your second-last line - ifiis a 3-tuple, you can simply writeR, G, B = i. It will unpack.
– Reinderien
1 hour ago
Your second-last line - if
i is a 3-tuple, you can simply write R, G, B = i. It will unpack.– Reinderien
1 hour ago
Your second-last line - if
i is a 3-tuple, you can simply write R, G, B = i. It will unpack.– Reinderien
1 hour ago
add a comment |
Victoria is a new contributor. Be nice, and check out our Code of Conduct.
Victoria is a new contributor. Be nice, and check out our Code of Conduct.
Victoria is a new contributor. Be nice, and check out our Code of Conduct.
Victoria is a new contributor. Be nice, and check out our Code of Conduct.
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%2fcodereview.stackexchange.com%2fquestions%2f207839%2fchange-all-pixels-that-lie-in-a-given-color-range-to-a-new-color%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
2
Your
ifstatement is split over three lines, in a way that I think is not valid in Python. If you put brackets around it, then you can break it up across lines: stackoverflow.com/questions/5253348/…– Cris Luengo
9 hours ago
1
Also clarify what
imports apply. What areImageandround?– 200_success
6 hours ago
1
@200_success round is a built-in function. For the Image my guess is it comes from pillow.
– Arthur Havlicek
5 hours ago