Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

PNG files Distorted

I am using Labview 7.1 with IMAQ 3.0 and Vision
I am taking 12 bit grayscale data from a Merlin Mid IR camera and saving as PNG files.
Labview writes and reads the data correctly. However other programs such as Matlab see the data distorted. Camera values that are around 600 show up around 42,000 on these programs.

I am using the default values with the save as PNG vi

Any ideas?

0 Kudos
Message 1 of 8
(5,103 Views)
Hi Air Force 1,

How are the other programs reading the image data, as a PNG file or as a 2D array of values?  I know that LabVIEW saves a 12-bit image as a 16-bit image (the next largest bit depth) where the pixel values use signed 16-bit integer values (I16).  Other programs may save and view 16-bit image data as unsigned 16-bit integer values (U16).  There is an excellent KnowledgeBase article that talks about this in more detail.  Let me know if this is not the information you're looking for.

Cheers,
Irene Chow
National Instruments
Applications Engineer
Message 2 of 8
(5,085 Views)
Irene
Thanks. I am using an unsigned integer and it is being stored as a signed in LV. Your suggestion works with all file types but PNG.

I used to have some gain and offset PNG files that I wrote with Matlab and used with LabView 5. In labview 6 those PNGs did not work and I switched to TIFF. Something changed between LV 5 and 6. I would prefer to use PNGs because of file size. Any idea what has changed or why LV PNGs have other incompatibilities besides the integer issue?
AF1
0 Kudos
Message 3 of 8
(5,050 Views)
Hi Air Force 1,

What version of NI Vision are you using?  I found a KnowledgeBase article that may describe your situation precisely, and it says NI Vision 6.0 corrected the issue.  Let me know if this helps.

Thanks,
Irene Chow
National Instruments
Applications Engineer
0 Kudos
Message 4 of 8
(5,038 Views)
Irene
Yes I have read the article. I am using Vision 7.1 and was using it when I took the images.

I have attached 2 files of the same data. The TIFF is correct when you subtract 32,768. The PNG I have no idea what is going on.

The upload utility is dorked up and does not support PNG or TIFF so please provide an email so that I can send them to you.
Thanks
AF1
0 Kudos
Message 5 of 8
(5,030 Views)

Air Force One,

Please Zip the files or change their individual extensions to attach to this thread.  Also, if you open the images with Windows Picture and Fax Viewer?

Thanks,

Scott Savage
National Instruments
Applications Engineering
www.ni.com/support

0 Kudos
Message 6 of 8
(5,017 Views)
Vision stores the PNG files according to section 9.1 (Sample Depth Scaling) of the PNG specification (see http://www.libpng.org/pub/png/spec/1.1/png-1.1-pdg.html#E.Sample-depth-scaling). This means a value of 600 really ends up at 38437 (if you apply the algorithm as specified). If the software that is reading the png file does not pay attention to the actual bit depth that is stored off, then it will read it as the actual value that is stored in the file which will be 38437.

Like Scott suggested, I would open the image in a viewer like the Window Picture and Fax Viewer. If that looks good, then I would be inclined to say that Vision is writing the file correctly.

Regards,

Satish Kumar
National Instruments
R&D
Message 7 of 8
(5,006 Views)
Here are the two files. If you take the TIFF and subtract 32,678 as in the previouslly mentioned articles you get the right answer. I created the TIFF from the PNG file that came off of the camera with LabView.
Thanks
AF1
0 Kudos
Message 8 of 8
(4,968 Views)