Color Extractor Script


#1

Hi,

   This is an action script that I wrote for Photoshop that allows you to separate the color from any image onto it's own 'color' layer. For example, you can take any photograph, and now see the color as a separate layer to the actual shading of the image.
   
   The script is non-destructive and can be used infinitely after re-flattening your layers without any loss of quality.  I looked for a technique or tool to accomplish this when I was studying digital painting and couldn't find one.  This script has helped me tremendously in learning how images are constructed.  I now use it as a tool that allows me to switch between painting with color and focusing on shading and form only.  The script works on 8, 16 and 32 bit images and should support all color image modes.
   
   Installation:  Extract the contents of the .zip file anywhere you prefer.  In Photoshop, simply load the actions window (alt+F9), and in the upper right of this window, click on the pulldown menu and choose "load actions" and simply browse for the file.
   
   Usage: Select a layer in a color image that you would like to separate and play the script.  To assign a hotkey to the action, just double click the script inside of the Actions window and you can assign a function key for faster access.
  
  This script is free to use for both commercial and non-commercial use.  Credit is always appreciated.  Enjoy.

#2

cool script thanks for sharing :smiley:


#3

Great concept Jettatore!

Yes, I think we need more digital tools to us to help and guide the digital painting process. To separate out a tonal study from the color study can be really helpful to the painter.

Have installed, run and looked through this Photoshop action. Now, I see it duplicates the original image twice, creates a color layer through two color blending modes and a 50% grey fill, and then ‘desaturates’ the bottom image. Great idea and just checking that I understand the process correctly?

Now sorry, but I’m just a little dubious on the Desaturate action. I never use it in Photoshop because it’s so inaccurate. The safest way to convert ‘color-values’ into their corresponding tonal value is to covert the image to greyscale. Now totally agree that this is a destructive method - so might not be appropriate. From what I understand, Photoshop averages RGB values to determine a Desaturation value. As a result the luminance shifts.

Only mentioning it as a digital painter wants to reproduce tones accurately. There is such a thing as the difference between perceived and measured luminance. You might want to check it out.

Keen to hear your thoughts. A fasinating topic and well done on developing a tool to aid digital painters.


#4
The second tool I'm working on, that has a few inherent flaws right now, separates the tonal layers of the gray scale image and breaks it down further, either separating the lights, darks and mid-tones to their own layers, or by separating the fine details from the broader form shading.  It's a difficult problem to tackle since images vary widely in their content but I have made some decent progress on it so far.
Now, I see it duplicates the original image twice, creates a color layer through two color blending modes and a 50% grey fill, and then 'desaturates' the bottom image. Great idea and just checking that I understand the process correctly?
 
 Now sorry, but I'm just a little dubious on the Desaturate action. I never use it in Photoshop because it's so inaccurate. The safest way to convert 'color-values' into their corresponding tonal value is to covert the image to grayscale. Now totally agree that this is a destructive method - so might not be appropriate. From what I understand, Photoshop averages RGB values to determine a Desaturation value. As a result the luminance shifts.
You got the concept perfectly.

The script works non-destructively on the vast majority of images.  There are a few images, that it clips out a very small amount of color, just one time.  I believe that is do to the fact that especially in 8 and 16 bit, but even at 32 bit, finding a perfect 50% gray is difficult to locate in Photoshop.

As far as Desaturate, I'm also using after that function, the relatively hidden "Fade Desaturate" function which the research I did, supposedly produces a perfect grayscale or black and white.  Every other method that I tried while experimenting produced completely unacceptable results.  

A good test is this.  Take any image, run the script on it, and then put the original layer on top of the two new layers and use the eye tool to hide the top original layer, flipping back and forth to see any changes.  Most of the time, there are none.  If there aren't any visible color shifts, then this is one of the vast majority of images that the script works perfectly on and you can prove this by continually flattening the two new layers, re-running the script on the result and comparing the new result to the very original for any changes again, rinse and repeat.  Aside from any initial clipping that doesn't even occur on the majority of photographs and paintings, this NEVER appears to result in any degradation regardless how many times you were to repeat it.

I believe the only way to improve the script is to get a perferct 50% gray so that no minimal clipping would ever occur in the first place.  But by all means, please try to break it, bend it and improve it or prove me completely wrong.  I'm all for it.  Also if you have any interest in helping me develop the gray scale splitter I described at first, just PM me, as I could definitely use a hand.  -Derek

#5

Hi Derek,

Thanks for further explaining the workings of the Color Extrator Script for Photoshop.

