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

Photoshop Help Tips, questions, and solutions for Adobe Photoshop users
One tip or question per thread, please

Color Subtraction Help needed

Thread Tools
Old 02-22-2006, 02:38 AM
dario dario is offline
Junior Member
Join Date: Feb 2006
Posts: 13
Question Color Subtraction Help needed

Hi, I am trying to figure out how to automatically subtract a color from an image. I created a model so that i can play with:
The original solid pink wide rectangle was superimposed with a 50%transparent light blue rectangle.

Now, is there a tecnique to automatically "subtract" the blue rectangle and get back the pink one? I am playing with Apply image and Calculation with no success, probably because i do not understand the algorithms used.

Of course this is an artificial example, and i could work with clone stamp, of patch tool, but if i understand this i can apply the method to other real photos.

I use Photoshop CS2

thanks Dario
Attached Images
File Type: jpg test-removecolor.jpg (4.4 KB, 20 views)

Last edited by dario; 02-24-2006 at 11:31 AM.
Reply With Quote top
Old 02-22-2006, 02:02 PM
Craig Walters's Avatar
Craig Walters Craig Walters is offline
Senior Member
Join Date: Apr 2005
Location: somewhere over there
Posts: 8,786
Blog Entries: 4
hi dario,

welcome to RP.

well, you've made this too simple i say that because i think what you want to handle is going to be a more complex solution than what you can do here. for this image, i'd simply use color replace. i'd replace the violet with the red and the blue in the white area with white. simple. real world photographs are rarely that simple. so, if you made an action based on what i just gave, it most likely wouldnt work as an automaticity on more complex images.

Reply With Quote top
Old 02-22-2006, 02:48 PM
dario dario is offline
Junior Member
Join Date: Feb 2006
Posts: 13
Originally Posted by Kraellin
hi dario,
well, you've made this too simple
Probably you are right. Maybe I can tell you my problem. I have a few color images that have been ruined by a color semitransparent ink.
What i would like to do is to "undo" as much as possible the effect of the ink, before going to retouch manually the pictures (by the way, they are covers of old comic books)
That's the situation that i was trying to model with that simple picture i posted: something to be cleaned from some transparent colored ink

That's why i tried to understand the "apply image" and "transform". My guess was that, after manually selecting the ruined part, and knowing the RGB value of the ink, i could somehow "erase" the ink, at least to a great extent.
Reply With Quote top
Old 02-23-2006, 12:58 AM
CJ Swartz's Avatar
CJ Swartz CJ Swartz is offline
Senior Member
Join Date: Sep 2001
Location: Metro Phoenix area, Arizona
Posts: 3,345
Blog Entries: 19
dario, have you tried an adjustment layer using Selective Color yet? You can choose the color you wish to work on (you can work on more than one color using the same adjustment layer) and then adjust the level of Cyan/Magenta/Yellow and or Black affecting that color -- it can help when there are color changes to an image. It won't get you ALL the way, but it might give you a good start.

Here's a short tutorial (using an older version of PShop) just to get you started: (or you can ask questions here at RPro)
Reply With Quote top
Old 02-23-2006, 04:58 AM
bart_hickman's Avatar
bart_hickman bart_hickman is offline
Senior Member
Join Date: Nov 2005
Location: Oregon, USA
Posts: 479
Think in terms of how the colors combined. In the pink parts, you removed half of the red (divided it by two), then added in half of the color value of the blue. In the white parts, you removed half of the white, then added in half of the blue.

So you need to subtract half of the blue back out, then multiply the result by two to get back the original.

Since I don't know the actual value of your original blue, I calculated it from what I see on the white area using this formula:
(original blue) = [(50% blue on white) - (50% white)]*2
(original blue) = [(166,184,230) - (128,128,128)]*2
(original blue) = (76,112,204)

So when I make a strip with color 76,112,204 and set the opacity to 50% and superimpose that on white, I get the light blue in your picture. However, when I superimpose that blue on the pink in your picture, I don't get the same purple. That means something's wrong the picture you posted--perhaps jpeg compression has distorted the colors.

So I reconstructed your picture. Now apply the same general formula to remove the blue from the image:
(original colors) = [(current colors) - (50% blue)]*2
for white:
= [(166,184,230) - 0.5*(76,112,204)]*2
= (255,255,255) (white)

for the pink:
= [(158,121,181) - 0.5*(76,112,204)]*2
= (240,130,158) (pink)

I attached the final image. I removed the blue from a strip inside the original blue strip--you can see the white and pink are restored.

I attached the layer palette as well. The layer "reconstruct" is my reconstruction of your original image--ie., the colors are undamaged.

On top of that is a strip of your original blue color set to 50% opacity (Raster 6). The blend mode is difference.

On top of that is a channel mixer that is masked to only affect the area corresponding to the blue strip. The channel mixer has all three channels set to 200% which corresponds to multiply by 2. You could use a curve layer as well.

I use the principles involved here when I'm doing background replacements where the foreground object has blended with the background color. Also, the background eraser brush in Paintshop Pro does this sort of math so that when you are erasing a background color that has blended with a foreground object, it gets removed in a way that looks realistic.

