11-28-2012 09:04 PM
I have used the Measurement and Automation Explorer (MAX) to snap an image using a Basler scA640-70fm CCD camera and then save the image in both TIFF and PNG formats. What I needed was the grayscale values for pixels in the image. I used another program (ImageJ) to convert the TIFF/PNG files to text image (i.e. grayscale values in a .txt file). But when I did that I noticed that the TIFF and PNG files for the same image produced very different pixel values. Also, given that the CCD camera bit depth is 12, I expected the text image to have no pixels with value greater than 4095 (i.e. 2^12 - 1), but the highest pixel value in the text image created from the TIFF file was in fact 36863; i.e. it seems the image is a 16-bit image..
I'm not sure what I need to correct. Is it not possible to use MAX to save the grayscale values for a CCD image?
Thanks,
Neil
Solved! Go to Solution.
11-28-2012 09:42 PM
You need to take into account that there is no such thing as 12bit file format. In reality it's either 8 or 16 (or something else for RGB and HDR iamges).
12 bit that you mentioned is a dynamic range of your camera. So it cannot give you a value more than 2^12-1. However in MAX you can adjust exposure, gain etc. Some of these parameters can affect image dynamic range so you can have any value up to 2^16-1.
All in all it is impossible to save pixels' values in MAX. However this information is easy go get using Labview Vision module or Picture functions (these i free i belive and come in package with labveiw).
www.xinstruments.com - Custom Software for Industrial Automation
www.hdrconverter.com - Picture processing made easy
11-28-2012 09:46 PM
If you look closer, you will notice the 4 lower bits are all zeroes. If you bit shift all the numbers to the right 4 bits, you will get the 0-4095 range that you expect. Max just put the zeroes in a different place than you expected.
Bruce
11-29-2012 02:35 PM
Thank you. It seems that NI Image Acquisition software is not included in our university site license for LabView.
11-29-2012 02:46 PM
@BruceAmmons wrote:
If you look closer, you will notice the 4 lower bits are all zeroes. If you bit shift all the numbers to the right 4 bits, you will get the 0-4095 range that you expect. Max just put the zeroes in a different place than you expected.
Thanks for the tip. I looked at the pixel values from the TIFF file and it seems the 4 lower bits are in fact non-zero. I also looked at the pixel values from the PNG file; it does have 4 lower bits that are 0. (I have attached both files.) Do you think the PNG file is the one to use after right-shifting? I do wonder why the TIFF and PNG files produce different pixel values.
Thanks,
Neil
11-30-2012 08:00 AM
I am pretty sure PNG does lossless compression, which means you get the exact same values back when you reload the file.
I suspect TIFF does some compression, which changes the values slightly, including the lower 4 bits.
If you want to be absolutely sure, you can always use BMP, which does not do any compression. I always use PNG, because it reduces the file size without introducing any artifacts.
Bruce
11-30-2012 11:15 AM
@BruceAmmons wrote:
I am pretty sure PNG does lossless compression, which means you get the exact same values back when you reload the file.
I suspect TIFF does some compression, which changes the values slightly, including the lower 4 bits.
If you want to be absolutely sure, you can always use BMP, which does not do any compression. I always use PNG, because it reduces the file size without introducing any artifacts.
Thanks. I think MAX only saves images in TIFF or PNG formats; I don't think BMP was one of the options.
The TIFF file was compressed, but I think as long as the compression wasn't lossy, the bit values should not change. Do you know whether Measurement and Automation tool uses lossy or lossless compression? (BTW, MAX seems to have converted 12 to 16 bits by adding 2^15 to all bit values in the TIFF file.)
Could someone from NI please confirm that the PNG files created by MAX contain actual image pixel values suitable for quantitative analysis?
Thanks,
Neil
11-30-2012 03:47 PM
Hi Neil,
Use PNG if you want to process images. PNG is a lossless format. I never liked TIFF for 16-bit images. When we implemented that code, the TIFF standard only supported 8 bit images, and different vendors added 16 bit support in different and incompatible ways.
-Jeff
12-01-2012 08:20 PM
Thank you.
12-03-2012 06:38 PM
Apropos using the PNG file for image processing, how does one convert the 16-bit data in the PNG image saved by MAX to 12-bit data? The CCD bit depth is 12, so it can't output more than 12 bits. (I was hoping the 4 most significant bits in the PNG image pixels would be 0, but they're not.)
Thanks,
Neil