Board index » delphi » HOW TO CONTROL BRIGHT AND CONTRAST IN BITMAPS ?

HOW TO CONTROL BRIGHT AND CONTRAST IN BITMAPS ?

Hi, anybody have a component to modify the bright and/or the contrast into a
bitmap image ?
I will appreciate any info.

Thanks in advance, GAL.

 

Re:HOW TO CONTROL BRIGHT AND CONTRAST IN BITMAPS ?


I posted a same porcedures in delphi tip section on my site. Try to read a
tip#56 ("to play with colors")

--
With best regards, Mike Shkolnik.
E-Mail: mshkol...@scalabium.com
        mshkol...@yahoo.com
WEB: http://www.scalabium.com
          http://www.geocities.com/mshkolnik

Locatelli Gabriel D??? ???Y?? <8t6fjf$b...@bornews.borland.com> ...

Quote
>Hi, anybody have a component to modify the bright and/or the contrast into
a
>bitmap image ?
>I will appreciate any info.

>Thanks in advance, GAL.

Re:HOW TO CONTROL BRIGHT AND CONTRAST IN BITMAPS ?


Quote
"Locatelli Gabriel" <g...@amc.com.ar> wrote in message news:8t6fjf$bkp3@bornews.borland.com...
> Hi, anybody have a component to modify the bright and/or the contrast into a
> bitmap image ?

Are you working with color or gray scale images?
Also, the exact answer depends on the PixelFormat of your bitmap.  Working with pf24bit bitmaps is
fairly easy since each pixel contains complete color information.  In pf8bit bitmaps, you may want
to manipulate the palette table instead of the Scanlines that have the "pixel" data.

For brightness changes, you can just add a constant to each of the (R,G,B) components.  You can
shift the brightness by changing each pixel to (R+delta, G+delta, B+delta), where the ceiling of
each value is 255 and the floor is 0(if delta is negative).   For an example of this (and some other
brightness info), look under "Brightness" on this page:
http://www.efg2.com/Lab/Library/Delphi/Graphics/ImageProcessing.htm

 If you know about histograms this has the effect of shifting the whole histogram left or right but
does not change the shape of the histogram (except for some endpoint edge effects).

For info about histograms, see
http://www.efg2.com/Lab/Graphics/Colors/ShowImage.htm
Contrast is really an issue of changing where the minimum and maximum pixel values are.  For
gray-scale image, see the Histostretch Grays Lab Report:
http://www.efg2.com/Lab/ImageProcessing/HistoStretchGrays.htm
With a contrast enhancement you want to stretch the histogram of the brighness component to span the
largest possible range.

Color contrast changes are a bit tricky -- I've never got around to getting an example of that on my
site.  You need to convert RGB to another color space, like HSL (Hue-Saturation-Lightness).  You
keep the Hue and Saturation constant and histostretch the Lightness values to span as much as the
0..255 range as possible.  With this modified Lightness value, L', you convert HSL' back to R'G'B'
to get a contrast enhanced image.

If you know Italian, there's a different approach on this page:
http://digilander.iol.it/gensavas/francosava/grafica/docs/c_grafica7/...
ne.htm
(Even if you don't know Italian -- I don't --, you can probably still figure out the code fragments
shown there.)

--
efg

Earl F. Glynn     E-mail:  e...@efg2.com
Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

Re:HOW TO CONTROL BRIGHT AND CONTRAST IN BITMAPS ?


On Wed, 25 Oct 2000 08:29:06 -0300, "Locatelli Gabriel"

Quote
<g...@amc.com.ar> wrote:
>Hi, anybody have a component to modify the bright and/or the contrast into a
>bitmap image ?
>I will appreciate any info.

Using this aproach i got some values that where (at least next to,
long time since i did the test) identical to Paint Shop Pro's values,
so i guess it cant be all wrong
    half:= 128; // in case of 24bit color (0..255)
    red_out:= (red_in - half) * factor + half;

of cource clamp it to the given range

Like i said, its based on what i learned from TV's and i cant say it's
even half right, but its easy and the values added up so :)

- Asbj?rn

Re:HOW TO CONTROL BRIGHT AND CONTRAST IN BITMAPS ?


Thanks a lot !
 But , yes, I'm working with 24 and 32 color bitmaps captured from a camera.
Exist a component to do the work or only exist procedures ????

Best regards.

Other Threads