View Full Version : Color Subtraction Help needed dario 02-22-2006, 01:38 AM 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:
http://img49.imageshack.us/img49/5918/testremovecolor2wm.jpg
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 Kraellin 02-22-2006, 01:02 PM hi dario,
welcome to RetouchPRO.
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.
craig dario 02-22-2006, 01:48 PM hi dario,
well, you've made this too simple ;)
craig
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. CJ Swartz 02-22-2006, 11:58 PM 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) :)
http://www.heathrowe.com/tuts/color_selective.asp bart_hickman 02-23-2006, 03:58 AM 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.
Bart dario 02-24-2006, 02:00 AM 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 :)
Dario philbach 02-24-2006, 12:14 PM 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. bart_hickman 02-24-2006, 11:06 PM 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.
Bart dario 02-25-2006, 08:49 AM 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)
Dario | |