Posted by
Stephan Saalfeld on
May 13, 2010; 7:24pm
URL: http://imagej.273.s1.nabble.com/RGB-to-CMYK-tp3688100p3688103.html
In the trivial case, that is when the intensity value stored for each
color channel is linear, grey is ( red + green + blue ) / 3 and no color
profiles are in the way, the conversion is quite easy. Let r, g and b
be red, green and blue in unsigned byte range [0...255] and calculate c,
m, y and k as floating point in range [0...1]:
c = 1.0 - r/255.0
m = 1.0 - g/255.0
y = 1.0 - b/255.0
That's CMY from which CMYK is derived by extracting the grey component
into a fourth channel and scaling the remaining color channels
respectively:
k = min( c, y, k )
if ( k == 1.0 )
c = m = y = 0
else
s = 1.0 - k
c = ( c - k ) / s
m = ( m - k ) / s
y = ( y - k ) / s
For the application, you have in mind, I do not think that conversion
into CMYK is of any help. It does not add any information to your data.
Better look at Gabriel Landini's Colour Deconvolution plugin and
directly estimate the percentage of the colors you're looking for:
http://www.dentistry.bham.ac.uk/landinig/software/cdeconv/cdeconv.htmlBest,
Stephan
On Thu, 2010-05-13 at 06:44 -0700, Kateo wrote:
> HI Duane,
> I was wondering if you could expand on how to convert RGB--> CMYK. I have no
> clue about these things, but I found a paper that before analyzing the
> colours in histological sections performed colour separation into CMYK
> before dertermining the % of colours in their section. I want to determine
> the % of orange/red vs. green colour in my sections stained with picrosirius
> red and viewed under a polarized microscope. Anyway, I would appreciate your
> guidance... or anyone else's!
> Thanks,
>
> Kate