Reading Tips:
C ++ image processing SeriesCodeIt is clear and readable, and all uses C ++ code.
《Delphi Image ProcessingThe series focuses on efficiency. The general code is Pascal, and the core code is BaSm.
Make sure that the two items are consistent and can be compared with each other.
The code in this article must include "C ++ Image Processing-data types and common functions"Article.
The image flip process generates an image that is opposite to the original image in the horizontal or vertical direction.
The principle of image flip is very simple, that is, based on the pixel (horizontal direction) in the middle column of the image, or the middle row pixel (vertical direction) as the base column (ROW), the first column (ROW) of the image) the pixels of the image are exchanged with the pixels in the last (ROW) column of the image, and the pixels in the second (ROW) column of the image and the second (ROW) column of the image) pixel switching ......, until the base column (ROW), if the number of columns (rows) in the image is an even number, the columns (rows) at the beginning and end of the image are exchanged, including the base column (ROW, if the number of columns (rows) in the image is an even number, the base column (ROW) remains unchanged, and the columns (rows) corresponding to other headers and tails are exchanged in pairs.
The following is the implementation code and example of image flip.Program(Use bcb2010 and GDI + ):
// Inclutypedef Enum {reversalmodehorizontal, // horizontal flip reversalmodevertical // vertical flip} reversalmode; // image flip (image) void imagereversal (bitmapdata * data, reversalmode mode Mode) {uint width = data-> width; uint Height = data-> height; int srcoffset = data-> stride> 2; int dstoffset, Delta; pargbquad PD, PS; argb color; If (mode = reversalmodehorizontal) {Pd = (pargbquad) Data-> scan0; PS = Pd + width-1; dstoffset = srcoffset; Delta =-1; width >>=1;} else {PS = (pargbquad) Data-> scan0; Pd = Ps + (height-1) * srcoffset; dstoffset =-srcoffset; Delta = 1; height >>=1 ;}for (uint y = 0; y
The image after the example is run is as follows, with the source image on the left and the horizontal image on the right:
Due to limited levels, errors are inevitable. Correction and guidance are welcome. Email Address:Maozefa@hotmail.com
You can access 《C ++ Image Processing-document indexing".