# How to use compression to change bit depth of a video signal?

on
I need to use compression to change bit depth of a video signal.

Our Focal Plane Array(FPA) is Vanadium Oxide(VOx) Resistive Microbolometers Uncooled Thermal Infrared Detector.  The output of this image sensor is 14-bit, Wide Dynamic Range(WDR), raw, monochrome, 640 x 480 resolution.  The pixels of this video signal will be processed by Image Signal Processor(ISP).  ISP input is 12-bits.  Therefore, I need to compress FPA output to 12 bits and then input into ISP.

How to perform global tone mapping using two methods, PWL and LUT (curve defined by lut) based mapping.  I need to tone map 14 bit data to 12 bit.  What does PWL stand for?  Please provide sufficient information so I can achieve this.  It's suppose to be similar to gamma compression.  I can do gamma correction in matlab.  Can this tone mapping also be done in matlab?  If yes, please provide some examples.
Comment
Watch Question

Do more with

EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
PWL means piece-wise linear, and LUT means look-up table.  There are many on-line references.

In your case, you have to come up with a function that converts a 14-bit input to a 12-bit output.

The LUT is the most flexible.  It is fast, but it takes up an enormous amount of space, 16K x 12 bit.

One common PWL technique would be logarithmic compression.  In your 14-to-12 bit case, you might choose a 9-bit mantissa and a 3-bit exponent.  This is fast to implement:
1. Calculate the exponent by counting and truncating the first 0 thru 7 leading zeroes.
2. Calculate the mantissa by taking the next nine bits, which may include some leading zeroes.

Commented:
global tone mapping can be done using Two methods as follows:
1.  PWL
2.  LUT(curve defined by lut) based mapping

I know  I have to come up with a function or algorithm.  I was told it is similar to gamma correction.  I can do gamma correction in matlab but
how I can learn to do what I need to do?

>> One common PWL technique would be logarithmic compression
I don't get it.  output of my infrared sensor is 14-bit non-negative integers.   And you are asking me to map to 12-bit floating point.  The ISP that is going to treat 12-bit binary numbers as non-negative integers.

Commented:
Log compression maps 14-bit non-negative integers to 12-bit non-negative integers.  It is computationally fast bit manipulation that trades size for resolution.  It de-emphasizes small differences between larger values and preserves small differences between small values.
Binary logs and exponents are not floating point functions.

Mantissa in bold on the left.  Exponent in bold on the right.
===============================================================================
11 1111 1110 0000   thru   11 1111 1111 1111   all map to    000 1111111   [32 values]
00 1111 1111 1000   thru   00 1111 1111 1111   all map to    010 1111111    [8 values]
00 0000 1111 1110                                                      maps to    101 0111110    [1 value]

Note that the simplest 14- to 12-bit PWL mapping is just dropping the two LSB's.

Commented:
11 1111 1110 0000(16,352)  thru  11 1111 1111 1111(16,383)  all map to 000 1111111(127)  ?

I didn't understand how mantissa and exponent operate in your example?

>> Note that the simplest 14- to 12-bit PWL mapping is just dropping the two LSB's.
The sensor manufacturer says if we drop two LSB's, Noise Equivalent Temperature Difference(NETD) will increase by a factor of 4.

Commented:
I was not suggesting that drop two bits.  That was just an example of a possible PWL algorithm.

Have you asked vendor about log compression?   They will probably tell you it's the best you can do.  These are the techniques NASA used in the Pioneer missions in the 1970's.

How are you going to implement this compression?  Microprocessors, CPLD's, or DSP's?  Parallel or serial?  What ISP are you using?  Why are you limited to 12 bits?  What are the requirements of the entire system?
Commented:
Here is an algorithm to convert a 14-bit positive integer to 12-bit log with a 2-bit exponent and 10-bit mantissa.

``````Input = [ B13, B12, B11, ... B2, B1, B0]   MSB to LSB

If B13 = 1   then   EXP = 11   and   MANT = [B13, B12, B11, ... B6, B5, B4]
else
If B12 = 1   then   EXP = 10   and   MANT = [B12, B12, B10, ... B5, B4, B3]
else
If B11 = 1   then   EXP = 01   and   MANT = [B11, B10, B9, ... B4, B3, B2]
else   EXP = 00   and   MANT = [B10,  B9, B8, ... B3, B2, B1]
``````
Note that you never get to see the LSB in this representation.  You might decide you need to opt for a 3-bit exponent and a 9-bit mantissa.
This would add one more test level to the algorithm, and you would only use five of the eight available exponents.

Commented:
Expert continuously answered follow-up questions.  Great responses.