OpenCV
Open Source Computer Vision
|
Prev Tutorial: Object detection with Generalized Ballard and Guil Hough Transform
Next Tutorial: Affine Transformations
Original author | Ana Huamán |
Compatibility | OpenCV >= 3.0 |
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
Load an image:
Create the destination image and the two mapping matrices (for x and y )
Create a window to display results
Establish a loop. Each 1000 ms we update our mapping matrices (mat_x and mat_y) and apply them to our source image:
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.