LabWindows/CVI User Group Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

rotate an image using cvi

In image processing, rotation of an image is an initial step, and this workshop demonstrates how to do this job using NI LabWindows™/CVI. CVI follows ANSI C and allows user to control the low level memory. The processes of rotation mainly contain identity, allocation, and duplication. The functions used in this demo include “GetBitmapFromFile”, “AllocBitmapData”, and “GetBitmapData”, in thumb. “GetBitmapFromFile” loads a bitmap file from selected path, and gives a unique identity. “AllocBitmapData” allocates data buffer related to color table, data buffer, and mask buffer, respectively. “GetBitmapData” obtains the detailed information, i.e. width, height, depth, of the original image. The variable “src” and “dest” is the row data related to source image and destination image, and “calloc” located the size of “dest” when the size of row data is determined after “GetBitmapData”. The step illustrated above is antipasto, and the main course is duplication. The manuscript uses three loops to achieve this work and makes a copy from the sources address to destination address. “NewBitmap” is an enclosure dessert and appoints the data buffer “dest” to an image. “DiscardBitmap” and “free” function is table manner after all the processes have been completed. By the way, user must claims the variables used in the manuscript in advance, and this is a big difference to those who familiar with MATLAB or LabVIEW.

Step 1: GetBitmapFromFile(filename, &bmpSrc);

Step 2: AllocBitmapData(bmpSrc, &colorTable, &src, &mask);

Step 3: GetBitmapData(bmpSrc, &bytesPerRow, &pixelDepth, &width, &height, colorTable, src, mask);

Step 4: dest = calloc (width * height * pixelDepth / 8, sizeof (unsigned char));

Step 5: dest[(height - 1- i) * bytesPerRow + (width - 1 - j) * pixelDepth / 8 + k] = src[i * bytesPerRow + j * pixelDepth / 8 + k];

Note :

1. ANSI is the aberration of “American National Standards Institute”

2. I'm Fresh user of CVI community, please notify me if any improper usage, thanks you !

Contributors