Archived

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

Hue\Saturation adjustment

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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]

Share this post


Link to post
Share on other sites