Login  Register

Re: How to determine inverse color?

Posted by Gabriel Landini on Jan 10, 2006; 4:26pm
URL: http://imagej.273.s1.nabble.com/How-to-determine-inverse-color-tp3704104p3704110.html

On Tuesday 10 January 2006 15:19, Robert Baer wrote:
> Very interesting solution.  I tried it with your greyscale internal image
> and with the sample image mandrill (baboon.jpg).  I don't quite understand
> why in the latter case the lines persist but in the former they do not.

The problem is that on an RGB image we should get the separate RGB pixel
values, calculate the contrasted colour for each plane with the same formula:

>  putPixel(x1, y1, ((getPixel(x1, y1)+128)%256)); // new line

and then pack the RGB triplet and plot.
One advantage of this method is that it seems to be reversible too (so one
does not need to store the original colours, just re-apply the algorithm and
you've got them back).
I'll see to make it run in colour too.

> Do we need a bit-shifted RGB substitute for the following code line for
> your XOR algorhithm to work with RGB images?  (Sorry, I don't quite have
> enough insight into color representation to figure this out on my own.)

The colour representation is very simple, imagine that the lut is circular (so
255 is next to 0. For any LUT value, the "contrasted" value is 180 degrees
away from the current (i.e. each colour is 128 values to the right of it).

Cheers,

Gabriel