I try to convert image from RGB model to HSV and display it. Unfortunately I dont have any idea how to do this. I dont want to use built-in function but I want write function alone. I want to do this in similar way using RGB channels. I read/checked a lot of example from this site but I have not found any special and helpfull materials. Please help how should I do this.
// image from RGB to grayscale
private static BufferedImage monochromatyczny(BufferedImage obrazek)
{
for(int x = 0; x < obrazek.getWidth(); x++)
for(int y = 0; y < obrazek.getHeight(); y++)
{
int piksel = obrazek.getRGB(x, y);
// kanaĆy r,g,b
int r = (piksel>>16) & 0xff;
int g = (piksel>>8) & 0xff;
int b = (piksel) & 0xff;
int gray = (r+g+b)/3;
piksel = (gray<<16) | (gray<<8) | gray;
obrazek.setRGB(x,y,piksel);
}
return obrazek;
}
Good explanation how to convert color RGB -> HSV i'm found on http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
You may to try this formula in your rgb_2_hsv function