Sunday, 26 February 2012

Copying and Tiling with OpenCV

Recently,a friend of mine asked, how to perform the matlab function repmat(A,m,n) in opencv.
Okay, for those of you, who want to know what repmat does, this is a normal image


a.k.a Normal Image

Now, after you tile it, this is what it looks like
a.k.a tiled image
This is the basic functionality of repmat

Now, If you are new to OpenCV, this might seem a little hard at first. But I'll explain with the code first and if you still have any doubts, send me a mail.

The basic operation is simple, copy the source image into a specific region of the destination image. Repeat this n times. Here, two questions might arise, How do you copy the original image and how the hell do you choose the region. The answer to your questions can all be found in the explanation with code section below :-