Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colorizing images in Java

I'm working on some code to colorize an image in Java. Basically what I'd like to do is something along the lines of GIMP's colorize command, so that if I have a BufferedImage and a Color, I can colorize the Image with the given color. Anyone got any ideas? My current best guess at doing something like this is to get the rgb value of each pixel in the BufferedImage and add the RGB value of the Color to it with some scaling factor.

like image 243
Paul Wicks Avatar asked Aug 22 '08 23:08

Paul Wicks


1 Answers

Let Y = 0.3*R + 0.59*G + 0.11*B for each pixel in the image, then set them to be

((R1+Y)/2,(G1+Y)/2,(B1+Y)/2)

if (R1,G1,B1) is what you are colorizing with.

like image 148
Nick Avatar answered Sep 30 '22 07:09

Nick