MATLAB: Sliding window minimum and maximum filter

blockprocmaximumminimumsliding window

I'm trying to apply a sliding window minimum and maximum filter to an image of a certain window size. Actually, I'm trying to find the optimum window size for it. But I really haven't gotten the hang of it. I presume that I should be using blockproc to implement the sliding window, but not really sure how to find the maximum and minimum filter. As to the implementation itself, should I use loops to slide the window across the entire area of the image ?

Best Answer

If you have the Image Processing Toolbox, you're in luck!. The sliding max filter is called imdilate() and the sliding min filter is imerode(). These are called "morphological operations." No loops needed:
localMinImage = imerode(grayImage, true(3));
localMaxImage = imdilate(grayImage, true(3));
Related Question