I am trying to take an image and evaluate the total number of pixels that have a combination of saturation and brightness over a specific baseline in an image. This formula works properly.
sqrt(s/255. * v/255.)
A value of a medium red for example would be 0.5, where a totally saturated bright red would be 1. Returning the saturation isn't enough for the type of metric I wish to collect.
I want to return a single percentage of those pixels over the baseline, versus the total pixels in the image. I am a bit stuck trying to get this filter to work and to do the total calculation of the result versus the total pixels.
BASELINE = 0.8
pixels = hsv.reshape((hsv.shape[0] * hsv.shape[1], 3))
for h,s,v in pixels:
d[h] = sqrt(s/255. * v/255.)
vibrant_px[h] = filter(lambda x: x > BASELINE, d)
How to total vibrant_px versus total pixels that are over BASELINE?
For the most part this works, but getting the total results from the tuple is frustrating me.