LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert an image to binary format

Hi!
 
I am currentyl trying to convert an 8 bit image to a binary image using IMAQ. However, it seems that 8 bits is the lowest it can go. How can I achieve the conversion? Please help..
 
Thanks
0 Kudos
Message 1 of 7
(6,280 Views)
Hi Wan,

8-bit is binary too Smiley Wink

Do you want a black/white picture (or: 1-bit color resolution)? There surely are some threshold functions in IMAQ (or: brightness/contrast controls) to calc your picture!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(6,260 Views)

Hi..

Thanks a lot. I actually want a 1 bit to represent each pixel in order to save as much space as possible. Can help suggest some VIs from IMAQ or any normal labview VIs?

 

Thanks In advance. Smiley Very Happy

0 Kudos
Message 3 of 7
(6,251 Views)
Hi Wan81,
If you are trying save disk space by writing your image out to a 1-bit file, I think the best way to do this would be to convert your image into an array of booleans, and then use the Flatten Pixmap VI to construct a pixmap of your image (with settings for no transparency, 1-bit depth, etc.) You could then use this pixmap with Write to BMP to write out a 1-bit image. See the LabVIEW help on the Graphics Formats VIs for more information.

To do the conversion into booleans, I would recommend thresholding your image into 0's and 1's, and then using two nested For Loops to build a corresponding 2-D boolean array based on whether the value at each pixel is 0 or 1.

If you are trying to save RAM by working with the image in memory as a 1-bit IMAQ image, then this unfortunately won't be possible. The normal IMAQ functions require at minimum an 8-bit image depth, such as Grayscale U8.

Message Edited by VGA CD-ROM on 04-22-2008 11:38 AM
0 Kudos
Message 4 of 7
(6,204 Views)
Hi Wan & Vijay,

to save disk space I would use WriteToPNG instead of WriteToBMP Smiley Wink
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(6,184 Views)
Hi GerdW,
That's a good point. I forgot that the PNG format does in fact support 1-bit color depth. Looking at the help confirms that the Write to PNG VI supports it as well.
0 Kudos
Message 6 of 7
(6,163 Views)

Hi Vijay and GerardW,

Thanks for the tips. Really appreciate it. I will give it a try in my lab later.

 

Best Regards

Ridwan

0 Kudos
Message 7 of 7
(6,126 Views)