I have an big image and I have to :
First, apply a function to every possible patch of the image, like a sliding window. This is actually very similar to convolution, which is supported in Matlab, but instead I need to calculate a "key value" (real) on each image patch (let's consider it a black box function). As suggested by the comments, perharps I can use the "blockproc" function
Then, I need to find n smallest key values and their respective positions, but the catch is that I have several overlapping windows with similarly low key values then sorting will preserve all of them in the list, which is undesirable. Instead I want to detect those overlapping windows and keep only the one with the lowest key value. You can say that I want to find not the n smallest key values but only the n local minima (not sure if this analogy is correct though) . I can't give the code because it is too long and complicated (face recognition using eigenfaces with +5 functions)