Java Utililty Methods RGB Color Convert To

List of utility methods to do RGB Color Convert To

Description

The list of methods to do RGB Color Convert To are organized into topic(s).

Method

double[]RGBtoHSV(double r, double g, double b)
Calculates the HSV color value for a given RGB value.
double h, s, v;
double min, max, delta;
min = Math.min(Math.min(r, g), b);
max = Math.max(Math.max(r, g), b);
v = max;
delta = max - min;
if (max != 0) {
    s = delta / max;
...
float[]RGBtoHSV(float r, float g, float b, float[] result)
http://www.cs.rit.edu/~ncs/color/t_convert.html
if (result == null) {
    result = new float[3];
float h, s, v;
float min, max, delta;
min = min(r, g, b);
max = max(r, g, b);
v = max; 
...
float[]RGBToHSV(float... rgb)
RGB To HSV
float r = Math.min(Math.max(rgb[0], 0f), 1f);
float g = Math.min(Math.max(rgb[1], 0f), 1f);
float b = Math.min(Math.max(rgb[2], 0f), 1f);
float min = Math.min(r, Math.min(g, b));
float max = Math.max(r, Math.max(g, b));
float delta = max - min;
if (max == 0f)
    return new float[] { 0f, 0f, 0f };
...
voidRGBtoHSV(float[] hsv, float[] rgb)
Convert an RGB color to HSV representation.
float r = rgb[0];
float g = rgb[1];
float b = rgb[2];
float h, s, v, diff;
int minIdx = 0;
int maxIdx = 0;
float maxCol = r;
float minCol = r;
...
voidRGBtoHSV(int r, int g, int b, double hsv[])
Convert r,g,b to h,s,v
int min; 
int max; 
int delMax; 
if (r > g) {
    min = g;
    max = r;
} else {
    min = r;
...
double[]rgbToHsv(int red, int green, int blue)
Converts an RGB color value [0-255] to HSV [0-1].
double r = (double) red / 255.0;
double g = (double) green / 255.0;
double b = (double) blue / 255.0;
double max = Math.max(Math.max(r, g), b);
double min = Math.min(Math.min(r, g), b);
double h = 0;
double s = 0;
double v = max;
...
double[]RGBtoHSV(int red, int green, int blue)
Method returns three doubles representing the HSV values of a RGB input Values in input must be between 0 and 255 Values in output are between 0 and 1.
double H = 0, S = 0, V = 0;
double R = red / 255.0;
double G = green / 255.0;
double B = blue / 255.0;
double var_Min = Math.min(Math.min(R, G), B); 
double var_Max = Math.max(Math.max(R, G), B); 
double del_Max = var_Max - var_Min; 
V = var_Max;
...
voidRGBToHSV(int red, int green, int blue, float[] hsv)
Convert RGB components to HSV (hue-saturation-value).
float min, max, delta;
min = Math.min(red, Math.min(green, blue));
max = Math.max(red, Math.max(green, blue));
hsv[2] = max; 
delta = max - min;
if (max != 0)
    hsv[1] = delta / max; 
else {
...
int[]rgbToHsv(int rgb)
Converts the red, green and blue color model to the hue, saturation and value color model
float r = (float) ((rgb & 0xff0000) >> 16) / 255;
float g = (float) ((rgb & 0x00ff00) >> 8) / 255;
float b = (float) (rgb & 0x0000ff) / 255;
float M = r > g ? (r > b ? r : b) : (g > b ? g : b);
float m = r < g ? (r < b ? r : b) : (g < b ? g : b);
float c = M - m;
float h;
if (M == r) {
...
StringRGBtoHTML(int rgb)
Produces HTML color representation
final StringBuilder b = new StringBuilder("0000000");
b.replace(0, 1, "#");
for (int i = 5; i > 0; i -= 2) {
    final int bt = rgb & 0xFF;
    rgb = rgb >> 8;
    StringBuilder b2 = new StringBuilder(Integer.toString(bt, 16));
    if (bt < 16) {
        b2.insert(0, "0");
...