[futurebasic] Re:Color. Compensation for image background

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 1999 : Group Archive : Group : All Groups

From: Robert Covington <t88@...>
Date: Wed, 13 Jan 1999 14:44:45 -0700 (MST)
>jonathan wrote:
>> the only 'quick'n'dirty' method that i see in this case would need
>> a light point and a dark point present in all images.
>> The light point would be mapped then to 255 of all values
>> the dark point to 0 of all values, and then the intermediate
>> values recalculated/spread with that range.
>
>> This would only work if you do have a 'black' spot and a 'white'
>> spot. And if one of these has uneven values (ie black = 00, 1A, 08
>> for RGB) then this could create a color cast over the rest of the image.
>
>Great minds think alike! On the way to work I was thinking that subtracting
>the adjacent background was inappropriate.  The background color may vary
>depending on the thickness of the mounting media (specimens are embedded in a
>_clear_ plastic).

Hope this isn't a repetition of something else or useless to you.

You might wish to do this before doing the above, it should take care of
any color cast.

What I would do would be to take a 3x3 or larger pixel sample of the
background, average those pixels, and see what RGB channel is not equal to
the others, or if they do not make it up to 255, say.

If it turns out that the "white" has a fairly equal spread of the three
channels, then just take the needed amount to get things to 255 and add
that to the channels of all the pixels. That should bump you up to a true
white reference all over.

Ideal white,    255,255,255

Average,from BG, 230,232,230

Add 25 to every red,blue channel,23 to the green. Set any pixel that
exceeds 255 to 255.

If one of the channels has a large predominance over the others, making for
a color cast, adding the differences to make the three channels equal
should also correct this.

You can also sample a neutral gray in the picture if there is one, and
whatever percentage difference among the channels is there would also
indicate a color cast.

This approach may have the problem of lightening your blacks though. In
that case, you could pick a center point, and only lighten any pixels
brighter than those, darken any below by whatever it takes to get a
previously black pixel back to black.


You could always throw the pictures in Graphic Converter or Photoshop and set
the levels there with "Auto" in GC or with" AutoLevels" in Photoshop. :)

If you took a simple picture, and did a before and after analysis of the
changes that Photoshop does, that might be helpful to see how things get
remapped.

I fear you might have to get involved with histograms if you need a lot of
accuracy, which it seems you do.

>Are there books on imaging algorythms?  Any titles?

A posting to comp.graphics.algorithms would be of help to you, and the FAQ
is posted there often. If you can't find it, I can send it to you.

I will send you the Colorspace FAQ I found recently, and some "Photoshop"
type layer algorithms I found also, that might help with color
transformations.

Robert Covington