LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array to greyscale imaq

Hello,

 

i try to convert  2d array of float to BMP file but it doesn't works. the error is invalid format.

 

thanks for your help.

0 Kudos
Message 1 of 2
(2,834 Views)

Hello,

This link could be helpful for you but it is in French:

 

http://digital.ni.com/public.nsf/allkb/6DA98CB6E708F1A586257177004BC60B?OpenDocument

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------

The English version says:

Document Type

OK for Web

 

Title 

Converting 2D Arrays to Grayscale Pictures Without IMAQ VIs

 

Problem 


How do I convert a 2D array of pixel values into a grayscale image in LabVIEW if I don't have NI-IMAQ or the Vision Development Module?

 

Solution 


You can use the Flatten Pixmap VI to convert the 2D array. This VI is available in the Graphics Formats Palette, which comes with LabVIEW Full and Professional Development System but not the LabVIEW Base Package.

The example program attached below demonstrates how to convert a 2D array into an 8-bit or 24-bit grayscale image and then save it as a JPEG image, as explained in the following steps:

  • Use Flatten Pixmap.vi to convert the 2D array into a 1D array of image data. In this case, a 2D array of unsigned 8-bit integers was used as the pixmap input.
  • To create an 8-bit grayscale image, the color input is an array of 256 elements (the RGB color values) that correspond to the values from the pixmap input. To create a 24-bit grayscale image, the color input is ignored, but the 2D array of unsigned 8-bit pixmap must be converted into 24-bit pixmap data.
  • To save the image as a file, you can use Write JPEG File.vi, Write BMP File.vi, or Write PNG File.vi.
  • To view the image on the front panel, use the Draw Flattened Pixmap.vi. (Remember, since you are not using the NI-IMAQ drivers or Vision Development Module, you will be using the LabVIEW picture control to view image, not the IMAQ Image Display control.)


Note: All of the VIs mentioned above can be found in the LabVIEW Functions palette under Programming » Graphics & Sound » Graphics Formats or Picture Functions.

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Other link helpful:

 

https://decibel.ni.com/content/docs/DOC-4155

http://digital.ni.com/public.nsf/websearch/4384D228C02AE46986256E71007F5DF9?OpenDocument

https://decibel.ni.com/content/docs/DOC-9534

http://digital.ni.com/public.nsf/websearch/B6258C0AE767659D86256F3900578F6A?OpenDocument

 

Regards

Samuel G. | GEMESIS

Certified LabVIEW Architect

Certified TestStand Developer

GEMESIS.EU

0 Kudos
Message 2 of 2
(2,808 Views)