Sliding a window with cavities over an image

asked 2018-08-07 09:02:53 -0500

sazr gravatar image

Often I need to slide a window across an image. But the window has cells I am not interested in. Is there a term for this kind of convolution and is there an OpenCV function that can do this for me?

Further explained:

I wish to inspect the gradient direction of an image and find all areas that have similar directions to the below kernel:

 -1   -1    -1
 -1   270  -1
 225  -1  315

In the above kernel, I want to ignore the cells with -1. I want to slide the window across the image and minus this kernel from the ROI under the window. Those ROI's with the smallest difference I want to keep/highlight.

 -1   -1    -1        minus     88   200  210       equal       -    -    -    
 -1   270  -1                     90   288  220                      -   18   -
 225  -1  315                    199 210  320                     26   -    5

In the above example the difference equals 49. So in my resultant image all those cells in the ROI should be 49. In the resultant image I'll know the closest matches by finding the pixels/cells that are closest to zero.

Is there a term for this kind of sliding window? Is this considered convolution still (I don't flip the original kernel though so maybe cross-correlation?). Is there an OpenCV function that can do this?

edit retag flag offensive close merge delete