How do I mask saturated pixels, and those surround them, from an image?

Viewed 23

I'm trying to analyze an image, loaded as an array, which currently contains saturated pixels. The analysis function also takes a mask array, which I can easily define to cover the pixels which are saturated or above some threshold value.

What I would like to do is define a masking array which masks both the saturated pixels, and some radius/area around them. I could image looping over every element in the mask array and finding the maximum value within the defined radius for each, but that seems like a very slow way to approach it, and I wondered if there could be anything quicker.

im = np.asarray(Image.open(image))

mask = np.where(im>2000,0,1)

output = some_function(im,mask)
0 Answers
Related