LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Image rotation

Hi, I have a rather simple question. I found this demo by Altenbach that rotates an image in a picture indicator. How do I change the picture? 

0 Kudos
Message 1 of 14
(6,554 Views)

Use a file dialog to load an image using one of these tools.

 

(It you have problems with this, I would recommend to start with something simpler and do some basic LabVIEW tutorials first)

 

My program is really just a very simple demo. You should try to understand it, try to improve it, and adapt it for your purpose.

Message 2 of 14
(6,547 Views)

Hi! Thank you. I am now able to load my image using read PNG file. However, my picture sort of degrades in qualit. Is this normal? 

0 Kudos
Message 3 of 14
(6,520 Views)

You Start out with a rectangular grid of pixels. For an arbitrary rotation, there cannot be a 1:1 relation between old and new pixels so some distortion is expected. What is your image type (greyscale, paletted, rgb, etc.).

 

You can make a fancier algorithm by e.g. adding some antialiasing or by using bilinear interpolation to get the new values.

 

Can you show us the "degraded" image?

0 Kudos
Message 4 of 14
(6,503 Views)

Heres what they look like at 0degrees, 25degrees and 180degrees. There's some distortion when it's not at 0/180degrees.

 

Also, how do you permanently put the image in the vi? Currently, I will have to choose my image first.

 

image.png

0 Kudos
Message 5 of 14
(6,471 Views)

Create an indicator after the read function (right-click wire ... Create indicator). Run the VI once and load your image. Right-click the new indicator terminal and "change to constant". Delete all file IO related stuff and read from the new diagram constant instead, like in my example..

Message 6 of 14
(6,466 Views)

I see! Thank you.

 

Also, I'm trying to change the control, instead of a slider, I want it to read data from a VISA serial port. However, I'm having problems. Data won't flow past the VISA configure into the while loop. Could you advice me?

 latestt.png

0 Kudos
Message 7 of 14
(6,441 Views)

Yuor main while loop will stall forever because you have an event structure waiting for a value change of an indicator. That will never happen. Value change events are for controls operated by the user. You need to eliminate the event structure and simple wire the rotation code to the received value. Why use a shift register for the image? Just place the indicator after the inner for loop. Learn about dataflow!

 

(I was only looking at the snippet, not the actual code. Maybe tomorrow.)

 

Please attach the actual VI instead of a snippet, because things get a bit messed up, especially with the property nodes. A lot of your code looks weird and convoluted. How does a typical received string look like? Does the lower code alone communicate correctly with the instrument if you leave out the rotation code?

0 Kudos
Message 8 of 14
(6,423 Views)

I thought I'd hit on a gucci easy solution by modifying a dial or guage, replacing the needle with an image, but alas it does not rotate.

 

Anyway, my Spidey sense tells me you want this to use as an indicator for some software to talk to a quadrotor. Whilst a half decent modern PC will have enough grunt to do these kind of rotations in software, it's not something I would want being called in the 'main loop'.

 

There are a couple of different approaches-

1) Pre render a bunch of images at e.g. every 10 degree angle, and just display the correct one. Disadvantages: Memory use, limited rotation resolution.

2) 3D accelerated.

 

I would consider 3D accelerated. You can render something like this in LabVIEW's 3D picture control, and leveraging modern 3D cards the rotations essentially come for free in CPU terms. You will be able to rotate it precisely in 'real time' and you can even make it look smoother. Inverstigate the rendering options, like anti-aliasing and super sampling. Also, double the size of your source image in both dimensions, but display it at half scale.

 

0 Kudos
Message 9 of 14
(6,406 Views)

@ToeCutter wrote:

 

Also, double the size of your source image in both dimensions, but display it at half scale.

 


The LabVIEW picture control has a property called Zoom Factor.

 

You could use this to scale the picture easily.

 

http://digital.ni.com/public.nsf/allkb/55EEBE3A1ECC38F58625765600796F1C

 

 

0 Kudos
Message 10 of 14
(6,394 Views)