LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert picture data type to array

I am using labview 6i and working on image processing. i was able to use a draw flattened pixmap block(Picture control) to convert array to picture. but after a few cosmetic addition to the picture i need to back convert picture to Array? how do i do so in 6i??

Ankur
0 Kudos
Message 1 of 9
(6,035 Views)
Hi Ankur,

I sending you one VI. Sorry but I don't have time to enhance this code. But I mind this code help you.

Have a nice day

JCC

P.S.: I don't know why, but not working well 'rect' in "Write JPEG File.vi".
0 Kudos
Message 2 of 9
(6,011 Views)


@ank wrote:
I am using labview 6i and working on image processing. i was able to use a draw flattened pixmap block(Picture control) to convert array to picture. but after a few cosmetic addition to the picture i need to back convert picture to Array? how do i do so in 6i??

Ankur



Hi Ankur !
Seems you are quite in a hurry for your project !
Some explanations :
A LV picture is not a bitmap array. It's a vectorial thing that can be regarded as a cluster describing the various parts of the picture (for instance a square, plus a line, plus some points, plus a bitmap, plus...
When a LV pict contains only a bitmap picture, it is possible to extract nearly easily the bitmap array and the color table, after a flatten to string operation. But any modification of the picture, for instance drawing a line or adding a few dots, will make things considerably more complicated. So, forget it...

The alternative method is to convert the picture to a pixmap, using the method indicated by Micah Boyd and Marcel Kaft in a previous post. However, as you noticed, you have to remove label and border. Additionnaly, the image can be larger or smaller than its displayed part.

Here is how to do everything right :
1/ Hide the label : there is a property node that do the job
2/ Increase or decrease the picture size as needed, using the DrawAreaSize property node. The lower size limit is 11 pixels (w and h).
3/ Use the GetImage method to get the picture array (and the color table... see later on)
4/ Resize the picture control to its original size, and make the label visible again (if required)
Of course, this will produce some flicker on the screen. To avoid that, use the defer update panel property.
5/Remove the border. Easy, since the array is really a bit map array, ie each point is coded as RVB, using 3 bytes. Since the border is 3 pixel wide, a simple array manipulation remove the excess pixels.
6/ How do we get the color table ? That's the easyiest part : there is no color table, since it is a RVB picture !

The attached vi do the trick. It could be improved to retrieve only a specific part of the picture, but I have not enough time for that.

Enjoy !

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
Message 3 of 9
(6,008 Views)
Hum, I made some confusion with several vi versions. This one is the good one...
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
Message 4 of 9
(6,005 Views)
thanks for the help guys. My real problemb was to preserve the colour table too. My project involves the addition and manipulation of images, hence the problem. will work with these and get back to you.

Thanks 🙂

Ankur
0 Kudos
Message 5 of 9
(5,994 Views)
Hi Ank !
There is no color table associated with true RGB images !
Color tables are only used with other formats, to try to reduce the file size.

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 6 of 9
(5,963 Views)
Guys,

I tried to use the get image method node for a picture control. after cutting out a 3 pixel width all around the array the resultant array was not the same as the source image attached is my attempt please help.

Ankur
0 Kudos
Message 7 of 9
(5,940 Views)
May be you should have a look at the vi I sent in a previous post...

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 8 of 9
(5,934 Views)
CC,

Just came across this while having the exact same problem.

Great stuff (As usual)

Stars for you ***** *****

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 9 of 9
(5,537 Views)