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.
Let Y = 0.3*R + 0.59*G + 0.11*B for each pixel in the image, then set them to be
Y = 0.3*R + 0.59*G + 0.11*B
((R1+Y)/2,(G1+Y)/2,(B1+Y)/2)
if (R1,G1,B1) is what you are colorizing with.
(R1,G1,B1)
2.1m questions
2.1m answers
60 comments
57.0k users