private void convertRGBtoHSV() {
        float r;
        float g;
        float b;
        float max, min;
        float hsv[] = new float[3];
        float delta;
        for (int i = 0; i < imageSize; i++) {
            r = redPixel[i];
            g = greenPixel[i];
            b = bluePixel[i];
            r /= 255.0f;
            g /= 255.0f;
            b /= 255.0f;
            max = Math.max(Math.max(r, g), b);
            min = Math.min(Math.min(r, g), b);
            delta = max - min;
            hsv[2] = max;
            hsv[1] = (max == 0.0f) ? 0.0f : delta / max;

            if (r == max) {
                hsv[0] = 60.0f * (g - b) / delta + (g < b ? 6 : 0);
            } else if (g == max) {
                hsv[0] = 60.0f * (b - r) / delta + 2;
            } else {
                hsv[0] = 60.0f * (r - g) / delta + 4;
            }
            if (hsv[0] < 0.0f) {
                hsv[0] += 360.0f;
            }

//            hsv = Color.RGBtoHSB(Math.round(r), Math.round(g), Math.round(b), hsv);
            hsvPixel[i] = Color.getHSBColor(hsv[0], hsv[1], hsv[2]).getRGB();
            huePixel[i] = (hsvPixel[i] >> 16) & 0xFF;
            saturationPixel[i] = (hsvPixel[i] >> 8) & 0xFF;
            brightnessPixel[i] = hsvPixel[i] & 0xFF;
        }
    }