开发者

Accuracy with calculations on images scanned with TWAIN

I'm using the TWAIN libraries to scan a greyscale image. I then programmatically adjust each pixel in the scanned image to have different white and black endpoints. So pixels with a colour value of less than the blackpoint are clamped to the blackpoint. And pixels with a colour value of greater than the whitepoint are clamped to the whitepoint. Also, all pixels that are inbetween are extrapolated.

My problem is that I'm losing quality in the calculation because the scanned image I'm doing the calculation on is only 8bits per colour channel.

I either need some way of acquiring the image with a higher number of bits per colour channel, or I need to tell the scanner to do this calculation for me.

I know that the Epson control panel allows you to specify black and white end points and do this calculation, and it looks like it's not having the accuracy issues. So I wonder if it's doing something specific to the Epson hardware. Unfortunately my software needs to use generic printe开发者_开发百科rs.

Does anyone know a way around this problem?


Some models of TWAIN scanner - mostly they are flatbeds - can deliver data deeper than 8 bits/channel.

Your code needs to set the transfer mechanism (ICAP_XFERMECH) to memory (TWSX_MEMORY), set the pixel type (ICAP_PIXELTYPE) to TWPT_GRAY, then see if you can set ICAP_BITDEPTH to 16.

If that succeeds, you can then do a memory (AKA buffered) image transfer, and get 16-bit/channel data. I expect you'll find that the data is in the 10-12 upper bits (i.e. the sample range is 0..65535) and the low bits are noise.

You can't use native transfer mode (TWSX_NATIVE) because the native image formats (DIB and PICT) don't support 16-bit/channel data. You might be able to use file transfer mode with a file format that supports 16-bit/channel data, like TIFF or JFIF: You'd just have to experiment with the scanner.

I just did this with an Epson Perfection V100 Photo I have on my desk, I'm sure other Epsons support this, maybe all the Perfection series. See: Twister Report archive

And yes, the reason this works well with 8-bit scans when you do contrast adjustments in the scanner's UI is that the scanner is adjusting the contrast by tweaking the gain in an amplifier - so working in the analog domain. (Effectively, infinite bits/channel ;-)

You could exploit that circuitry: Most flatbeds will let you set ICAP_SHADOW, ICAP_HIGHLIGHT and ICAP_CONTRAST - which has the same effect as setting the black level, white level and contrast in the scanner UI. Then you'd be adjusting the analog signal, and you'll get dense 8-bit histograms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