Re: How to determine inverse color?

Posted by Robert Dougherty on
URL: http://imagej.273.s1.nabble.com/How-to-determine-inverse-color-tp3704104p3704106.html

Jeff,

As you suggest, the algorithm for maximum luminance contrast for one
background color would be to compute the luminance of the background from
something like Y = 0.299R + 0.587G + 0.114B and choose white if Y < 128 or
black otherwise.

Bob
 

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jeff
> Brandenburg
> Sent: Tuesday, January 10, 2006 7:20 AM
> To: [hidden email]
> Subject: Re: How to determine inverse color?
>
> On Jan 7, 2006, at 2:12 PM, Robert Dougherty wrote:
> > If the problem is to maximize the contrast, and the contrast is
> > defined as
> > the Euclidean distance between the background color and the new color
> > in RGB
> > space, then there is a unique solution: choose the farthest corner of
> > the
> > RGB cube from the background color.  Let the background color be (rIn,
> > gIn,
> > bIn), and compute the new color, (rOut, gOut, bOut) according to
> >
> > int rOut = 0;
> > int gOut = 0;
> > int bOut = 0;
> > if(rIn < 128) rOut = 255;
> > if(gIn < 128) gOut = 255;
> > if(bIn < 128) bOut = 255;
>
> While this optimizes per-color contrast, it doesn't optimize luminance
> contrast, and luminance contrast is what makes fine detail (like
> markers) visible.  For example, on a green (r0gFFb0) background, either
> black or white would be more legible than cyan (rFFg0bFF).
>
> I faced a similar problem for captioning grayscale movies, and the
> solution I adopted was shadowed or beveled text.  This provided
> contrast against black, white, and anything in between, because each
> letter feature was portrayed by both light and dark levels.  This could
> still fail if the background image had texture similar to that of the
> caption letters; the obvious worst case is captioning a background
> image that consists entirely of caption letters. :-)
>
> Filip, can you use markers that include texture, instead of a single
> color -- perhaps something as simple as a white dot in a black ring?
> Is your background image amenable to this sort of treatment?
> --
> -jeffB (Jeff Brandenburg, Duke Center for In-Vivo Microscopy)