Re: How to determine inverse color?
Posted by Robert Dougherty on Jan 07, 2006; 7:12pm
URL: http://imagej.273.s1.nabble.com/How-to-determine-inverse-color-tp3704104p3704111.html
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;
I haven't actually tested it....
Bob
Robert P. Dougherty, Ph.D.
President, OptiNav, Inc.
Phone (425) 467-1118
Fax (425) 467-1119
www.optinav.com