LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use or convert a imaq image to plot images back on waveform graph

Hi

 

I am currently opening and manipulating (rotate and resize) a PNG image using IMAQ Vision in LabView 8.2.1 This works well and I can display the Image on the front panel using a IMAQ Image Control.
In addition to this I would now like to display the image as a background on waveformgraph. I can do this with the original PNG file by reading it and then flatten it to a pixmap ie make it a Picture but this is of little use as I need to use the manipulated IMAQ image.
Therefor I would like to know how to convert the manipulted IMAQ Image to right Picture Format (without resaving) in order to use it on the PlotImages.Back property node of a wavefrom graph.

I very much welcome your suggestions as I feel it should be easy yet can not seem to solve it. Thank you for your time!!!

0 Kudos
Message 1 of 7
(4,082 Views)
There is a fuction called Vision and Motion>>Vision Utilities>>Color Utilities>>IMAQ ColorImageToArray.  This function will output a 2D U32 array that represents the pixel data of the image.  Feed this data into Graphics & Sounds>>Picture Functions>>Draw Unflattened Pixmap vi.  I am assuming you are manipulating a RGB image.
Message Edited by rpursley8 on 10-24-2008 09:50 AM
Randall Pursley
0 Kudos
Message 2 of 7
(4,073 Views)

Thank you for your reply !

 

I have tried the function as you suggested but it does not seem to work as I work with PNG files rather then RGB.

 

I can open and work OK with the PNG files using the IMAQ image functions (Create, Read, Rotate) and I can display the image using a IMAQ Image Control.

Also I can open PNG files using the Picture functions (Read PNG , Flatten Pixmap) and display them as background to the graph.

 

What I want to achieve is a combination of both ie. Attch the ‘purple’ IMAQ image wire to the ‘blue’ Picture data wire of the PlotImages.Back.

 

Thanks again for your time and suggestions ! Would be great to get this solved before the weekend !

0 Kudos
Message 3 of 7
(4,060 Views)
Can you post the code?
Randall Pursley
0 Kudos
Message 4 of 7
(4,049 Views)
This worked for me.  Is you PNG file an RGB image?  I have attached the code and the image I was using to test it.  If you can post your image as well.
Message Edited by rpursley8 on 10-24-2008 12:43 PM
Randall Pursley
Download All
0 Kudos
Message 5 of 7
(4,047 Views)

Hi Randall

 

Apologies for replying somewhat late but I have been out of the office for a few days.

Your suggestions and code helped me greatly and led to solving my query so thank you for that.

 

There is one more thing (well many many more but I will place new posts for those Smiley Wink however that you might be able to answer for me.

Following your suggestion to use the image to array function I searched through more examples and found the code that did exactly what I wanted to do. Please see attached.

In this code a For loop is used to add 65793 to the color table. It works very well but I do not know why it is used exactly. Can you exlplain? I also realize I never made it clear that I use grayscale PNG files rather then color images.

 

Thanks again for your excellent help, it is much appreciated.

 

Download All
0 Kudos
Message 6 of 7
(4,005 Views)

The FOR loop is creating a color table to translate your 8-bit data into color data.  If you look at the array that is generated from the loop, the number 65793 is 0x010101 and it generates an array so the pixel values will translate as follows.

 

0 = 0x000000

1 = 0x010101

2 = 0x020202

3 = 0x030303,  ...

 

This will give a color table of shades of gray (Red, Green, and Blue components have same value).

 

 

By the way, if you use the code I posted it will automatically convert your grayscale image to RGB keeping the appropriate grayscale values.  In other words, it will read in your image and display it properly.

 

 

Message Edited by rpursley8 on 10-30-2008 02:03 PM
Randall Pursley
0 Kudos
Message 7 of 7
(3,990 Views)