Specifically, I have a bunch of photographic crayon images. I would like to remove the color from one to produce a neutral image that I can load into an iPhone app that I'm writing and dynamically color. The crayon images have dark regions (shadows) and light regions (shine) which I would like to preserve. I will be dynamically coloring it with many different colors, ranging from white to rainbow colors to black.

My first inclination is to turn the image into a grayscale image and then somehow turn the color channel into an alpha channel, and change the color of all pixels to black. Then I could use it as a mask. However, this would only preserve the shadows, and I would lose all the highlights.

Any ideas?

  • Can you please post an example of how a mask would lose highlight and shadows? Masks can be all or nothing and everything in between. Commented Aug 19, 2011 at 17:55
  • If I have a square of color, say red, and then I apply another square of color on top, say black, with a mask, then I would end up with a red square with darkish regions (depending on the mask). I wouldn't have any lighter regions at all. Maybe there's a different kind of mask I can use? Commented Aug 19, 2011 at 17:58
  • 1
    A mask is a mask is a mask; a shade of grey to determine the opacity of an image. The only other thing that really changes is the shape of the mask. A visual would really help here, because this isn't making much sense (but that could just be me after a long day's work). Commented Aug 19, 2011 at 18:55
  • Sorry, a visual would have made things easier. I basically just want to colorize a grayscale image, as I realized with Alan's answer. Thank you for helping me to think this through, Philip. Commented Aug 19, 2011 at 21:02

1 Answer 1


I'm entirely unfamiliar with iOS/Objective C coding capabilities, but it seems to me that the problem is not one of masking. For arbitrary color selection inside the app, you'd need to work in Lab, HSB or HSV, if that's possible to do, changing the H or the a and b values programmatically.

In Photoshop, you would do this by adding a Hue/Saturation layer and shifting the Hue slider, or by adding a solid color layer and changing its blend mode to Hue or Color. Apply a mask to isolate the effect to a particular part of the image, but the mask is just white on black. That's how it would work in your app, too, I suspect, if you are considering a specific set of colors, rather than arbitrary, user-definable colors.

  • Perfect. When I asked the question, I thought I would need some complex masking solution. It turns out, all I need to do is (1) take my original crayon photo, (2) turn it into grayscale in Photoshop, (3) load it into my iPhone app, and (4) colorize it by putting a colored layer above it with Hue or Color blend mode. I need to look into how to accomplish step 4, but at least now I have a game plan. Thank you. Commented Aug 19, 2011 at 21:00
  • Glad to help. I'm good at reading between the lines. :-) Commented Aug 20, 2011 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.