LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read the raw image file

I want to read the raw image file , i have the basic labview 8.0 version
0 Kudos
Message 1 of 13
(12,228 Views)
That is a broad question... I'll make some asumptions.


I think you have a file with some raw image format. This can be quite a few formats. Every camera firm has it's own proprietry format. Often, when talking about a raw image, it is simply a 2d array of colors. So you'll have a file with numbers that are U8's that represent R G B, alpha R G B, B G R, etc., or a U32 that represent the same, combined in one U32...


The data can be stored binary or ASCII. Both formats are handled differently.


The ASCII format can be one large array of data, or seperated with enters for each scan line.


In both cases, you might need to remove information, like height and width, from the data before parsing the image data.


You can use the "Spreadsheet String To Array" to convert the a ASCII string to a LabVIEW 1D or 2D array. Or use "Read From Spreadsheet File.vi" to read the file directly as an array. Use Reshape Array to convert a 1D array to a 2D array.


The binary file is a bit different. Use "Read Binary File". It will get you a string. This string is a converted array of U8, the string doesn't need to be ASCII. convert this string to an array of U8's, with "String To Byte Array". Convert the 1D array just like before.


Now you have a 2D array. You can convert it into a pixmap with "Flatten Pixmap.vi". You can then display it in a picture control with "Draw Flattened Pixmap.vi".


Regards,


Wiebe.
0 Kudos
Message 2 of 13
(12,226 Views)
Hi, I have a similar problem. I acquired Images and saved them as binary files. Now I want to open them, display them and save them as one of the supported image formats (jpeg,bmp, etc.).
I followed what was suggested in the previous post for the first two steps and it seems to work (except that I don´t know exactly what the input should be for "color" in flatten pixmap. My images are in grayscale. ). Anyway, for the last step (transform the picture into image) I don´t know how to do it.
Any suggestions? I have Labview 8.2.

Thanks,
Gabriele
0 Kudos
Message 3 of 13
(11,974 Views)
Hi Gabriele,

If you have managed to convert the data into a 2D array of pixel values, you should be able to convert this to an image data type using the IMAQ ArraytoImage VI.  This is located in the Functions palette under Vision and Motion -> Vision Utilities -> Pixel Manipulation.

If this does not allow you to save your image correctly, it may help if you post an example binary file and the code you have developed so far.

I hope this helps.


Rishee B.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 13
(11,947 Views)
Hi Risheeb,
Unfortunately, I have the Image to array.vi but not the Array to Image.vi in my Vison and Motion palette. I don´t know the reason!
Is there a way to overcome this problem? If not, What add on do I need to install to get that vi?
I myself tried to save picture as a JPEG file using the write to JPEG.vi on the graphic and sound palette, but it gives me an error asking for a GPIB controller, which I don´t know!
I attach the piece of vi I wrote so far, any suggestion is welcome!

Thank you very much,

Gabriele
0 Kudos
Message 5 of 13
(11,931 Views)
If you want to convert it to a picture control, you can use "Draw Flattened
Pixmap.vi". No need to install the Imaq or Vision packages!

Since MB339 only wants to display them, and save them to jpg, using labview
functions (i.s.o. Vision) might save a few bucks. You do need the
professional version though. (Without the professional version, you can
still display it, but you need to do it in

The color table is a 256 entry array, each element a u32 representing a
color. If you have a picture with grayscales, each pixel is probably a u8.
Each u8 should refer to an entry in the color table. So, pixel value 255
refers to color table element 255. If this pixel is white, the color table
entry 255 should be 0x00FFFFFF (00RRGGBB, so black is 00000000).

You can also convert the input array of u8's to u32 by multiplying the u8
with a u32 with value 00010101. For a pixel value of 255 (FF) this results
in a new pixel 00FFFFFF. Now you can wire this to the U32 input of "Draw
Flattened Pixmap.vi", and there is no need to wire the color table anymore.
Nore that this new array is 4 times bigger in memory!

The output "image data" from "Flatten Pixmap.vi" should be connected to
"Draw Flattened Pixmap.vi". Create a new control from the "new picture", and
it should display the image!

Regards,

Wiebe.


0 Kudos
Message 6 of 13
(11,929 Views)
Thanks a lot Wiebe,
I found the information about the color map very usefull but this still does not solve my problem since I do want to save the pictures!
I have a NI-IMAQ 3.7, shouldn´t that include Array to Image.vi?

Thank you again,

Gabriele
0 Kudos
Message 7 of 13
(11,924 Views)
The pixmap htat you put in the "Draw Flattened Pixmap.vi" to display as a
picture control, you can also put in "Write JPG File.vi" in "Graphics &
Sound>Graphics Formats". You can store pixmaps as jpg, png and bmp.

Regards,

Wiebe.


0 Kudos
Message 8 of 13
(11,917 Views)
Hi Gabriele,

I apologize, I forgot that the IMAQ ArraytoImage VI is part of the Vision Development Module (VDM), not the NI-IMAQ drivers, so you should use Wiebe's suggestions if you want to do this without installing the VDM.

If you're still having difficulty implementing Wiebe's suggestions, please consider posting an example binary file so we play around with it as well.  Thanks.


Rishee B.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 13
(11,905 Views)
Hi Risheeb,
the problem with impelmenting Wiebe´s tips is that, when I try to save the pixmap using the write to JPEG(or similar).vi  I get an error which says that the "GPIB controller" is reqired.
This time I attach an examply binary image, as you suggested!
Thanks a lot for your help!

Regards,
Gabriele
0 Kudos
Message 10 of 13
(11,892 Views)