Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving U16 data from aipd to png format

I am acquiring U16 data from a CCD and saving as U32 data in AIPD format. To use the data in applications outside Labview, I want to save the data in PNG format. To do this I am subtracting 32768 and then casting as I16 before using IMAQ Write PNG file.vi. Whether I set 'Use bit depth?' to true or false is making no difference: images are mapped in the PNG file such that the lowest value becomes zero. For example, an image acquired with a range 3000 to 62535 becomes 0 to 59535 in PNG. How can I preserve the correct values in the PNG file?
 
I am using Labview 8.0 with Vision Dev Module 8.0. PNG files are opened in e.g. Cinepaint.
0 Kudos
Message 1 of 10
(5,171 Views)
Hi Stephen,
 
Could you post your code for me please?  I'll have a look into it for you.
 
I seem to have made this work with the following code.
(You will notice that I create an array of I16 then put that into a PNG file.)  If you look at the array before the write and after the read you will see that they match perfectly.
Is this what you see with your I16 array?
 
How have you done this?
 
Thanx
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 2 of 10
(5,154 Views)

Hey Stephen,

Any luck?

 

AdamB

Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 3 of 10
(5,141 Views)
I agree that Labview can generate a png file and then read it and get the same answer. The problem is using any other application to read that png file. Have you tried to do that?
0 Kudos
Message 4 of 10
(5,139 Views)
Hi,
Well I've opened the files in GIMP 2.2 and Pictureviewer (Microsoft).
Then Word, Publisher and finally paint.
 
They all seem fine.  Is there a setting in the other program you are using?
 
What does your code look like?
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 5 of 10
(5,134 Views)

Sure, the images may look nice when opened in any of the packages you have used, but it is the actual intensity values that I am interested in. All of the packages you have used to open the png file truncate the file to 8 bits from the original 16 bits. Using the attached program and aipd file, I generate the attached png and txt files. The txt and aipd files should have the same maximum, minimum and mean intensity values as the png file when viewed in any non-Labview package capable of viewing 16 bit files without truncation. They don't. The max, min and mean of the attached aipd and txt files are 62535, 3000, 30317, but, for example using Cinepaint, IDL or Python, they are 59535, 0, 27317 in the png.

Stephen

0 Kudos
Message 6 of 10
(5,127 Views)
Hi,
 
2 quick things for you to try:
1) In the convert to PNG vi. use the quality input and wire in the value 1000 instead of the default 750.
2) create an AIPD with the same image (but make one single pixel value 0)
What are the results when you try this?
 
Thanx
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 7 of 10
(5,121 Views)

1. Changes the min to 18000. Surely it shouldn't change?!

2. Yes, this does work (but is not a useable solution for me). It is as though the 'use bit depth?' input does not work.

0 Kudos
Message 8 of 10
(5,113 Views)
No your right it shouldn't change at all.
(there is something very wrong there.)
I am unable to actually get any of the programs you are using for trial versions.
(We don't have licenses over here)
 
What results do you see with this program?
 
I'm still relying on what is actually being sent to the PNG conversion file and it's an array of -29xxx to +29xxx which should translate as you expect.
 
We'll keep digging.
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 9 of 10
(5,109 Views)
I opened up the files inside of Photoshop (quoted that it will open up the 16 bit files) and this also translates the low values to a 0.
Is this the specs for Png?
The Photoshop program also only actually uses 15 bits of data.  So the data ranged from 0 - 29535 (or there abouts)
It all seems to point to the different programs translating the Png in different ways.
 
All I can prove from the point of view of the LabVIEW code is that the data is consistant when written and then read, and the data values must be stored in the file or LabVIEW would read the data as any of these other programs have.
 
Did you have any luck with the code?
 
Thanx
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 10 of 10
(5,068 Views)