LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rotate an Image by specified pixel

Imaq Rotate.vi is to rotate an image around its center point (correct?).

 

I need to rotate an image by a user-specified point in the image. What I have in mind is to expand the original image so that the specified point becomes the center of the new image, rotate this new image, and trim the image back to its original size. Is this the right way to do it? Or I am making it too complicated?

 

rotation.jpg

0 Kudos
Message 1 of 10
(5,284 Views)

Whether you rotate about the center of the image, or any other point in the image after re-dimensioning the image, the angle of rotation is the same.

 

If your goal is to preserve the original image dimensions you can wire a T to the maintain image size boolean.

 

If your goal is to end up with the red dot in the middle, then resizing before rotating is the quickest path.

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
0 Kudos
Message 2 of 10
(5,272 Views)

A rotation does not change the shape of your image. If you apply IMAQ Rotate on your image by e.g. 90 degrees clockwise, you will get a satifying result.
Your approach would introduce more effort than required. Especially "trimming back the image to its original size" should make the resulting image look very close to what IMAQ Rotate is doing. So I would stick with IMAQ Rotate.

0 Kudos
Message 3 of 10
(5,270 Views)

No, my goal is not to keep the random point in the center. The goal is to rotate the image around the selected point. The end result is every other pixels are all moved but the selected point.

0 Kudos
Message 4 of 10
(5,262 Views)

I know Rotate.vi won't change shape, but when you rotate an image around a different point, the relative positions of each pixel will be different. That's why I wanted to rotate by a random point, instead of the center point all the time.

0 Kudos
Message 5 of 10
(5,259 Views)

You mean that the "selected point" has the same absolute coordinates at the end as in the beginning? Simply use the IMAQ Rotate like they are telling you to, then translate all of the pixel coordinates by the negative of the X and Y distances that you moved this pixel in the first place (easily calculated by the distance from the nearest corner before rotation and the size of the image, so you don't really have to locate it again).

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 6 of 10
(5,256 Views)

I am not able to follow you. Rotate around the image center first and then what? Where do you feed in the 'selected point'?

0 Kudos
Message 7 of 10
(5,250 Views)

You can calculate the center point of the image and you know "your point". When using IMAQ Rotate, you can also calculate where "your point" will be in the reulting image. That's all you need to go further.

 

0 Kudos
Message 8 of 10
(5,237 Views)

All right. First, do you want your "selected point" to have the same absolute coordinates in your new image as in the original? If yes, keep reading. If no, all that follows is irrelevant.

 

In the following discussion, you need to bear in mind that I have not used NI Vision stuff, but the Vision functions seem to be very straightforward.  It seems NI has made it easy for you.

 

The first thing you have to do is determine the X,Y coordinates of the point you want to rotate around ("selected point"). I'll leave that to you, since you've got to pick a point somehow.

 

From the dimensions of the image, the coordinates of your point, and the angle you want to rotate your image through, calculate the X,Y vector that you will "move" your "selected point" along your coordinate system if you do a simple rotation.

 

From the Image Manipulation subpalette of the Vision Utilities palette, use the IMAQ Rotate function to rotate your image hawever far you want.

 

From the same subpalette, use the IMAQ Shift function to translate the entire image back along the vector you determined 2 steps ago to put the "selected point" back where it was originally.

 

If that doesn't do it, it's probably impossible Smiley Wink .

 

I don't know how to break it down any better than that.

 

Cameron

 

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 9 of 10
(5,233 Views)

@ericward wrote:

 Not sure whether this post will offer some help. But there are several posts talking about the image rotation at specified point.

 

http://stackoverflow.com/questions/10026905/how-to-rotate-an-image-about-a-point-that-is-not-the-ima...


@MengHuiHanTang wrote:

I know Rotate.vi won't change shape, but when you rotate an image around a different point, the relative positions of each pixel will be different. That's why I wanted to rotate by a random point, instead of the center point all the time.



Thanks for sharing the info. I will check it later.

 

 

 

Best regards,

Arron

0 Kudos
Message 10 of 10
(4,059 Views)