LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert U32 matrix to 8 bit grayscale image?

Solved!
Go to solution

Good day to all,

 

I obtained an array of 512*512 U32 data from the photomultiplier using the analog input of DAQ board. My question is how to convert this 32-bit matrix to 8 bit monochrome image for display. 

I tried the method in this post to convert array to grayscale image https://decibel.ni.com/content/docs/DOC-4155 but the result looks like a contour rather than real image. I guess it is because their input to Flatten Pixmap is 8 bit, but mine is 32 bit. Do I need to do gamma correction to scale my data? But how?

 

I attached the original image, which is a particle.I also attached my labview code and the processed image.  Thanks!

 

 

0 Kudos
Message 1 of 11
(6,049 Views)

Try the Draw Unflattened Pixmap VI.

Nevermind, I misunderstood your question. I think there must be something wrong with you color table that you made. The conversion isn't exactly what you were expecting. Maybe play around with that table generation?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 11
(6,035 Views)

Thanks James. Yes, the Draw Unflattened Pixmap gives a color image, but still looks like contour.

 

I input the data in Matlab, I found that the function mat2gray can realize my function (see the pic), but I don't know how to get the same result in Labview.

 

Could you explain a little more about the color table?

0 Kudos
Message 3 of 11
(6,005 Views)

Is this not just the result of integer overflow when labview coerces the 32-bit matrix to 8bits? Have you tried dividing all the elements by 2^(32-8) to scale all your values down to 8 bits? (or any other method of scaling your data down to the 0-255 range)

0 Kudos
Message 4 of 11
(5,973 Views)

Where is your original image data?

0 Kudos
Message 5 of 11
(5,956 Views)

Hi, here is my original data, in .txt format.

0 Kudos
Message 6 of 11
(5,935 Views)

Thanks! The problem is indeed caused by overflow of data through convertion. However, in this typical example my data ranges from 

4294963840 to

4293967276

If I divide all the data by 2^(32-8), the whole matrix becomes 255, showing a total white image.

 

 

 

0 Kudos
Message 7 of 11
(5,915 Views)
Solution
Accepted by topic author xfeng89

Then you'll probably need to do you own custom conversion then that increases the difference between the brightest and the darkest.You could just make 4294963840 the zero and 4293967276 the max and scale down to 0-255

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 8 of 11
(5,909 Views)
Solution
Accepted by topic author xfeng89

Simple scaling for maximum contrast.

 

DynamicRange.png

 

DynamicRangeExample.png

Message 9 of 11
(5,878 Views)

Elegant!

0 Kudos
Message 10 of 11
(5,864 Views)