-2

I am trying to find the average colour in a picture, and convert the colours to HSB.

I am using a bufferedImage and the list function, and I have found the colours red, green and blue in each pixel.

Can anyone give me some tips on how to convert to HSB in java? :)

user2080806
  • 21
  • 1
  • 1

1 Answers1

2

Use java.awt.Color.RGBtoHSB(int r, int g, int b, float[] hsbvals). See javadoc here.

P.S. If you use p = bufferedImage.getRGB(x,y), recall that the lowest 8 bits (myPixel&0xff) correspond to the blue component, so you may use something like: Color.RGBtoHSB((p>>16)&0xff, (p>>8)&0xff, p&0xff, hsbvals).

erickson
  • 249,448
  • 50
  • 371
  • 469
StatsTrade
  • 51
  • 2