Convolution of ROI using as border the pixels outside the ROI

asked 2016-10-11 03:20:27 -0500

pmousoul gravatar image

updated 2016-10-11 03:51:14 -0500

Hello,

is it possible to calculate the convolution of a ROI of an image and use as border the border of the ROI which is outside the ROI (not included in the ROI)?

If yes, how is it calculated?

For example, I used filter2D on a ROI selected with Rect(), but in filter2D there isn't a border option which matches with what I'm describing above..

example.png edit: To visualize what I'm describing, in the attached file, I want to calculate the convolution of the yellow ROI using as border the pixels around the yellow ROI (the ones included in the blue rectangle but do not belong to the yellow rectangle).

Thank you for your time, Panos

edit retag flag offensive close merge delete

Comments

hey, took me 5 times to understand your 1st line ;)

(while it all makes sense, maybe a small image / drawing would be helpful to others)

berak gravatar imageberak ( 2016-10-11 03:26:34 -0500 )edit
1

I added an example image and using it tried to explain what I want to do.

Said in another way: I would like to be able to calculate the convolution only for the image pixels that the kernel resides entirely inside the image. So, lets say that the example.png describes the case where the kernel size is 3x3.

pmousoul gravatar imagepmousoul ( 2016-10-11 04:05:04 -0500 )edit

what if you do the convolution on a roi, that's kernelsize/2 larger than your actual roi, and crop the result back later ?

berak gravatar imageberak ( 2016-10-12 02:59:53 -0500 )edit

That is valid, but I want to avoid the extra calculations because I'm measuring execution time. What you are saying is what I'm currently doing, but since I'm measuring execution time, I would prefer an exact solution.

pmousoul gravatar imagepmousoul ( 2016-10-12 03:05:49 -0500 )edit