more warning about red and blue averaging function
This commit is contained in:
parent
d5768a4bfe
commit
033abea7e3
1 changed files with 13 additions and 3 deletions
16
app.py
16
app.py
|
@ -288,11 +288,20 @@ class renderedImageZoom:
|
||||||
|
|
||||||
|
|
||||||
def get_image_average(self,color,low, high):
|
def get_image_average(self,color,low, high):
|
||||||
|
#i keep getting divizion by zero errors in the branches where it should be impossible to get a division by zero error.
|
||||||
|
# sometimes i truly hate python
|
||||||
if color == "blue":
|
if color == "blue":
|
||||||
slice = self.image[:][low:high]
|
slice = self.image[:][low:high]
|
||||||
blue = 0
|
blue = 0
|
||||||
for line in slice:
|
for line in slice:
|
||||||
blue += sum([p[2]/(p[0]+p[1]+p[2]) for p in line])
|
for pixel in line:
|
||||||
|
print(type(pixel))
|
||||||
|
if pixel[2] == 0 or pixel[2] == None:
|
||||||
|
blue += 0
|
||||||
|
else:
|
||||||
|
blue += pixel[2]/(pixel[0]+pixel[1]+pixel[2])
|
||||||
|
print("active pixel value",pixel[2]/sum(pixel))
|
||||||
|
print(blue)
|
||||||
|
|
||||||
blue = blue / (100*(high-low))
|
blue = blue / (100*(high-low))
|
||||||
return "{} is the pixel average".format(blue)
|
return "{} is the pixel average".format(blue)
|
||||||
|
@ -301,10 +310,11 @@ class renderedImageZoom:
|
||||||
red = 0
|
red = 0
|
||||||
for line in slice:
|
for line in slice:
|
||||||
for pixel in line:
|
for pixel in line:
|
||||||
if sum(pixel) == 0:
|
if pixel[0] == 0 or pixel[0] == None:
|
||||||
red += 0
|
red += 0
|
||||||
else:
|
else:
|
||||||
red += pixel[0]/sum(pixel)
|
red += pixel[2]/(pixel[0]+pixel[1]+pixel[2])
|
||||||
|
print(red)
|
||||||
|
|
||||||
red = red / (100*(high-low))
|
red = red / (100*(high-low))
|
||||||
return "{} is the pixel average".format(red)
|
return "{} is the pixel average".format(red)
|
||||||
|
|
Loading…
Reference in a new issue