views:

93

answers:

4

I want to develop a program which recolors the input image based on the given theme the same way as ms-powerpoint application does.

I am giving following link that shows what exactly i want to do.

I want to generate images same as images in below link under the Dark Variations and light Variations title based on the current theme.

http://blogs.msdn.com/powerpoint/archive/2006/07/06/658238.aspx

Can anybody give me idea,info regarding how to achieve it efficiently ??

+2  A: 

You can give a look to the HSL colorspace to be able to have the same result. HSL means Hue, Saturation, Lightness.

You can keep the lightness of each pixel of your image and change only the hue. I think this will allow you to achieve what you want. You can find the RGB to HSL conversion on the wiki page.

Hope that helps.

Patrice Bernassola
That's not quite sufficient - in HSL, black remains black and white remains white no matter what the hue. Dark Variations replace the white with a light color, and Light Variations replace the black with a dark color.
Mark Ransom
+1  A: 

You can use a library like CxImage and convert the image to grayscale, then use the mix command with another image that you have made that is the same size as the original, and mix the two with the Mix command, using the filters. You can do mix-screen, and this should tint the pixels the color of the second image in the resultant image. Try playing with CxImage a bit, see if it will do what you want it to do. This is all coming off the top of my head, and its been a while since I have tried to do anything like this. YMMV, but this would be the simplest implementation. You could always look at how CxImage does the blend, and apply it to the image yourself.

Jay Kramer
+2  A: 

Step 1: Choose the colors you want to represent black and white. For the dark variations, choose black and a light color; for the light variations, choose a dark color and white.

Step 2: Convert a pixel to gray. A common formula for this is L = R*0.3 + G*0.59 + B*0.11.

Step 3: Interpolate between the colors using the gray value. output.R = (L/255)*light.R + (1-(L/255))*dark.R and likewise for green and blue.

Mark Ransom
thanks ,but i want to make it generic for all themes (component colors of theme are know to me ).Can you give an example how to chose light.R and dark.R ?Thanks in advance.
Ashish
You can measure what Microsoft used - for example, the first 3 Dark variations use RGB (154,191,248), (248,154,153), and (216,248,159); the first 3 Light variations use (55,99,153), (156,57,54), and (121,149,62).
Mark Ransom
A: 

I must say thanks to Mark and Patrice for ur guidance which helped me achieved it.

For light variation, I have done it by converting the theme colors to HSV colorspace and found relation between output color and theme color for black color (input) .

The relation was found to be linear for saturation and value and hue was almost constant.

I have used interpolation formula to make it generic for any given theme. I have also make use of color matrix to achieve desired result.

Similarly for dark variation i have used white color as input and apply the same technique.

Ashish