Class ColorHsv
- java.lang.Object
-
- boofcv.alg.color.ColorHsv
-
public class ColorHsv extends java.lang.ObjectColor conversion between RGB and HSV color spaces. HSV stands for Hue-Saturation-Value. "Hue" has a range of [0,2*PI] and "Saturation" has a range of [0,1], the two together represent the color. While "Value" has the same range as the input pixels and represents how light/dark the color is. Original algorithm taken from [1] and modified slightly.
NOTE: The hue is represented in radians instead of degrees, as is often done.
NOTE: Hue will be set to NaN if it is undefined. It is undefined when chroma is zero, which happens when the input color is a pure gray (e.g. same value across all color bands).RGB to HSV:
min = min(r,g,b) max = max(r,g,b) delta = max-min // this is the chroma value = max if( max != 0 ) saturation = delta/max else saturation = 0; hue = NaN if( r == max ) hue = (g-b)/delta else if( g == max ) hue = 2 + (b-r)/delta else hue = 4 + (r-g)/delta hue *= 60.0*PI/180.0 if( hue < 0 ) hue += 2.0*PI
[1] http://www.cs.rit.edu/~ncs/color/t_convert.html
-
-
Field Summary
Fields Modifier and Type Field and Description static floatd60_F32static doubled60_F64static floatPI2_F32static doublePI2_F64
-
Constructor Summary
Constructors Constructor and Description ColorHsv()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidhsvToRgb_F32(Planar<GrayF32> hsv, Planar<GrayF32> rgb)Converts an image from HSV into RGB.static voidhsvToRgb(double h, double s, double v, double[] rgb)Convert HSV color into RGB colorstatic voidhsvToRgb(float h, float s, float v, float[] rgb)Convert HSV color into RGB colorstatic voidrgbToHsv_F32(Planar<GrayF32> rgb, Planar<GrayF32> hsv)Converts an image from RGB into HSV.static voidrgbToHsv(double r, double g, double b, double[] hsv)Convert RGB color into HSV colorstatic voidrgbToHsv(float r, float g, float b, float[] hsv)Convert RGB color into HSV color
-
-
-
Field Detail
-
d60_F64
public static final double d60_F64
- See Also:
- Constant Field Values
-
d60_F32
public static final float d60_F32
- See Also:
- Constant Field Values
-
PI2_F64
public static final double PI2_F64
- See Also:
- Constant Field Values
-
PI2_F32
public static final float PI2_F32
- See Also:
- Constant Field Values
-
-
Method Detail
-
hsvToRgb
public static void hsvToRgb(double h, double s, double v, double[] rgb)Convert HSV color into RGB color- Parameters:
h- Hue [0,2*PI]s- Saturation [0,1]v- Valuergb- (Output) RGB value
-
hsvToRgb
public static void hsvToRgb(float h, float s, float v, float[] rgb)Convert HSV color into RGB color- Parameters:
h- Hue [0,2*PI]s- Saturation [0,1]v- Valuergb- (Output) RGB value
-
rgbToHsv
public static void rgbToHsv(double r, double g, double b, double[] hsv)Convert RGB color into HSV color- Parameters:
r- redg- greenb- bluehsv- (Output) HSV value.
-
rgbToHsv
public static void rgbToHsv(float r, float g, float b, float[] hsv)Convert RGB color into HSV color- Parameters:
r- redg- greenb- bluehsv- (Output) HSV value.
-
hsvToRgb_F32
public static void hsvToRgb_F32(Planar<GrayF32> hsv, Planar<GrayF32> rgb)
Converts an image from HSV into RGB.- Parameters:
hsv- (Input) Image in HSV formatrgb- (Output) Image in RGB format
-
-
DataMelt 3.0 © DataMelt by jWork.ORG