Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Get 16-bit unsigned data from an image

I got 16-bit grayscale UNSIGNED images from IMAQ framgrabber . I am trying to get the data of the image. However, most application of LabView support 16-bit signed. I used IMAQimageToArray to convert image to data. However, if my image data is between 0-32767, the result from IMAQimageToArray is 0-32767. If my image data is between 32767 to 65535, the result from IMAQimageToArray still be 0-32767!!!!! If my image data is between 0-65535, the result will be shifted dawn to -32768 to 32767.
The problem is that when I get the result between from 0-32767, I will not be able to know that the real data is 0-32767 or 23768-65535!!!! How can I get the real image data from 16-bit unsigned grayscale image?

The program still behaves the
same with TIFF format image.
0 Kudos
Message 1 of 4
(3,866 Views)
Hello Kritsada,
I don't know if I have understood your problem correct,
but have you tried the following?

Select the Functions Palette, then "all Functions" ->
"numeric" -> "conversion". There you find a function that converts data to the unsigned 16Bit form. If you put this function behind the "IMAQimageToArray.vi", the data should be converted from I16 to U16.

I have attached a very simple example...

Peter Weber
NI Germany
0 Kudos
Message 2 of 4
(3,866 Views)
Hello Peterguy,
Thanks for your answer.
However, my problem can not be solve with those convertion functions. it is quite complicated to explain. Therefore, I have attatched 3 example images . They are 16-bit UNSIGNDED images which actually 12-bit image but shifted to the left 4 bits(to make 12-bit image to 16-bit image). Therefore , the value of the darkest pixel should be 0 , the value of the brightest pixel should be 65520( or FFF0).
The image"dark4m1.tif" is a dark image..
The image"White250m.tif" is a bright image...
The image"BlackWhite.tif" is a bright image(White250m.tif), but I change the first pixels Black and the second pixel to Gray..

After you use IMAQimageToArray.vi , you will see that....
For
"dark4m1.tif", IMAQimageToArray.vi will give the value for the darkest pixels = 0 . If you look at the HEX code of the image, you will find the darkest pixel value = 0.
For "White250m.tif" ,IMAQimageToArray.vi will give the value for the brightest pixels = 32752. If you look at the HEX code of the image, you will find the bright pixels value = FFF0 which is 65520
The range of Black to White from the HEX code is 0-65520, but the range of Black to White from IMAQImageToArray is 0-32752. !!! ?????????????????.....

Now, consider the last image.
Then ,from the HEX code of the image,you will see Black pixel = 0,Gray = 32768( HEX=8000) White = 65520 (FFF0). However, the pixel value from IMAQImageToArray.VI will be ....Black pixel = -31280, Gray =0, White = 32752 ......!!!!!! ...???????? now, IMAQimageToArray does not give Black=0 anymore....

The problem is that ..... if I get an array from IMAQimageToArray which has range from 0-3275 , How can I know that the image
is Black(0)-Gray(8000) or Gray(8000)-White(FFF0)....?


Thank you,
Kritsada
Download All
0 Kudos
Message 3 of 4
(3,866 Views)
Hi Kritsada,

your problem sounds really strange...
For Example: The "FFF0"-Value in your Bright Image should be read as -16(signed format), or 65520 in unsigned format...
But NOT 32752! (32752 is "7FF0" in Hex.)

Perhaps you can post your VI, so that I can check the files with your Code?!


Regards

Peter Weber
NI Germany
0 Kudos
Message 4 of 4
(3,866 Views)