Great to hear you are open to chatting about the mechanics of the script as I gott’a say this is a topic I really enjoy. I too have found that any tool that can ‘de-construct’ an image into it’s component color-values is very useful to the digital painter. Again, well done on publishing this.

OK. Great tip on the “Fade Desaturation”. Quite right, it is well hidden. Google searched it and came across the following tut which explains it well ( http://www.photoshopessentials.com/photo-effects/fade-color.php ).

Have put together a little test for us as a jpg:

Now, sorry, still not convinced by the use of Desaturate plus Fade with Color blending.

The original image is in the first row. It contains a simple eleven part zone system, black through to white with 10% increments of grey. Under it are six fully saturated primary and secondary colors, covering 360 degrees of the color wheel.

The first is simply desaturated. Notice how Photoshop averages all the colors to 50% grey. The next uses desaturate plus fade color blend mode. Notice while the conversion to black and white is better, the blue is darkened considerably.

Finally, in the bottom row, I have opened a second instance of the image, and converted to greyscale. Comparing the results we get a more even conversion. Especially notice the blue swatch is not as black and more a 20% grey value.

So, this is what I mean when the ‘destructive’ method of converting to Greyscale mode is more accurate a conversion and preserves color-values.

Your tone separation script sounds like a great addition and look forward to seeing its development.

Cheers.


#6

“Photoshop averages all the colors to 50% gray”

I believe that’s exactly what you want here though. Because the way the script/technique works is that you make a 50% gray layer, then take the original color image, put it on top of that layer, and set it’s blending mode to color while it’s on top of the gray layer, and then flatten it, resulting in the separated color layer. Now, when you again, set the blending mode on this new separated layer to color, and put it on top of a fade-desaturated version of the original you should have perfect color separation, sans the ability to find a perfect 50% gray as mentioned previously.


#7

Ok, now I see what your getting at. Let me do a test and see if it jogs my memory a bit, I wrote this thing like 6 months ago…

-Yup, for some reason, and I don’t know the mathematical answer, it just doesn’t work when you repeat the process using grayscale “mode” conversion. My test for this was opening a new copy of the file, setting to grayscale, essentially discarding the color, and then setting back to RGB and importing separately a new “color separated” layer, and also importing a copy of the original to compare to. The comparison between the original and the grayscale version does not work. The same comparison to the desaturated -fade version simply works.

Keep in mind, I wrote this script starting with 0% knowledge of the math behind Photoshop and still have only scratched the surface on that subject.


#8

Yes. We could risk entering into the age old debate of ‘Tonal Realist’ vs. ‘Colorist’.

Looking at it from a painter’s point of view (as opposed to a computer scientist), accurate tonal reproduction is important. I know some painters who even say that it doesn’t matter what color you use, that the viewer judges and reads a painting off it’s tones. Frankly I love color and think it’s just as important as tone - color is not just the icing on the cake.

Just a note on the 50% grey. Noticed in your example that the color separated layer replaces 50% grey with what ever was white. For example, the white petals become grey in the color layer. Seemed at first strange to me, as I would have expected the petals to remain white in the color layer. As they say, color is light and the most saturated colors live within the mid-values. It’s impossible to have a saturated light green, for example, as the closer green approaches white light, the less saturated it is. This also occurs at the other end of the spectrum, where a color is less saturated as it approaches black (or has less light in it). Check out Ostwald and in particular Munsell’s color system. ( http://en.wikipedia.org/wiki/Munsell ) - you’ll find these historical color theorist form the foundation of our contemporary digital color models (particularity the HSB system).


#9

Yeah, makes sense to me also. Seems the 50% grey is a very important part of separating out the color.

Interesting. Will give it some thought. …


#10

“Seemed at first strange to me, as I would have expected the petals to remain white in the color layer.”

Definitely, but it’s being used as a blending mode, where 50% gray turns to nothing (no change) hence when it’s overlayed as color, the white from the black and white shows through as expected.


#11

Hey, very interesting thread you’ve got here.

I never realized there was such a big difference between desaturation and grayscale.

here I got a little comparison between desat and “set channels” (all to luminance) in AE, which seems to be like a grayscale mode transformation, but not completely.

lots of interesting info here, looking forward for more!!


#12

Thank you Jettatore, as someone new to PS, this is very helpful. I will look into this further and hopefully it can help me in my search to create better color all the way around.
Ariana


#13

Very cool script and discussion - thanks kindly for sharing :smiley:


#14

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.