![]() |
OpenCV
Open Source Computer Vision
|
Prev Tutorial: Hough Circle Transform
Next Tutorial: Affine Transformations
In this tutorial you will learn how to:
a. Use the OpenCV function cv::remap to implement simple remapping routines.
We can express the remap for every pixel location
where
Let's think in a quick example. Imagine that we have an image
What would happen? It is easily seen that the image would flip in the
observe how the red circle changes positions with respect to x (considering
The function that applies the remapping is cv::remap . We give the following arguments:
How do we update our mapping matrices mat_x and mat_y? Go on reading:
This is expressed in the following snippet. Here, map_x represents the first coordinate of h(i,j) and map_y the second coordinate.
After compiling the code above, you can execute it giving as argument an image path. For instance, by using the following image:
This is the result of reducing it to half the size and centering it:
Turning it upside down:
Reflecting it in the x direction:
Reflecting it in both directions: