RetouchPRO

Go Back   RetouchPRO > Tools > Software
Register Blogs FAQ Site Nav Search Today's Posts Mark Forums Read


Software Photoshop, Lightroom, Paintshop Pro, Painter, etc., and all their various plugins. Of course, you can also discuss all other programs, as well.

FilterMeister - Color Theory and Conversions

Reply
 
Thread Tools
  #71  
Old 03-29-2006, 12:32 PM
Stroker's Avatar
Stroker Stroker is offline
Senior Member
 
Join Date: Jan 2005
Posts: 370
Oh, my. It appears that I've done it again. I went to MTU for programming and math, and yet I still made a very bad mistake. I don't mind when I make a mistake and keep it to myself, but I have to beat my own butt when I pass my mistakes on to others.

I work in my own little world. I understand things in my world in my own special way. However, I can't always properly express those things to others. That is, I have my own nomenclature and it doesn't always match things outside of my world.

unit vector - vector with unit length of 1
normal - vector that is 90 degrees to another vector in a special way

Through this whole thing I've been using normal to mean unit vector. Shame on me.

I need a classroom with a chaulkboard.
Reply With Quote top
  #72  
Old 03-29-2006, 07:00 PM
Cameraken's Avatar
Cameraken Cameraken is offline
Senior Member
 
Join Date: Feb 2005
Location: Lancashire (UK)
Posts: 1,158
Thanks Stroker.

Hey, Stroker No worries. I don’t think I’ll ever catch up to you.

Your input to this thread has been absolutely fantastic and I can’t thank you enough for taking the time to do all this for us.

Craig has requested another filter
http://www.retouchpro.com/forums/software/13201-another-plugin-idea-desire.html

I will try to write this as it does not sound too difficult.
My main concern is that it will need a ‘feather’ to blend in.
I’m not sure of the code for that.


Ken
Reply With Quote top
  #73  
Old 04-06-2006, 03:16 PM
Cameraken's Avatar
Cameraken Cameraken is offline
Senior Member
 
Join Date: Feb 2005
Location: Lancashire (UK)
Posts: 1,158
Anyone good at maths?

I have plotted some input values (grey) and tabulated the required RGB output values.
As you will see from the graph I have taken 21 samples. There are a few anomalies in there but it’s showing some sort of pattern

The output values of Green are easy (Grey – 15 will give something approx)

The Red values are giving me problems
At low Grey values, Red needs to be double Grey (Red = Grey*2) but at higher values Red equals Grey (Red = Grey)

I could do this with a load of ‘If’ Statements but I’m sure there is an easier way.

Any Ideas?

Ken
Attached Images
File Type: gif Graph.gif (12.5 KB, 14 views)
Reply With Quote top
  #74  
Old 04-06-2006, 03:52 PM
Stroker's Avatar
Stroker Stroker is offline
Senior Member
 
Join Date: Jan 2005
Posts: 370
red = grey + grey*(255-grey)/128

???
Reply With Quote top
  #75  
Old 04-07-2006, 06:17 AM
Cameraken's Avatar
Cameraken Cameraken is offline
Senior Member
 
Join Date: Feb 2005
Location: Lancashire (UK)
Posts: 1,158
Thanks Stroker.

That’s looking pretty good.
The only problem is that input values over 125 are sending the output reds over 255

I guess I could knock these down by a percentage to keep them in range?

I’ll post this code as soon as I get it working.

Ken
Attached Images
File Type: gif Graph2.gif (5.9 KB, 7 views)
Reply With Quote top
  #76  
Old 04-07-2006, 03:02 PM
Cameraken's Avatar
Cameraken Cameraken is offline
Senior Member
 
Join Date: Feb 2005
Location: Lancashire (UK)
Posts: 1,158
Here it is.
Ken’s colourizing skin Filter.
It may be small but it works great.

The graph in post 145 shows how real skintones look in b&w. And the graph below shows how this code puts the colour back. It adds tonal variations to the skin that would be difficult to achieve with a brush
My sample points come from skin charts and real pictures.

Here is how to use it for a base to colour skin.

Run the code on a b&w or colour photo.
In PS add a hide all mask and paint back the skin (and hair)
Add a Hue/Sat Adjustment and adjust the saturation to taste. (Sat -20 to -50 usually looks good)
This is by no means a finished colorize, but it is a good (and quick) start.

Please let me know what you think. If you find it useful I will package it up for our friends.

NB. All the swatches I used were for European skin. I may add other Nationalities.

Thanks for your help Stroker. I changed 128 to 255 as I found it a better fit overall.

Ken.

Code:
%ffp

Category        :"Ken"
Title                :"Ken's Skin Colorizer"
Copyright        :"Ken ©2006"
Author                :"CameraKen"
Filename        :"Ken's Skin Colorizer.8bf"
Description        :"European Skin Colorizer"
Version                :"1.0"
Dialog                :"CameraKen's European Skin Colorizer"

supportedmodes:RGBMode

ForEveryTile:{

			int r,g,b,Grey, 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++){

				//(Grey=src(x,y,0)+src(x,y,1)+src(x,y,2))/3;
				
				Grey=(src(x,y,0)*0.30+src(x,y,1)*0.59+src(x,y,2)*0.11);
				
rv=Grey+Grey*(255-Grey)/255;
gv=Grey -15;
bv=Grey-Grey*(255-Grey)/255;
	
				pset(x,y,0, rv );
				pset(x,y,1, gv );
				pset(x,y,2, bv );
	}}

	return true;
}
Attached Images
File Type: gif Graph3.gif (15.4 KB, 6 views)
Reply With Quote top
  #77  
Old 04-09-2006, 07:53 AM
Stroker's Avatar
Stroker Stroker is offline
Senior Member
 
Join Date: Jan 2005
Posts: 370
Rock on, Ken. Take the idea a bit further and have different data sets for different sets of skin tones. Snapper might be a good idea. Great. Now I'm going to be messing with this idea.

Back when I started messing with vectors in Lab mode, I started using a technique that I call Spherify. Basically take a point from the center and then shoot it onto the outside of the Lab sphere.

p1 = center of the sphere
p2 = given pixel values
get the vector
convert vector to unit vector
final values = unit vector * 127

Interesting technique. Can show you a few things about an image with a glance. But it does take a bit of getting used to.

As I started looking at the final Spherify images more and more often, I started to see another data set that I wanted. I eventually took Spherify and ChOpped it into Event Horizon.

This is kind of a weird way of dividing a photograph into mids, highs, and lows. A bizarre mix of Lightness and saturation/rho.

When you run the code, you will be left with a mess. You can ignore the mess because the good stuff is in the individual channels.

L = mids
a = highs
b = lows

These channels are an interesting place to work with contrast, saturation, and things.

Code:
%ffp

Category:"Tech Slop Lab"
Title:"Event Horizon"
Author:"JLHalmich"
Copyright: "2006 by JLHalmich"
Organization:"Tech Slop Lab"
Version:"beta 1"
Filename: "TS_eventhorizon.8bf"
Description: "Lightness and Rho for\nHigh/Mid/Low"
About: "!t Plug-in !V\n!C\n!c\n!D"

supportedmodes: labmode

dialog: size=(240,185)
ctl[CTL_OK]: MODIFY, pos=(160,165)
ctl[CTL_CANCEL]: MODIFY, pos=(200,165)

ForEveryTile:{
int x,y,ll,aa,bb,rho;
float p1dist,p1nx,p1ny,p1nz;


for (y=y_start; y<y_end; y++){
//if(updateProgress(y,y_end)) abort();
for (x=x_start; x<x_end; x++){

// grab values
ll=src(x,y,0)-128;
aa=src(x,y,1)-128;
bb=src(x,y,2)-128;

// get distance
p1dist=sqrt((float)ll*ll + aa*aa + bb*bb);

// unit vector
p1nx=(float)ll/p1dist;
p1ny=(float)aa/p1dist;
p1nz=(float)bb/p1dist;

// spherify a and b, then get rho
// rho*2 for range of 0 to 255
aa=p1ny*127;
bb=p1nz*127;
rho=c2m(aa,bb)*2;

// reset and recalc a and b for high/low
aa=0; bb=0;
if(ll>=0){aa=255-rho;}
if(ll<0){bb=255-rho;}

// output
pset(x,y,0,rho);
pset(x,y,1,aa);
pset(x,y,2,bb);


}}// x, y

return true;
} // for every tile
Reply With Quote top
  #78  
