Calculate median/mode but ignore black colour
In OpenCV Python, I have masked out parts of the image, thus they are black. I need to calculate the median (or mode) colour that occurs in the image but ignore the masked/black pixels.
How can I do this because the functions I use still consider black pixels AFAIK:
mode = scipy.stats.mode(img) # will consider black pixels wont it?
median = np.median(img, axis=(0,1)) # will consider black pixels wont it?
there is no opencv call in your example. median is not mode and duplicate post