Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Save to PNG file using IMAQ Write File Does Not Save Proper Gray Scale

Solved!
Go to solution

Hi - I have a simple VI which reads a U16 raw file and then attempts to save to IMAQ Write File PNG option (because I want the 16-bit format).

 

I define a custom color table which is just inverse gray scale, and this is applied to the image.

 

The Image displays properly but saves the PNG file with non-inverted gray scale.

 

Raw U16 file is titled 'Martha 1849-02-001-6-view0000_raw_grey_16bit.raw' and posted at ftp://ftp.ni.com/incoming.

 

How come and how do we get this to work properly?

 

Thanks,

 

Don

0 Kudos
Message 1 of 4
(4,104 Views)
Solution
Accepted by topic author DonRoth

 


@DonRoth wrote:

 

I define a custom color table which is just inverse gray scale, and this is applied to the image.

 


 

 

No! your custom color table applies to the Image Display, not to the image.

 

In additional, you can't save palette together with 16 bit image. The palette can be stored together with 8 bit "indexed" image.

 

What you can do - if you need just inversed grays, then use IMAQ Inverse to compute the negative of an image.

 

Andrey.

Message 2 of 4
(4,099 Views)

Wow!  That is really confusing.  And strange.  You should be able to save what you see on the screen!

 

Furthermore, the color palette should be able to be saved to any image type. (And there is nothing in the Help on this function that says otherwise.)

 

What is interesting also is that the IMAQ Inverse fx is not supposed to be compatible with U16, but I just tested it and it works.  So NI should update this.

 

You have to create another buffer to get both the Image display and Saved Image to display properly.   Very confusing.

 

Don

 

 

0 Kudos
Message 3 of 4
(4,098 Views)

 


@DonRoth wrote:

 

What is interesting also is that the IMAQ Inverse fx is not supposed to be compatible with U16, but I just tested it and it works.  So NI should update this.

 


 

 

Ups, I haven't check it. There are lost of VIs where I16 is supported, but U16 - not. Support for U16 was introduced since version 9, and not fully implemented yet.

 

 


@DonRoth wrote:

 

You have to create another buffer to get both the Image display and Saved Image to display properly.   Very confusing.

 


 

Yes, you need to create another buffer, because IMAQ Image passed "by reference", and not "by value". It means, if you have connect Vision display before IMAQ Inverse, then theoretically its possible that image will be displayed after inversion, so you will need additional buffer for inversion (or for display) for avoiding "race condition".

 

 

Andrey.

 

0 Kudos
Message 4 of 4
(4,094 Views)