LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Rotate a bit image(not text) with given angle

Aim of the application was to rotate the bit map image with the angle inputs given as 0-360 degrees(like transformation of an image). I tried with graph, and plot a polygon and i rotate it as per the given degree, but i couldn't able to do it in bitmap image, which we loaded.

 

Kindly provide, how i can read the bitmap and tilt it as per the degree i want.

Download All
0 Kudos
Message 1 of 4
(3,514 Views)

Hello Harihara_Balaji,

first of all, your project does almost what is supposed to do, it simply needs some minor corrections: look at the modified code I am attaching.

 

The corrections I made are the following:

  • No need to programmatically display additional axes: simply edit the corresponding graph axis and check "Show labels" checkbox Smiley Wink
  • I also made scales -100 to 100 and disabled autoscaling so that images maintain their proportion in the graph when rotated
  • Promotion of all variables to doubles, to avoid rounding errors in calculations
  • Use of PI macro which has a greater precision

What is important to understand, is that the algorithm you are using rotates the polygon around the origin of axes (that is why I used bidirectional scales). To demonstrate is simply update "angle" variable by typing a new value or using up/down arrows and see the result on the second graph; I also added coordinates for a rectangle around the origin for you to see a different pattern result.

To rotate a polygon around its center you may for example calculate the center of the image, translate its coordinates so that it matches the origin, rotate and then move it back to original position.

 

 

Now, coming to your "real" question, rotation of an image is a bit more complicated, as it implies to deal with every pixel and with color depth. Additionally, when the angle is not a multiple of 90° you must consider aliasing, that is pixels that after rotation do not fall on the pixel grid (i.e. rotated coordinates are not integers). This implies some antialiasing algorithm to be used to correct those errors. Not a trivial task. Anyway, you can find some documentation on the web, for example on this page and this other one: these informations can give you a starting point for you to elaborate on.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,509 Views)

Hi Roberto,

 

 

         Thanks for your valuable replySmiley Happy, it's very helpfull for me, i will try to rotate the image based on the inputs you have provide. I will attach the files, after i accomplish my project. Thanks once again....

 

 

0 Kudos
Message 3 of 4
(3,503 Views)

Dear Roberto,

 

 

                   I tried with the documents u provided, but still i feel difficulty to tilt an image, i can't able to read the pixels, i only can read the width and the height of the loaded image. Kindly provide few more solutions to tilt the image(bitmap) file with the angle as input.

0 Kudos
Message 4 of 4
(3,447 Views)