Hi all, I'm trying to write a slightly modified median filter. I have a logical array with the locations of hot pixels in an image. I'd like to replace the values of these pixels with the mean or median value of the pixels that are 2 pixels away from this central hot pixel. Example, the black pixel in the image below should be red. I'd like to take the median of the other red pixels, only and replace the black pixel with that value.
Right now I do it with a loop over x,y locations of the hot pixels, but it takes minutes, because I have about 42,000 hot pixels:
subFrame = normalizedFrames(y_hotpixels(aa)-2:2:y_hotpixels(aa)+2,x_hotpixels(aa)-2:2:x_hotpixels(aa)+2); normalizedFrames2(y_hotpixels(aa),x_hotpixels(aa)) = median(subFrame(:));
I would love to learn the MATLAB way to do this...