Old 04-09-2006, 06:59 PM
Cameraken's Avatar
Cameraken Cameraken is offline
Senior Member
 
Join Date: Feb 2005
Location: Lancashire (UK)
Posts: 1,158
Thanks Stroker. Glad you like it.

The graphs are the important bit. Once we have these the rest could be done with curves. But FM is easier.
I’ve tried it on a lot of b&w pictures and it’s worked OK with all of them. The more tones in the b&w the better the colour.

It’s interesting that there is this pattern to the way skintones desaturate. If all colours desaturate slightly differently it may be possible to make good guesses at what the colours were before the picture was made b&w (just a thought) I may try grass, skies, wood, hair etc as well.

I intend to add other skintones and a sat slider and a couple of adjustment to this. I’ll keep playing with it.

Snapper(Gen-A) – I don’t understand? This seems to add grain and alter transparency. Would I not be better altering saturation? Or are you suggesting I use the BMP method of loading a file?
There is another bitmap loader here.
http://groups.yahoo.com/group/FMML/message/3622


Event Horizon
Interesting Stroker. But what can I do with it? Its messed up the picture so adjusting Mids, Highs and Lows would be of no use. Or can you ‘see’ something in the channels that I can’t?

Ken
Reply With Quote top
  #79  
Old 04-10-2006, 01:45 AM
Stroker's Avatar
Stroker Stroker is offline
Senior Member
 
Join Date: Jan 2005
Posts: 370
Yes, I was refering to the bitmap loader code. Each horizontal line in the bitmap can be a different data set of values. It would be like having a bunch of gradient maps or Curves presets in one little bitmap.

The problem you are going to run into is one of variance. How would you handle a peach forehead and rosie cheeks that have the same brightness values? Delve into segmentation? Some post filter painting? While there is a general pattern, variance is key and may not be easy.

Event Horizon - the secrets are held in the individual channels. I'll see about putting something together. However, I'm leaving tomorrow and won't be back for a week or so.
Reply With Quote top
  #80  
Old 04-14-2006, 05:27 AM
Cameraken's Avatar
Cameraken Cameraken is offline
Senior Member
 
Join Date: Feb 2005
Location: Lancashire (UK)
Posts: 1,158
I improved the code slightly by changing

gv=Grey-15 to gv-gv*(255-gv)/1000

This keeps the lows and mids the same but adds a little more green to the highlights.

I now understand why most use CMYK for skin.
RGB values contain the colour and the luminosity. And that is why my graphs were not uniform.
In CMYK the Black is split out. So it is easier to talk percentages.

SupportedModes: CMYKMODE
test=(c+m+y);
This works OK. But
SupportedModes: CMYKMODE
test=(c+m+y+k);
This does not work. How do I access the Black channel?

There seems to be nothing at FM about this but there is are FM command rgb2cmyk and cmyk2rgb??? But there is nothing in the Wiki.

I have also got some code to convert RGB to CMYK but they talk about ‘Normalising’ the data. Is this just a case of changing 0-255 to 0-1 ?

RGB -> CMYK
Black=minimum(1-Red,1-Green,1-Blue)
Cyan=(1-Red-Black)/(1-Black)
Magenta=(1-Green-Black)/(1-Black)
Yellow=(1-Blue-Black)/(1-Black)

CMYK -> RGB
Red=1-minimum(1,Cyan*(1-Black)+Black)
Green=1-minimum(1,Magenta*(1-Black)+Black)
Blue=1-minimum(1,Yellow*(1-Black)+Black)

C, M, Y, K, R, G, and B have a range of [0;1].

http://www.scarse.org/docs/color_faq.html#rgb
http://www.scarse.org/docs/color_faq.html


Ken
Reply With Quote top
Reply

  RetouchPRO > Tools > Software


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Color Space conversions Reimar Photoshop Elements Help 4 01-16-2004 06:58 AM
Batch Raw conversions in PS CS okplayer Software 0 12-19-2003 01:03 PM


All times are GMT -6. The time now is 08:52 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2016 Doug Nelson. All Rights Reserved