I've got an image (ndarray with shape (480, 640, 3)) and an associated mask (ndarray with shape (480,640)). What I want to do is this: For each pixel in the image whose corresponding mask value is 255:
- Calculate the "distance" of that pixel from a reference color = sqrt((R-r)^2+(B-b)^2+(G-g)^2))
- Return the minimum and maximum values of that distance
I could of course loop over each pixel individually, but it feels like there's a more efficient way using np.array() or something. This question seems to be going in the right direction for me, but it doesn't include the mask.
Is there a clever/efficient way to do this?