LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

16 bit tiff to 12 bit conversion

I need a algorithm to convert 16-bit tiff files with pixel values ranging from -32768 to 32768 to 12-bit values ranging from 0 to 4095. The algorithm provided by NI (http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/10560a596bddd342862566c70062a743?OpenDocument) doing a 16->8 bit conversion seems not to work if the brightness values are negative [-32768..0[. Is any help out there ???
0 Kudos
Message 1 of 4
(4,634 Views)
The example maps -32768 to 32768 to 0 to 255 this needs to corrospond to the gray scale map that is used to view the image. I have attached a modified version that will shift the lower 12 bits up within a 16 bit tiff or remapps the range to -2048 to 2047 and shifts up to the MSB of the 16 bit word.
Stu
Stu
Message 2 of 4
(4,634 Views)
Hi,

1) Convert the number to I32,
2) Add a (I32 constand with value) 32768 to it.

The result is a 16 bit positive number, ranging from 0 to 65535.

3) Use 'Rotate Right With Carry' (Carry = FALSE) on the result.

We have a 15 bit integer.

4) repeat 3) , 14 bits result
5) repeat 3) , 13 bits result
6) repeat 3) , 12 bits result, ranging from 0 to 4095 !

Offcause you can make a for loop repeating step 3) fout times, but don't
forget to put the result in a shift register!

This is, Btw. a very crude way of color reduction...

Regards,

Wiebe.


"mino" wrote in message
news:5065000000080000001E4C0000-1021771306000@exchange.ni.com...
> I need a algorithm to convert 16-bit tiff files with pixel values
> ranging from -32768 to 32768 to 12-bit valu
es ranging from 0 to 4095.
> The algorithm provided by NI
>
(http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/10
560a596bddd342862566c70062a743?OpenDocument)
> doing a 16->8 bit conversion seems not to work if the brightness
> values are negative [-32768..0[. Is any help out there ???
0 Kudos
Message 3 of 4
(4,634 Views)
Hi,

1) Convert the number to I32,
2) Add a (I32 constand with value) 32768 to it.

The result is a 16 bit positive number, ranging from 0 to 65535.

3) Use 'Rotate Right With Carry' (Carry = FALSE) on the result.

We have a 15 bit integer.

4) repeat 3) , 14 bits result
5) repeat 3) , 13 bits result
6) repeat 3) , 12 bits result, ranging from 0 to 4095 !

Offcause you can make a for loop repeating step 3) fout times, but don't
forget to put the result in a shift register!

This is, Btw. a very crude way of color reduction...

Regards,

Wiebe.


"mino" wrote in message
news:5065000000080000001E4C0000-1021771306000@exchange.ni.com...
> I need a algorithm to convert 16-bit tiff files with pixel values
> ranging from -32768 to 32768 to 12-bit valu
es ranging from 0 to 4095.
> The algorithm provided by NI
>
(http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/10
560a596bddd342862566c70062a743?OpenDocument)
> doing a 16->8 bit conversion seems not to work if the brightness
> values are negative [-32768..0[. Is any help out there ???
0 Kudos
Message 4 of 4
(4,634 Views)