LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save 16-bit BMP as 24-bit BMP

Hello,

 

I am not very experienced when it comes to image processing,

 

I am trying to acquire an image from my 12-bit camera.  I have done this successfully; it gets turned into a signed 16-bit image, which I would like to save as a 24-bit BMP.  For some reason, IMAQ does not allow me to write to file as a BMP.  I get an invalid image type error.  I messed around and wrote to file as a PNG and named the file *bmp, however, I am concerned that the image is being compressed/losing data.  Ultimately, I will feed these images into a program I wrote that works with the images as 2D arrays.

 

So,

 

1. What is the best way to save the files as a BMP.

2. How can I make these BMPs 24-bit instead of the automatic 16-bit signed they are.  The code I have already works with 24-bit images only.

 

Many thanks.

0 Kudos
Message 1 of 7
(5,124 Views)

PNG is basically a compressed BMP, a 24-bit GIF, it's non destructive. You cannot, however, just change the file extension! It's a description for the system how to interpret the file, it doesn't change the file. It's the equivalent of measuring your waist in inches instead of centimeters, sure the number is lower, but you're not any smaller.

Some programs are smart enough to realize it's actually a PNG and open it as such, others will try to read it as a BMP and it'll be severely corrupted.

 

If you can get the Image data you can use the ordinary picture-functions to save it as BMP.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 7
(5,120 Views)

Hmm, so I got the array as an unsigned 16 bit, but the standard write to BMP does not support writing a 16 bit.  If I write it as a 24 bit it looks wrong (obviously)

 

How can I save the BMP as a 16 bit and also work with the raw data?  The bmp to array VI doesnt support it 😞

0 Kudos
Message 3 of 7
(5,094 Views)

hi max,

 

could you post an example 16 bit bmp?

 

 

Regards,
Alex

0 Kudos
Message 4 of 7
(5,077 Views)

If I understand you correctly, you are trying to preserve the 16-Bit data, but you want to save the image as a BMP, possibly for ease of viewing.

 

The problem is that these two goals are mutually exclusive.  The BMP format is only 24-bit as it applies to color images.  Each channel red, blue, green is assigned 8-bits of intensity.  If you wanted to preserve the data, by spreading the 16 bits out over the RBG channels, the resulting image is going to be unpredictably ugly.  I'm assuming that your camera is greyscale, of course.

 

There are several approaches you can take.  You can save two images:  An 8-bit BMP, and a 16-bit PNG.  You can save the 8-bit image as a PNG, and use the VISION DATA vis to include the 16-bit values as an array.  

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
Message 5 of 7
(5,073 Views)

Yes, John has it right.  I did not quite understand what I was doing until just now.  Whoops.

 

So, I do not need to work with 24-bit BMPs, that would be a waste.  I do need to preserve the 12 bits of gray, which appears to be automatically turned into a signed 16 bit image by IMAQ.  But then I also need to view the data and manipulate the arrays, which cannot be done with the standard flatten/unflatten pixmap VIs. 

 

I don't quite understand your recommended approaches.  Is there not a set of VIs that can save 16 bit BMPs and convert to arrays?  Where are the VISION DATA VIs if I want to save as PNG and then get raw arrays out?

0 Kudos
Message 6 of 7
(5,067 Views)

in the meantime, I came up with some sample data;

 

here's what I would do, if I needed a quick solution:

 

2013-07-24_I16tobmp.png

 

 

alternatively,

you can look at the blockdiagram of LabVIEW\vi.lib\picture\bmp.llb\Write BMP File.vi !

so, you are able to modify the write bmp file.vi and figure out how it works and then change it.

 

 

 

Regards,
Alex

0 Kudos
Message 7 of 7
(5,059 Views)