We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › How do I covert from RGB to CMY ?
Page Index Toggle Pages: 1
How do I covert from RGB to CMY ?? (Read 1068 times)
How do I covert from RGB to CMY ??
Aug 12th, 2009, 11:13pm
 
Hi there,

How do I covert from RGB to CMY ?
I googled and found the following description:

----------------

Step 0: Normalize R,G, and B values to fit into range [0.0 ... 1.0], or
adapt the following matrix.

Step 1: RGB to CMY

| C | | 1 | | R |
| M | = | 1 | - | G |
| Y | | 1 | | B |

------------------------------

Could somebody please help me with the actual Processing code?

Thanks so much,
Christian
Re: How do I covert from RGB to CMY ??
Reply #1 - Aug 13th, 2009, 12:55am
 
There also seems to be another step to this process from the website

Step 2: CMY to CMYK

| C' | | C | | min(C,M,Y) |
| M' | | M | | min(C,M,Y) |
| Y' | = | Y | - | min(C,M,Y) |
| K' | | min(C,M,Y) | | 0 |

Easier to calculate if K' is calculated first, because K' = min(C,M,Y):

| C' | | C | | K' |
| M' | | M | | K' |
| Y' | = | Y | - | K' |
| K' | | K'| | 0 |

----------------------

Again is somebody could help me turn this in to processing code that would be brilliant
thanks,
Christian
Re: How do I covert from RGB to CMY ??
Reply #2 - Aug 13th, 2009, 2:28am
 
Have you already looked at this  Seems fairly comprehensive and it should be easy enough to apply in Processing...
Re: How do I covert from RGB to CMY ??
Reply #3 - Aug 14th, 2009, 1:52am
 
I am using this bit of code.


void colourConnversion()  
 {
  //load a file with all cmyk colour values

   colour_lines = loadStrings("AllColourValues.txt");    
   float[] cyanValue = new float[colour_lines.length];
   float[] magentaValue = new float[colour_lines.length];
   float[] yellowValue = new float[colour_lines.length];
   float[] blackValue = new float[colour_lines.length];

   float[] c = new float[colour_lines.length];
   float[] m = new float[colour_lines.length];
   float[] y = new float[colour_lines.length];

   r = new float[colour_lines.length];
   g = new float[colour_lines.length];
   b = new float[colour_lines.length];

   String[] currentLine;
   colorChars =  new float[colour_lines.length];

   for ( int i = 0 ; i < colour_lines.length ; i++ )
   {
     currentLine = split(colour_lines[i], ",");
     cyanValue[i] = Float.parseFloat(currentLine[0]);
     magentaValue[i] = Float.parseFloat(currentLine[1]);
     yellowValue[i] = Float.parseFloat(currentLine[2]);
     blackValue[i] = Float.parseFloat(currentLine[3]);

     //convert the values from the file into rgb colours

     //CMYK -> CMY   //CMYK values = From 0 to 1
     c[i] =  (cyanValue[i] * (1 - blackValue[i]) + blackValue[i]);
     m[i] = (magentaValue[i] * (1 - blackValue[i]) + blackValue[i]);
     y[i] = (yellowValue[i] * (1 - blackValue[i]) + blackValue [i]);

     //CMY -> RGB  //CMY values = From 0 to 1
     r[i] = (( 1 - (c[i] / 100)) * 255) ;
     g[i] = (( 1 - (m[i]  / 100)) * 255);
     b[i] = (( 1 - (y[i] / 100)) * 255);
   }
 }
Page Index Toggle Pages: 1