[comp.graphics] Color enhancement ?

dan@rna.UUCP (Dan Ts'o) (10/08/88)

	Are there well-known (hopefully simple) algorithms for enhancing
colors of an RGB image ? If one has a color image whose colors looked
"washed out", how can they be improved ?
	Simplistically, it seems one would want to improve the saturation
without adjusting the hue or color balance. Is that the idea ? That idea
to seem to reduce to removing white while maintaining the color ratios.
Also, is there such a thing as color compression -- to try to capture a
wide dynamic range of colors in a small representation space without the
spatial degeneration involved in dithering.
	Please email replies. Thanks.

				Cheers,
				Dan Ts'o		212-570-7671
				Dept. Neurobiology	dan@rna.rockefeller.edu
				Rockefeller Univ.	...cmcl2!rna!dan
				1230 York Ave.		rna!dan@nyu.arpa
				NY, NY 10021		tso@rockefeller.arpa
							tso@rockvax.bitnet

david@epicb.UUCP (David P. Cook) (10/10/88)

In article <281@rna.UUCP> dan@rna.UUCP (Dan Ts'o) writes:
>
>	Are there well-known (hopefully simple) algorithms for enhancing
>colors of an RGB image ? If one has a color image whose colors looked
>"washed out", how can they be improved ?
>	Simplistically, it seems one would want to improve the saturation
>without adjusting the hue or color balance. Is that the idea ? That idea
>to seem to reduce to removing white while maintaining the color ratios.
>Also, is there such a thing as color compression -- to try to capture a
>wide dynamic range of colors in a small representation space without the
>spatial degeneration involved in dithering.

A very simple method using histograms... simply stretches the image... here are
the steps:

    [1]  Scan the image looking for the MINIMUM and MAXIMUM grey value.  This
	 is defined as the MIN(R,G,B) and the MAX(R,G,B) for the entire image.

	 These represent the 'darkest' and 'lightest' colors.  Now, these need
	 to be spread out.

    [2]  To spread out the values 'ie.. bringing them into proper contrast', you
	 simply execute the following:

	       value = 256 / (MAX - MIN)      <-- 256 = Total # greys possible

	       New_Red    = (Red - MIN) * value
	       New_Green  = (Green - MIN) * value
	       New_Blue   = (Blue - MIN) * value

    [3]  Pictorially....

	 Image with BAD contrast has the following 'histogram':

	  N  |             X
	     |             X
	     |             X             X
  Frequency  |             X             X    X
	     |             X        X    X    X
	     |         X   X        X    X    X
	     |         X   X  X     X    X    X
	  0  |-----------------------------------------------------
	     0            Grey Value Histogram                   255

	 Image with PROPER STRETCHED contrast has the following 'histogram':

	  N  |          X
	     |          X
	     |          X                               X
  Frequency  |          X                               X         X
	     |          X                    X          X         X
	     |X         X                    X          X         X
	     |X         X        X           X          X         X
	  0  |-----------------------------------------------------
	     0            Grey Value Histogram                   255

	     Note that new colors/greys are not added, but are simply 
	     "stretched".  This takes a 'bad contrast' image and makes
	     it good.  The only problem with this is that if the original
	     image has MIN and MAX of 0 and 255 then no stretch can occur,
	     but in these cases you can lighten the bottom end and then
	     stretch the entire image.


	     If still confused, email me at:::   uunet!epicb!david
-- 
         | David P. Cook            Net:  uunet!epicb!david        |
         | Truevision Inc.  |   "Sometimes I cover my mouth with   |
         | Indianapolis, IN |    my hand to tell if I'm breathing" |
         -----------------------------------------------------------