开发者

Recoloring an image based on current theme?

I want to develop a program which recol开发者_如何学Cors 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 ??


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.


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