Re:JPG: resize, brightness, contrast ?
Quote
"Paul Claridge" <paul.clari...@{*word*269}.net> wrote in message
news:833ftl$8td9@forums.borland.com...
Quote
> Try this from Gordy @ G-SOFT - It was posted here last week.
> function ContrastLUT(Amount: Integer): array[Byte]of Byte;
...
> apply the lookup table to your bitmap bytes to adjust contrast
If I'm reading this fragment correctly, this function returns a 256-byte
lookup table that makes darker intensities (those < 127) darker, and lighter
intensities (those > 127) lighter. This lookup table should work fine for a
grayscale image with a median value around 127. But this may
or may not be appropriate for any given grayscale image. And the code
doesn't address how it might be applied to pixel data in scanlines,
or when a palette is used, or when you have a JPEG image.
What if the grayscale median were about 50? I don't think this technique
and lookup table will work so well. For a grayscale image, histogram
stretching (or histogram equalization) would work fairly well. Take a look
at the image in this Lab Report that has a median grayscale value of 49
and how it is histogram stretched from a range of 11..97 to the full-contrast
range of 0..255:
http://www.efg2.com/Lab/ImageProcessing/HistoStretchGrays.htm
You can't just apply the lookup table in the fragment, or in histogram
stretching, to each of the three RGB color planes separately and
always get good results. While this might work in some images,
it can (and does) introduce color shifts in other images.
--
efg
Earl F. Glynn E-Mail: EarlGl...@att.net
Overland Park, KS USA
efg's Computer Lab: http://www.efg2.com/Lab