How to realize the Translation of Image by C++
This article mainly explains "how to realize the image translation of C++". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "how C++ to achieve image translation" bar!
Translation of image
Moving is to regard the image as a whole, and the display cannot be like scanning. The scanning mode is somewhat like opening a painting. For example, when displaying the upper part, the lower part can be unrealistic, while the movement can be seen as a plank painting. When displaying, it must be carried out in physical order. For example, when translating from top to bottom, you must first display the lower image and then display the upper image, so the translation algorithm is more difficult than scanning.
Panning is a copied method to display the image, and each time it is displayed, the number of copied rows is increased by one line until the display is complete.
/ / Mobile display void Mobile_display () {/ / read picture Mat srcImage, dstImage; srcImage = imread ("2.jpg"); dstImage = Mat (srcImage.size (), CV_8UC3); imshow ("original image", srcImage); / / define variable Mat roiImage; int ImageHeigth = srcImage.rows; int ImageWidth = srcImage.cols; namedWindow ("mobile display"); for (int I = 1; I < ImageWidth) 1 roiImage = srcImage (Rect (ImageWidth-i, 0, I, ImageHeigth)); roiImage.copyTo (dstImage (Rect (0,0, I, ImageHeigth)); imshow (Mobile display, dstImage); waitKey (5);} waitKey (0);}
Moving picture
Intermediate expansion
When we turn on the TV, we all have the feeling that the TV image starts in the middle of the screen and expands up and down, and this effect is the expansion in the middle. In fact, the principle of the middle expansion special effect display is not difficult. During the display, the image is divided into two parts, the middle boundary is displayed in the center of the screen, and the image is quickly scanned upward and downward, and finally the image is fully displayed on the screen. In this way, people will see the effect of middle expansion because of the characteristics of visual physiology.
/ / void Middle_expansion () {/ / read the picture Mat srcImage, dstImage; srcImage = imread ("2.jpg"); dstImage = Mat (srcImage.size (), CV_8UC3); imshow ("original image", srcImage); / / define the variable Mat roiImage; int ImageHeigth = srcImage.rows; int ImageWidth = srcImage.cols; namedWindow ("intermediate extension"); for (int I = 1; I