Archived

This topic is now archived and is closed to further replies.

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Howdy Folks, Does anybody know of an algorithm which takes an image and recolors it in a manner similar to image->adjustments-> hue\saturation with colorize checked in adobe photoshop? I''m basically trying to recolor 2D planets in my space game so I can produce a greater variety of planets without taking up more disk space. Thanks, stilltjack

Share on other sites
Take the brightness (value in hsv) either weighted or unweighted:
unweighted = (r+g+b)/3
I don't remember the exact weights for each color but they're somwhere around
value =
r * 0.3 +
g * 0.59 +
b * 0.11
you'll probably want to scale this from 0->1
to do so you'd just divide by 255 (or multiply by 1/255)

So, say you pick tan (rgb(160,120,96) or so)
Anyway, to get the color to go from black to the specified color (in rgb)
You'd just multiply each grayscale value by the color's rgb value.

But this won't give you the nice
black -> color -> white fade

For that, I'd assume you'd use something like
if (gray_value<=gray(dest_color))
output_color = rgb(color) * gray_value / (1-gray(dest_color))
else
output_color = rgb(color)+(gray_value-dest_color)*255 / (1-gray(dest_color))

That should do the trick (I'm just guessing here, haven't tried it)

Btw, the gray() function is meant to return the value (brightness) of an rgb value.

Also, sometimes you can just get away with multiplying the gray_value by 2 * dest_color and get decent results (works for not very saturated dest_color with medium brightness.
-Michael

[edited by - thr33d on November 11, 2003 6:00:23 PM]

Share on other sites
I'd convert it to HSV or HSL (depending on taste) (you can find the conversion functions with google), there change the saturation and lightness or value, and then convert it back to RGB.

[edited by - Boops on November 11, 2003 7:13:54 PM]

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 104
• 11
• Forum Statistics

• Total Topics
632977
• Total Posts
3009677
• Who's Online (See full list)

There are no registered users currently online

×