07-02-2008, 10:36
|
Adam Boulad

Joined on 09-16-2007
Posts 513
|
|
|
Andi, It seems your data is already in the correct bit positions (13 bits from 0 to 12), but your problem is with the sign bit. If that's the case, one easy solution that will solve it for both positive and negative pixel values is the following: 1. Put the bits in a signed 16-bit integer. 2. Shift it left by 3 bits. 3. Perform integer division by 8. This will shift right by 3 bits, and also perform sign extension so the high 3 bits will be all 1 for negative numbers, and all 0 for non-negative numbers.
To make it general, the same steps become: 1. Calculate N1 = (15 - High Bit location), and N2 = (Low Bit) 2. Put the bits in a signed 16-bit integer. 3. Shift left by N1 bits. 4. Divide by (2 to the power (N1+N2))
Adam Boulad LEADTOOLS Technical Support
|
|
|
|
|
Report
|
|
|
|