Saturday, April 9, 2011

blkproc in OpenCV

I've seen a couple of guys in many forums  of OpenCV (even the most popular Yahoo group) asking what is the equivalent of blkproc of Matlab in Opencv for which there were no replies. I'm not sure why people didn't care to answer that. For some there were replies which claimed that OpenCV doesn't have the  equivalent of blkproc.
Btw, My other programs in OpenCV will be posted here

I did some research (after which I felt a little foolish) on this. It turned out that there is a equivalent of blkproc of Matlab in Opencv. 

It is "cvSetImageROI", of course its that! (:p)

When you set an ROI for an image, it does basically the same what blkproc of Matlab does.

In Matlab we have the following, B = blkproc(A,[m n],fun) where fun is a inline function, m and n are block size in x and y directions and A is the Matrix we want to apply the function (bulk processing).

The OpenCV equivalent of the same would be:


while(condition)
{
cvSetImageROI( image, cvRect(point_x, point_y,  length_block_x, length_block_y) );
foo (image);
cvResetImageROI(image);
}


image is the IplImage we want to operate on, cvRect(x,y,length, width) defines the region of interest.
foo(image) would be the processing we would want to do on the block ROI we set.

Cheers!!

No comments:

Post a Comment