Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Correlation Implementation

I want to basically write code from scratch to do correlation on a given image with a kernel(without using filter2d function).

I am trying to find a general way of correlating image with kernel( mxm size where m an is odd number) but I can't seem to think of a good algorithm that will work for kernel of all sizes. In case of a boundary issue, we compute correlation for each pixel of image as long as the center of the kernel is on this pixel.

My idea is to first classify the pixels into two types, first one being pixels where simple multiplication with kernel is fine. The problem comes with the second type that is the boundary pixels, the pixels at the edges of the image. I can't seem to find a general way and I seem to end up hard-coding it to compute correlation for these pixels for different sizes of kernel.

Does anyone have any ideas or suggestions for a simpler implementation?

Correlation Implementation

I want to basically write code from scratch to do correlation on a given image with a kernel(without using filter2d function).

I am trying to find a general way of correlating image with kernel( mxm size where m an is odd number) but I can't seem to think of a good algorithm that will work for kernel of all sizes. In case of a boundary issue, we compute correlation for each pixel of image as long as the center of the kernel is on this pixel.

My idea is to first classify the pixels into two types, first one being pixels where simple multiplication with kernel is fine. The problem comes with the second type that is the boundary pixels, the pixels at the edges of the image. I can't seem to find a general way and I seem to end up hard-coding it to compute correlation for these pixels for different sizes of kernel.

Does anyone have any ideas or suggestions for a simpler implementation?