Attached Images
File Type: jpg color_subtraction.jpg (7.6 KB, 27 views)
File Type: jpg palette.jpg (24.1 KB, 26 views)
Reply With Quote top
Old 02-24-2006, 03:00 AM
dario dario is offline
Junior Member
Join Date: Feb 2006
Posts: 13
Thanks to all!

Bart, attached is a portion of a comics cover ruined by ink. Do you think I can restore it using your technique? If so, can you tell me what steps should i take in this realistic example?

If you take a look you could see that the blu ink partially covered the image. In some portion it is easy to see what color was behind, and I could easily retouch it manually, but in the bottom part of the image it is not clear at all what color was behind.

The goal of a comic restoration is to recover the ORIGINAL colors as much as possible, that's why i would like to "undo" the ink.

thank! this is a great forum!!! I have a tons of questions to ask regarding comics restoring

Attached Images
File Type: jpg ink.jpg (81.6 KB, 48 views)
Reply With Quote top
Old 02-24-2006, 01:14 PM
philbach's Avatar
philbach philbach is offline
Senior Member
Join Date: Mar 2003
Location: Belgium, Wi
Posts: 1,332
Talking Blue Removal

Well one way that's a tad tedious is to select the magic wand tool in photoshop and select colors surrounded by black and fill those selected areas with the appropriate color.

I haven't tried it but possibly importing the image into adobe illustrator and using Illustrators Live Trace command to vectorize the comic image and then selecting the colored areas and filling them with the appropriate color might work too.

I tried using match color. You select the blue part of the image and copy that to a separate layer. Then in the background area you select areas of normal color and use Image Adjustments Match Color. It improved it some but not enough.
Attached Images
File Type: jpg MagicWant.jpg (34.0 KB, 33 views)
Reply With Quote top
Old 02-25-2006, 12:06 AM
bart_hickman's Avatar
bart_hickman bart_hickman is offline
Senior Member
Join Date: Nov 2005
Location: Oregon, USA
Posts: 479
It's doable

In your first post, you told me how the new color was combined with the existing image. In the case of the comic strip, all we have is some of the image after the blue ink and some after. So the strategy is different--we gather as many before/after color pairs as possible, plug those into a curve, then selectively apply that curve to the image.

First gather before/after color pairs. There are several places in the picture where you can see what the color is both before and after application of ink. For example, along the right-hand side, there is a pink rock with ink on it. An after-ink color is ~86,106,156 and a before-ink color on the same rock is ~223,176,157. So I want to put this datapoint into a curve adjustment layer. The red curve will have 86,223 (in,out), the green curve will have 106,176, and the blue curve will have 156,157. I got four or five samples like this and put them into a curve.

Now there's actually a heck of a lot of noise, jpeg artifacts, etc., in this image, so I did NR and blurring on it for taking samples and even after all that, I still get a very jagged (aka noisy) curve. So I smoothed out the curves because it's unlikely the actual ink does such a complex transformation to the image colors.

Now fill the alpha channel for the curve layer with black, then paint white wherever there's ink. The first attachment shows how it looks after some sloppy painting so you can see the effect.

Because the ink destroyed most (about 80%) of the color information AND because there is so much noise in the image AND because the amount of ink is variable, the result is blotchy, but good enough that you can see what the original colors were supposed to be so you can clone from the appropriate undamaged sections. I did some slight curve adjustments after I painted to get things as good as possible.

I attached a picture of the red and green curves (the blue curve is a straight line--apparently the ink was blue enough that it left the blue channel essentially unchanged.)

I think if I had a larger variety of color samples, the curves wouldn't have the "knee" in them--they would be straight lines. The knee doesn't matter here because there aren't any colors brighter than the knee location.

I'm thinking I should write a Paintshop Pro script that takes a series of color pairs, does a linear best fit to the data, and creates a curve layer automatically.

Attached Images
File Type: jpg fig1_remove_ink_from_comic.jpg (87.0 KB, 37 views)
File Type: jpg fig2_curves.jpg (24.0 KB, 16 views)
Reply With Quote top
Old 02-25-2006, 09:49 AM
dario dario is offline
Junior Member
Join Date: Feb 2006
Posts: 13
Bart and Phil. i tried your tecniques and it worked! thank you!
So it seems I was trying to use the wrong command (the Image>Apply or Image>Calculation)

Reply With Quote top

  RetouchPRO > Tools > Software > Photoshop Help

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
Help needed with Cyborgenic Leopard tutorial Baby Noel Software 0 10-16-2007 03:59 PM
Jewelry Retoucher(s) Needed vchiline Classifieds 0 02-05-2007 01:28 PM
What skill level needed? Doug Nelson Photo Restoration 22 10-20-2006 08:06 AM
Drum Scanner Operator Needed productioncoord Classifieds 0 06-08-2004 11:37 AM
Ideas Needed! Vikki Work/Jobs 12 11-21-2002 05:54 AM

All times are GMT -6. The time now is 04:31 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