@ALDAOperator(genericExecutionMode=ALL, shortDescription="Visualizes 2D regions.") public class DrawRegion2DSet extends MTBOperator
Background is always 0, regions can be drawn in different ways. The following kinds of region images can be created or drawn to an existing image:
MTBRegion2D
for details)
Constructors take the kind of image and the regions to be drawn as well as an eventual target image. Default configurations are set by the constructors. Use the different get/set methods to specify non default parameters like color, gray value etc.
Be sure to set the xMin, xMax, yMin, yMax values of the input
MTBRegion2DSet
correctly, because these values are
used to determine the output image size if no target image is specified
nor dimensions are given explicitly!
Modifier and Type | Class and Description |
---|---|
static class |
DrawRegion2DSet.DrawType
Type of image to be drawn.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
cloneTargetImage
Flag to enable/disable cloning of target image.
|
private Color |
color
Color value used, e.g., for color and transparent images.
|
private DrawRegion2DSet.DrawType |
drawType
Type of image to be created.
|
private Double |
grayValue
Gray value used, e.g., for mask or contour images.
|
private MTBImage.MTBImageType |
imageType
Desired type of output image.
|
private MTBRegion2DSet |
inputRegions
Set of regions to draw.
|
private Random |
random
Random generator for color sampling.
|
private MTBImage |
resultImage
Output image.
|
private int |
resultImgHeight
Desired height of result image.
|
private int |
resultImgOffsetX
Desired offset in x of result image.
|
private int |
resultImgOffsetY
Desired offset in y of result image.
|
private int |
resultImgWidth
Desired width of result image.
|
private MTBImage |
targetImage
Optional target image.
|
Constructor and Description |
---|
DrawRegion2DSet()
Default constructor where no parameters are set.
|
DrawRegion2DSet(DrawRegion2DSet.DrawType dtype,
MTBRegion2DSet regions)
Simple constructor to create the most common region image types.
|
DrawRegion2DSet(DrawRegion2DSet.DrawType dtype,
MTBRegion2DSet regions,
MTBImage tImage,
boolean cloneTImage)
Simple constructor to draw the most common region image types to
a given image.
|
Modifier and Type | Method and Description |
---|---|
protected int |
color2int(Color c)
Transforms color to integer value.
|
Color |
getColor()
Get the uniform color of the regions in a color image (COLOR_IMAGE only).
|
String |
getDocumentation() |
DrawRegion2DSet.DrawType |
getDrawType()
Get the kind of region image drawn by the operator
|
Double |
getGrayValue()
Get the gray value of the regions in a mask image (MASK_IMAGE only).
|
MTBImage.MTBImageType |
getImageType()
Get the datatype of the resulting image.
|
MTBRegion2DSet |
getInputRegions()
Get the regions that have to be drawn
|
Random |
getRandom()
Get the random number generator which is responsable to draw each region in a random color (COLOR_IMAGE only).
|
MTBImage |
getResultImage()
Get the resulting region image.
|
MTBImage |
getTargetImage()
Get the target image to which the regions are drawn, if one was specified.
|
private void |
initOperator()
Initial setip of the operator.
|
protected Color |
int2Color(int cInt)
Transforms integer value to
Color object. |
protected void |
operate() |
protected int |
randomColor(Random r)
Generates the next random color.
|
void |
setCloneTargetImage(boolean flag)
Enable or disable cloning of target image.
|
void |
setColor(Color c)
Set the uniform color of the regions in a color image.
|
void |
setDrawType(DrawRegion2DSet.DrawType dtype)
Set the kind of region image to be drawn
|
void |
setGrayValue(Double value)
Set the gray value of the regions in a mask image.
|
void |
setImageType(MTBImage.MTBImageType type)
Set the resulting image's datatype.
|
void |
setInputRegions(MTBRegion2DSet regions)
Set the input regions to be drawn.
|
void |
setRandom(Random r)
Set a random number generator to draw each region in a random color.
|
private void |
setResultImage(MTBImage image)
Set the resulting image.
|
void |
setResultImageHeight(int h)
Set target image height, overwrites all other internal settings.
|
void |
setResultImageOffsetX(int ox)
Set desired offset for target image in x direction.
|
void |
setResultImageOffsetY(int oy)
Set desired offset for target image in y direction.
|
void |
setResultImageWidth(int w)
Set target image width, overwrites all other internal settings.
|
void |
setTargetImage(MTBImage targetimage)
Specify a target image to which the regions are drawn.
|
private void |
synchronizeColorOptions()
Updates color parameter if a random generator is given.
|
private void |
synchronizeRandomOptions()
Updates random parameter if a color is set.
|
private void |
updateImageAndColorSettings()
Updates output image type and gray values according to chosen draw
type.
|
private void |
updateTargetImageDependencies()
Updates parameters depending on the target image.
|
void |
validateCustom() |
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, 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, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Input Regions", required=true, direction=IN, dataIOOrder=0, mode=STANDARD, description="Regions to draw.") private transient MTBRegion2DSet inputRegions
@Parameter(label="Draw Type", required=true, direction=IN, dataIOOrder=1, mode=STANDARD, paramModificationMode=MODIFIES_INTERFACE, callback="updateImageAndColorSettings", description="The type of image to be drawn.") private DrawRegion2DSet.DrawType drawType
@Parameter(label="Type of Output Image", required=true, direction=IN, dataIOOrder=2, mode=STANDARD, description="The data type of the output image.") private MTBImage.MTBImageType imageType
@Parameter(label="Gray Value", required=false, direction=IN, dataIOOrder=0, mode=STANDARD, description="Gray value used to draw all regions or contours.") private Double grayValue
@Parameter(label="Color Value", required=false, direction=IN, dataIOOrder=1, mode=STANDARD, paramModificationMode=MODIFIES_INTERFACE, callback="synchronizeRandomOptions", description="A color used to paint all regions or contours.") private Color color
@Parameter(label="Random Generator", required=false, direction=IN, dataIOOrder=2, mode=STANDARD, paramModificationMode=MODIFIES_INTERFACE, callback="synchronizeColorOptions", description="Random generator for sampling pseudo-colors.") private Random random
@Parameter(label="Target Image", required=false, direction=IN, dataIOOrder=3, mode=STANDARD, paramModificationMode=MODIFIES_INTERFACE, callback="updateTargetImageDependencies", description="Image where to draw the regions into.") private transient MTBImage targetImage
@Parameter(label=" - Clone Target Image?", required=false, direction=IN, dataIOOrder=4, mode=STANDARD, description="Select if the target image should be cloned.") private boolean cloneTargetImage
@Parameter(label="Result Image Width", required=false, direction=IN, dataIOOrder=5, mode=ADVANCED, description="Width of target image.") private int resultImgWidth
If this parameter and resultImgHeight
are set to something
different from -1 they will overwrite all other specifications.
@Parameter(label="Result Image Height", required=false, direction=IN, dataIOOrder=6, mode=ADVANCED, description="Height of target image.") private int resultImgHeight
If this parameter and resultImgWidth
are set to something
different from -1 they will overwrite all other specifications.
@Parameter(label="Result Image Offset X", required=false, direction=IN, dataIOOrder=7, mode=ADVANCED, description="Offset in x of result image.") private int resultImgOffsetX
If resultImgHeight
and resultImgWidth
are set to values
different from -1 this parameter will be used and overwrite all other
specifications.
@Parameter(label="Result Image Offset Y", required=false, direction=IN, dataIOOrder=8, mode=ADVANCED, description="Offset in y of result image.") private int resultImgOffsetY
If resultImgHeight
and resultImgWidth
are set to values
different from -1 this parameter will be used and overwrite all other
specifications.
@Parameter(label="Result Image", direction=OUT, mode=STANDARD, dataIOOrder=0, description="Result image.") private transient MTBImage resultImage
public DrawRegion2DSet() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Don't use this for region image creation.
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown if instantiation fails.public DrawRegion2DSet(DrawRegion2DSet.DrawType dtype, MTBRegion2DSet regions) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
See drawType
for details.
dtype
- Drawing type to be used.regions
- Set of regions to be drawn.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.public DrawRegion2DSet(DrawRegion2DSet.DrawType dtype, MTBRegion2DSet regions, MTBImage tImage, boolean cloneTImage) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
dtype
- Drawing type to apply.regions
- Set of regions to draw.tImage
- Target image to draw the regions to.cloneTImage
- Flag to clone the target image.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of processing failure.private void initOperator()
public void validateCustom() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
validateCustom
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setInputRegions(MTBRegion2DSet regions)
regions
- Regions to draw.public MTBRegion2DSet getInputRegions()
public void setTargetImage(MTBImage targetimage)
If image is null
a new image is created.
targetimage
- Target image.public MTBImage getTargetImage()
public void setCloneTargetImage(boolean flag)
Enabling cloning of the image requires a target image to be available.
flag
- If true cloning of target image is enabled.public void setDrawType(DrawRegion2DSet.DrawType dtype)
dtype
- see DrawTypepublic DrawRegion2DSet.DrawType getDrawType()
public void setImageType(MTBImage.MTBImageType type)
If a target image was specified and the given type differs from the target image's type, the target image is set to null. In this case a new image is created.
type
- Desired type of result image.public MTBImage.MTBImageType getImageType()
public void setGrayValue(Double value)
This setting is only active if a mask image is to be created. Be aware of the resulting image's datatype!
value
- Gray value to use.public Double getGrayValue()
public void setColor(Color c)
This setting is only active if a color image is to be created.
c
- Color to be applied.public Color getColor()
public void setRandom(Random r)
This setting is only active if a color image is to be created.
r
- Random generator to be applied.public Random getRandom()
public void setResultImageWidth(int w)
w
- Desired width of target image.public void setResultImageHeight(int h)
h
- Desired height of target image.public void setResultImageOffsetX(int ox)
ox
- Desired offset of target image in x.public void setResultImageOffsetY(int oy)
oy
- Desired offset of target image in y.private void setResultImage(MTBImage image)
image
- Result image.public MTBImage getResultImage()
If a target image (targetImage
) was specified, this is the
same object if cloning was not selected.
protected void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
protected int randomColor(Random r)
r
- Random generator to be used.protected int color2int(Color c)
c
- Color to transform.protected Color int2Color(int cInt)
Color
object.cInt
- Input integer value.private void updateImageAndColorSettings()
private void updateTargetImageDependencies() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.private void synchronizeRandomOptions() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.private void synchronizeColorOptions() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.public String getDocumentation()
getDocumentation
in class de.unihalle.informatik.Alida.operator.ALDOperator
Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.