@ALDAOperator(genericExecutionMode=ALL, level=APPLICATION) public class RGBToHSXConverter extends MTBOperator
MTBImageRGB
( RGB color space )
into an image with HSX( hue saturation intensity/brightness/value ) color
space.
The type of the resulting image is MTBImageByte MTBImageByte
or MTBImageFloat MTBImageFloat
.
In the later case all three channels have values in the range 0..1
,
otherwise in the range 0..255
.
There are three ways to convert an rgb-image.
Modifier and Type | Class and Description |
---|---|
static class |
RGBToHSXConverter.ColorChannel
Supported Color Channels.
|
static class |
RGBToHSXConverter.Mode
The way of converting an image from rgb to hsi.
|
Modifier and Type | Field and Description |
---|---|
private static int |
BLUE_COMPONENT_INDEX |
static float |
BYTE_TO_DEGREE
Constants to convert from [0-255] to [0-359] and vice versa.
|
private boolean |
createFloatImage
Create byte or float image
|
static float |
DEGREE_TO_BYTE |
private static int |
GREEN_COMPONENT_INDEX |
private static int |
HUE_COMPONENT_INDEX |
static float |
HUE_UNDEFINED |
private MTBImage |
hueMTBImg
Hue channel image.
|
private MTBImageRGB |
inputMTBImageRGB
Input Image.
|
private RGBToHSXConverter.Mode |
mode
Converter mode/algorithm
|
private static int |
RED_COMPONENT_INDEX |
private MTBImage |
resultMTBImg
Result Image.
|
private MTBImage |
satMTBImg
Saturation channel image.
|
private static int |
SATURATION_COMPONENT_INDEX |
static float |
SATURATION_UNDEFINED
To cope with undefined saturation/hue-values, we
use the following scheme.
|
private int |
THREE_COMPONENTS_COLOR_SPACE |
private static int |
X_COMPONENT_INDEX |
private MTBImage |
xMTBImg
Result Image.
|
Constructor and Description |
---|
RGBToHSXConverter()
Default constructor.
|
RGBToHSXConverter(MTBImageRGB image)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
MTBImage |
getHueMTBImg()
Get the hue channel image.
|
MTBImageRGB |
getInputMTBImgRGB()
Returns the input image, null if not set.
|
MTBImage |
getResultMTBImage()
Returns the converted image, null if not available.
|
MTBImage |
getSatMTBImg()
Get the saturation channel image.
|
MTBImage |
getXMTBImg()
Get the value channel image.
|
static boolean |
isHueUndefined(float saturation)
Return
true if the hue channel is undefined which is true is
saturation is zero or undefined which in turn is encoded as zero. |
static boolean |
isHueUndefined(int saturation)
Return
true if the hue channel is undefined which is true is
saturation is zero or undefined which in turn is encoded as zero. |
static boolean |
isSaturationUndefined(float xValue)
Return
true if the saturation channel is undefined which is true
if the x channel is zero. |
static boolean |
isSaturationUndefined(int xValue)
Return
true if the saturation channel is undefined which is true
if the x channel is zero. |
protected void |
operate()
Creates a
MTBImage with three channels, the same size as
the original one and converts each rgb pixel to a
hsx
pixel, where x stands for Inentsity or Brightness or Value
depending on the mode set. |
private float[] |
rgbToHSB_JRE(int[] rgbColor)
Conversion from RGB into HSB color space.
|
private float[] |
rgbToHSI_Sonka(int[] rgbColor)
Conversion from RGB to HSI color space according to Sonka et al.
|
private float[] |
rgbToHSV_EasyRGB(int[] rgbColor)
Conversion from RGB into HSV color space.
|
void |
setHueMTBImg(MTBImage hueChannelImage)
Set the hue channel image.
|
void |
setInputMTBImgRGB(MTBImageRGB inputImage)
Set the input image.
|
void |
setSatMTBImg(MTBImage saturationChannelImage)
Set the saturation channel image.
|
void |
setXMTBImg(MTBImage valueChannelImage)
Set the value channel image.
|
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getDocumentation, getHidingMode, getInactiveParameterNames, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterDescriptorUnconditioned, getParameterNames, getParameterUnconditioned, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, hasInOutParameters, hasParameter, isAnnotatedParameter, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, removeParameter, runOp, runOp, runOp, setConstructionMode, setConstructionMode, setConstructionMode, setHidingMode, setName, setParameter, setParameterUnconditioned, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory
public static final float BYTE_TO_DEGREE
public static final float DEGREE_TO_BYTE
private final int THREE_COMPONENTS_COLOR_SPACE
private static final int RED_COMPONENT_INDEX
private static final int GREEN_COMPONENT_INDEX
private static final int BLUE_COMPONENT_INDEX
private static final int HUE_COMPONENT_INDEX
private static final int SATURATION_COMPONENT_INDEX
private static final int X_COMPONENT_INDEX
public static final float SATURATION_UNDEFINED
public static final float HUE_UNDEFINED
@Parameter(label="Input Image", required=true, dataIOOrder=0, direction=IN, description="Input RGB-image") private transient MTBImageRGB inputMTBImageRGB
MTBImageRGB
.@Parameter(label="Algorithm used", required=true, dataIOOrder=1, direction=IN, description="The algorithm used") private RGBToHSXConverter.Mode mode
@Parameter(label="Create float image", required=true, dataIOOrder=1, direction=IN, description="If true a float image is created, otherwise a byte image") private boolean createFloatImage
@Parameter(label="Result Image", required=true, direction=OUT, dataIOOrder=-1, description="Result image (HSX color space)") private transient MTBImage resultMTBImg
MTBImage
.@Parameter(label="Hue channel Image", required=true, direction=OUT, dataIOOrder=-2, description="Hue-channel image") private transient MTBImage hueMTBImg
MTBImage
.@Parameter(label="Saturation channel Image", required=true, direction=OUT, dataIOOrder=-4, description="Saturation-channel image") private transient MTBImage satMTBImg
MTBImage
.
@Parameter(label="X channel Image", required=true, direction=OUT, dataIOOrder=-8, description="Wheather I or V/B-channel image") private transient MTBImage xMTBImg
MTBImage
.
public RGBToHSXConverter() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public RGBToHSXConverter(MTBImageRGB image) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
image
- The input image.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public MTBImage getResultMTBImage()
null
if not set.public MTBImageRGB getInputMTBImgRGB()
null
if not set.public void setInputMTBImgRGB(MTBImageRGB inputImage)
inputImage
- The input image.public MTBImage getHueMTBImg()
MTBImage
.public MTBImage getSatMTBImg()
MTBImage
.public MTBImage getXMTBImg()
MTBImage
.public void setHueMTBImg(MTBImage hueChannelImage)
hueChannelImage
- The image which contains the hue channel
informations of type MTBImage
.public void setSatMTBImg(MTBImage saturationChannelImage)
saturationChannelImage
- The image which contains the saturation
channel informations of * * type
MTBImage
.public void setXMTBImg(MTBImage valueChannelImage)
valueChannelImage
- The image which contains the value channel
informations of type MTBImage
.protected void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
MTBImage
with three channels, the same size as
the original one and converts each rgb pixel to a
hsx
pixel, where x stands for Inentsity or Brightness or Value
depending on the mode set.
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
private float[] rgbToHSI_Sonka(int[] rgbColor)
rgbColor
- The array of red/green/blue-parts as ints.0.0 : 1.0
.private float[] rgbToHSB_JRE(int[] rgbColor)
RGBtoHSB
method containing in
the jre, in the java.awt.Color
-class.rgbColor
- The array of red/green/blue-parts as ints.0.0 : 1.0
.Color.RGBtoHSB(int, int, int, float[])
private float[] rgbToHSV_EasyRGB(int[] rgbColor)
Code modified from : Easy RGB. A short description of the hsv/hsb colorspace : Wikipedia.
rgbColor
- The array of red/green/blue-parts as ints.0.0 : 1.0
.public static final boolean isHueUndefined(float saturation)
true
if the hue channel is undefined which is true is
saturation is zero or undefined which in turn is encoded as zero.saturation
- public static final boolean isSaturationUndefined(float xValue)
true
if the saturation channel is undefined which is true
if the x channel is zero.xValue
- public static final boolean isHueUndefined(int saturation)
true
if the hue channel is undefined which is true is
saturation is zero or undefined which in turn is encoded as zero.saturation
- public static final boolean isSaturationUndefined(int xValue)
true
if the saturation channel is undefined which is true
if the x channel is zero.xValue
- Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.