LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change picture aspect ratio in LabVIEW?

Solved!
Go to solution

I would like to change aspec ratio of my picture. Is that possible in labview.

To show it on example. I would like to take this picture:

 

Picture 1

 

and convert it to something like this:

 

Picture 2

0 Kudos
Message 1 of 11
(5,142 Views)

If you're working with actual images in LabVIEW then consider using the IMAQ tools for image manipulation. This vertical aspect ratio change is effectively a resample in the y dimension, so can resize a 600x600 image to 600x450 (for example).

 

If you don't have the IMAQ tools available, then convert your image to a 2D array and perform interpolation on each column, then convert back to an image. The image conversion utilities are in the Picture palette (flatten and unflatten).

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 11
(5,125 Views)

Thank you for your answer.

I'm trying now with your second proposal (i don't have IMAQ tools) and i'm having problems with perform interpolation part. 

I convert image to 2D and get all the columns from array. Problem is then that i really don't know how to do interpolation right. I don't get any usefull result.

Can you show me how to do only the interpolation part? Or maybe if there is any examples how to do it.

 

 

0 Kudos
Message 3 of 11
(5,098 Views)
Solution
Accepted by topic author Schime

Here is something I put together quickly based on the suggestion of using interpolation. You could expand on this to increase the image size based on a width and height percentage or set aspect ratio.

Message 4 of 11
(5,089 Views)

@Lourens wrote:

Here is something I put together quickly based on the suggestion of using interpolation. You could expand on this to increase the image size based on a width and height percentage or set aspect ratio.


Nice native solution, but when I need to do this I use .NET with a GDI resize function.  In testing it ran about 3-4 times faster than the solution you came up with.  .NET also supports multiple file types not just PNG, and it supports alpha layers in PNG files which is a royal pain to try to do nativly.  Of course not everyone can use .NET and not all environments support it.

Message 5 of 11
(5,086 Views)

Thank you both for examples.

 

0 Kudos
Message 6 of 11
(5,075 Views)

@Schime wrote:

Thank you both for examples.

 


If you really want to thank us you'll give kudos to posts that helped, and possibly mark a post as the solution to the topic.

0 Kudos
Message 7 of 11
(5,066 Views)

Done. 🙂

 

I tried Lourens solution and it worked fine. Transformation takes some time but it's ok.

For your example i'm missing a vi when i load it so i didn't test it yet.

0 Kudos
Message 8 of 11
(5,027 Views)

@Schime wrote:

Done. 🙂

 

I tried Lourens solution and it worked fine. Transformation takes some time but it's ok.

For your example i'm missing a vi when i load it so i didn't test it yet.


Oh you are so right I'm sorry.  That missing subVI isn't needed if you are providing a path and not the Image Data.  So I'd recommend deleting the Image Data control, and remove the case structure, leaving only the False case.  Then it will work.

Message 9 of 11
(5,011 Views)

Thanks. I used only GDI Resize Image Hooovahh Version.vi and did what you told me to do and it worked just fine. It's super fast.

 

This problem is solved thanks to you guys. Smiley Happy

0 Kudos
Message 10 of 11
(4,995 Views)