[sane-devel] reverse engineering techniques
Sun, 1 Aug 2004 15:39:33 +0200
On Wed, Jul 21, 2004 at 06:26:26PM -0400, Dave Burns wrote:
> Let me try an example which someone out there might solve readily for all I
> know. I can see the parameters where other drivers control the RGB gain and
> gamma curves (at least I think they specify gamma curves).
Gain is usually one value that inluences the whole image. At least for
the scanners I know it's used the set the amplification of the analog
frontend (AFE) during calibration.
Hardware gamma curves are nor supported by every scanner.
> RGB gain is fine,
> I have the values for that figured out. But there are two other values per
> RGB channel that remain unknown to me. The first value ranges from 0-63 and
> may have something to do with a black point (but not sure of that).
Maybe offset? Think of gain as the amplification and offset as the
> values across RGB are 47, 36, 36. The second value is made up of two bytes.
> I'm not 100% sure though that it is a short int. Since the 1st byte is only
> ever a 1 or 0 and when I've graphed scanned image data with varying values,
> there's a big discontinuity in the data. Typical values that give good
> results for me are 0x119, 0x108, 0x106. But I've also see weird combinations
> like 0x115, 0x9, 0x5. These combinations were from a driver that does
> autoexposure. If it helps, I can tell what the sequence is that the driver
> goes through before settling on those values (it iterates from a known
> starting point then must derive what it thinks are the best values).
Probably exposure times. The GT68XX scanners use Exposure start and
stop times for each color. IIRC start is one byte (usually 0 or near
0), stop is 2 bytes (about 0x50 - 0x200).
> Is this some weird way of specifying a gamma curve? Not gamma-related at
> all? Demonstrating empirically what changing those values does would require
> me to assemble some histograms and posting them so I thought I'd start with
> just an email first.
While both gamma and gain/offset influence the correlation between the
"real" color of the image to the data that is actually transmitted to
the computer there are differences:
gain and offset are ususally applied in the analog part of the scanner
(between sensor and ADC). You can use them to use the whole
range of the ADC (black = 0 and white = 255). At least that's what's
done in "my" scanners.
Gamma curves are usually used after calibration is done. They are used
to compensate the non-linear behaviour of most sensors. Or just to
make images brighter or darker. Nowerdays gamma curves are often done
in siftware (the driver)