
Software Photoshop, Lightroom, Paintshop Pro, Painter, etc., and all their various plugins. Of course, you can also discuss all other programs, as well. 
 Thread Tools 
#81
 
 
just to show my ignorance on all this, psp doesnt allow working in cmyk, so, i'm guessing from your line "SupportedModes: CMYKMODE" that this code wouldnt work in psp. true? craig 
#82
 
 
I'm mostly back but not quite. When dealing with CMYK, things are a bit different. For one, CMYK is subtractive for print as oppossed to additive for monitors. Then there is the CMY <> K paradigm. Even though K is a channel, it's not a true channel. Then there is the gamut and ICC thing, which I'm not very fluent with. I'm not sure how well PS and FM will get along when doing CMYK with FM. Right now I can't say that I recommend using FM for CMYK if print is your thing. I honestly don't know. Code: %ffp supportedmodes: cmykmode ForEveryTile:{ int x,y,k; for (y=y_start; y<y_end; y++){ //if(updateProgress(y,y_end)) abort(); for (x=x_start; x<x_end; x++){ // grab k k=src(x,y,3); pset(x,y,0,255); pset(x,y,1,255); pset(x,y,2,255); pset(x,y,3,k); }}// x, y return true; } // for every tile 
#83
 
 
I was thinking more of converting RGB to CMYK to adjust colours (skin is easier in percentage terms) and the convert back to RGB. Or am I wasting my time? I wrote this but I can’t get it working. It does something but the channels are very dark? I’m not sure what the problem is? If its my code then I can’t see my error. I’ve found the same formulas at several different sources so they should be OK. I also tried float but got ‘not yet implemented errors’ Ken. Code: %ffp Title :"RGB to CMYK" Author :"CameraKen" Dialog :"RGB to CMYK" supportedmodes:RGBMode ForEveryTile:{ int Red,Green,Blue,Cyan,Magenta,Yellow,Black,rv,gv,bv; for (y=y_start; y<y_end; y++){ if(updateProgress(y,y_end)) abort(); for (x=x_start; x<x_end; x++){ //Get to a range of 0 to 1 (Normalise) rv=(src(x,y,0)/255*100); gv=(src(x,y,1)/255*100); bv=(src(x,y,2)/255*100); // convert to CMY Black=min(1rv,1gv,1bv); Cyan=(1rvBlack)/(1Black); Magenta=(1gvBlack)/(1Black); Yellow=(1bvBlack)/(1Black); //Convert CMYK back to RGB //Red=1min(1,Cyan*(1Black)+Black); //Green=1min(1,Magenta*(1Black)+Black); //Blue=1min(1,Yellow*(1Black)+Black); //CMY have values 0 to 1 so multiply by 255 pset(x,y,0,Cyan*255 ); pset(x,y,1,Magenta*255 ); pset(x,y,2,Yellow*255 ); }} return true; } 
#84
 
 
You got your ranges messed up a little bit. Might as well stick with range 0 to 255. Code: %ffp Title :"RGB to CMYK" Author :"CameraKen" Dialog :"RGB to CMYK" ctl(0):standard,"Cyan",range=(255,255),val=0,track ctl(1):standard,"Magenta",range=(255,255),val=0,track ctl(2):standard,"Yellow",range=(255,255),val=0,track supportedmodes:RGBMode ForEveryTile:{ int Red,Green,Blue,Cyan,Magenta,Yellow,Black; for (y=y_start; y<y_end; y++){ //if(updateProgress(y,y_end)) abort(); for (x=x_start; x<x_end; x++){ //Get to a range of 0 to 1 (Normalise) Red=src(x,y,0); Green=src(x,y,1); Blue=src(x,y,2); // convert to CMY Cyan=255Red; Magenta=255Green; Yellow=255Blue; // not going to bother with Black // might be +=Black ??? /** Black=min(Cyan,min(Magenta,Yellow)); Cyan=Black; Magenta=Black; Yellow=Black; **/ // modify Cyan+=ctl(0); Magenta+=ctl(1); Yellow+=ctl(2); // back to RGB Red=255Cyan; Green=255Magenta; Blue=255Yellow; //Convert CMYK back to RGB //Red=1min(1,Cyan*(1Black)+Black); //Green=1min(1,Magenta*(1Black)+Black); //Blue=1min(1,Yellow*(1Black)+Black); //CMY have values 0 to 1 so multiply by 255 pset(x,y,0,Red); pset(x,y,1,Green); pset(x,y,2,Blue); }} return true; } 
#85
 
 
Thanks Stroker. I searched for ages to get a RGB to CMYK conversion. I tried + and – black and +=Black seemed closest although it’s not the same as PS. Adjusting skin tones in CMYK is easier than RGB because you can work in percentages. An average Caucasian should be around C15%17%; M32%38%; Y53%55%; K0% (ignore the black as it doesn't contribute to colour) In RGB the Black content is included in the RGB values and makes the correction more difficult (as my graphs showed) Maybe there is an easy way by using Hue/Sat (with Lum removed) as well. But the only way I know is CMY. I understand that many now use LAB .”normal" skin B would usually be 5 to 10 points higher than A. Which is another method I will look at. Ken. 
#86
 
 
I did some messing around and I'm pretty sure I understand the process. Here is the code to translate one percentage to another percentage. F in the controls means From, and T means To. Cyan F = 20 Cyan T = 25 That means take cyan of 20% and make it 25%. The rest will follow. (This is actually very similiar to my Colour2Colour filter.) * You will have to pardon the percentages being in the range of 0 to 100 instead of 0 to 1. Going to 100 is a simple way of hacking out some of the calculations. One thing to watch out for is K/black. The formula used is very crude compared to what Photoshop does. I don't know how much of a difference this will make to some of you folks, but seems okay to me because I don't do this kind of thing. If you understand what's going on, you may want to eventually do it straightup RGB. After all, the simple formulas used in the code are nothing more than simple inversions. Or not depending on what you are comfortable with. Clean up it, add features, package it, make lots of money, and sent me 10%. Code: %ffp ctl(0):standard,"Cyan F",range=(0,100),val=15,track ctl(1):standard,"Magenta F",range=(0,100),val=30,track ctl(2):standard,"Yellow F",range=(0,100),val=50,track ctl(3):standard,"Cyan T",range=(0,100),val=15,track ctl(4):standard,"Magenta T",range=(0,100),val=30,track ctl(5):standard,"Yellow T",range=(0,100),val=50,track supportedmodes: rgbmode ForEveryTile:{ int x,y,red,green,blue,range; int black,cyan,magenta,yellow; for (y=y_start; y<y_end; y++){ //if(updateProgress(y,y_end)) abort(); for (x=x_start; x<x_end; x++){ // grab values cyan=255src(x,y,0); magenta=255src(x,y,1); yellow=255src(x,y,2); // get k or black black=min(cyan,min(magenta,yellow)); // subtract black // range 0 to 255 > range 0 to 100 cyan=(cyanblack)/2.55; magenta=(magentablack)/2.55; yellow=(yellowblack)/2.55; // no need for this //range=255black; // scale cyan if(cyan<=ctl(0)){ cyan=scl(cyan,0,ctl(0),0,ctl(3)); } else { cyan=scl(cyan,ctl(0),100,ctl(3),100); } // scale magenta if(magenta<=ctl(1)){ magenta=scl(magenta,0,ctl(1),0,ctl(4)); } else { magenta=scl(magenta,ctl(1),100,ctl(4),100); } // scale yellow if(yellow<=ctl(2)){ yellow=scl(yellow,0,ctl(2),0,ctl(5)); } else { yellow=scl(yellow,ctl(2),100,ctl(5),100); } // back to rgb // range 0 to 100 > range 0 to 255 // order of operations, so it's fine red=255cyan*2.55black; green=255magenta*2.55black; blue=255yellow*2.55black; // output pset(x,y,0,red); pset(x,y,1,green); pset(x,y,2,blue); }}// x, y return true; } // for every tile 
#87
 
 
Thanks for the code Stroker. However I am beginning to question this conversion code. I just loaded a picture with skin of C18%, M56% Y72%. Yellow and Magenta work fine but Cyan did not. I am beginning to suspect the conversion. FM has two built in functions rgb2cmyk cmyk2rgb Harald Heim has given us the internal code of these half way down this page http://groups.yahoo.com/group/FMML/message/3220 Code: static int fm_rgb2cmyk(int r, int g, int b, int z) { int k; int bitMultiply= (bitDepthMode == 16 ? 128 : 1); k=255*bitMultiplymax(r,max(g,b)); if (z == 0) return 255*bitMultiplyrk; else if (z == 1) return 255*bitMultiplygk; else if (z == 2) return 255*bitMultiplybk; else if (z == 3) return k; else return 0; } static int fm_cmyk2rgb(int c, int m, int y, int k, int z) { int bitMultiply= (bitDepthMode == 16 ? 128 : 1); if (z == 0) return 255*bitMultiplyck; else if (z == 1) return 255*bitMultiplymk; else if (z == 2) return 255*bitMultiplyyk; else return 0; If we get RGB to CMYK working then my next project will be a RGBCMYK mono channel mixer. This would be useful for PS users and especially PSP users who do not have access to CMYK. Quote:
Ken 
#88
 
 
Harald's rgb2cmyk and cmyk2rgb internal code use the exact same method that we've been using. Written differently, but still the same. I messed with the functions and had no problem with k. Hmmm. One interesting difference: Code: int bitMultiply= (bitDepthMode == 16 ? 128 : 1); The cyan problem you are running into is a logic bomb related to the conversion (you are right). Our code is no where near as sophisticated as Photoshop. Our simpleness has spawned ugly. Can you find it? Can you hack it? * There is another logic bomb in there. Consider: CMY are percentages, but a percentages of what? Logic bombs are the good stuffs of programming. Last edited by Stroker; 04162006 at 01:06 PM. 
#89
 
 
I started my Channel Mixer which demonstrates the problem better. The Cyan slider does virtually nothing. The Magenta and Yellows sliders do something but because CMYK is subtractive it seems to be taking away rather than adding. However invert these and we are back to RGB. So the whole point of doing this is lost. The main problem seems to be that some RGB has to be present to see the effect of the CMY sliders. I read in the usergroup that RGB>LAB>CMYK may be better that RGB>CMYK There is something very wrong here? We need a new formula. I very often drag a CMYK layer to a RGB layer. So it is possible to display CMYK in RGB space. Percentages of What? Good question. Never thought about that. R128, G128, B128 = C52%, M43%, Y43%, K8% So adding black back would make them all 50%ish. That sounds OK. R255, G255, B255 = C0%, M0%, Y0%, K0% R0, G0, B0 = C75%, M68%, Y67%, K90%. Hmmm I see what you mean. The above figures are taken with the eyedropper in PS. The figures from this online conversion tool make more sense http://www.forret.com/tools/color.asp?R=128&G=128&B=128 Ken Code: %ffp Title :"RGB and CMYK Channel Mixer" ctl(0):standard,"Red",range=(0,100),val=30,track ctl(1):standard,"Green",range=(0,100),val=59,track ctl(2):standard,"Blue",range=(0,100),val=11,track ctl(3):standard,"Cyan",range=(0,100),val=0,track ctl(4):standard,"Magenta",range=(0,100),val=0,track ctl(5):standard,"Yellow",range=(0,100),val=0,track ctl(6):standard,"Black",range=(0,100),val=0,track supportedmodes: rgbmode ForEveryTile:{ int x,y,red,green,blue,range; int black,cyan,magenta,yellow; int out; for (y=y_start; y<y_end; y++){ if(updateProgress(y,y_end)) abort(); for (x=x_start; x<x_end; x++){ // grab values red=src(x,y,0); green=src(x,y,1); blue=src(x,y,2); cyan=255src(x,y,0); magenta=255src(x,y,1); yellow=255src(x,y,2); // get k or black black=min(cyan,min(magenta,yellow)); // subtract black // range 0 to 255 > range 0 to 100 cyan=(cyanblack)/2.55; magenta=(magentablack)/2.55; yellow=(yellowblack)/2.55; // Scale values out=(red*ctl(0)/100)+(green*ctl(1)/100)+(blue*ctl(2)/100); out=out+(cyan*ctl(3)/100)+(magenta*ctl(4)/100)+(yellow*ctl(5)/100); out=out+(black*ctl(6)/100); // output pset(x,y,0,out); pset(x,y,1,out); pset(x,y,2,out); }}// x, y return true; } // for every tile 
#90
 
 
The conversion code we are using IS wrong. Its intended to show how RGB may look when Printed. It is not intended for any sort of manipulation purposes. http://en.wikipedia.org/wiki/CMYK In the code increasing Red reduces the Cyan. This is correct when printing but what we would need to do is increase Magenta and Yellow for an Additive screen view. Ken 

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
 
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Color Space conversions  Reimar  Photoshop Elements Help  4  01162004 06:58 AM 
Batch Raw conversions in PS CS  okplayer  Software  0  12192003 01:03 PM 