de.unihalle.informatik.MiToBo.drawing
Class DrawRegion2DSet

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDOperator
      extended by de.unihalle.informatik.MiToBo.core.operator.MTBOperator
          extended by de.unihalle.informatik.MiToBo.drawing.DrawRegion2DSet
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator

@ALDAOperator(genericExecutionMode=ALL)
public class DrawRegion2DSet
extends MTBOperator

A class to visualize 2D regions. Background is always 0, regions can be drawn in different ways. Five kinds of region images can be created or drawn to an existing image:

LABEL_IMAGE: draw gray value image where regions are labeled by their index in the set + 1 ID_IMAGE: draw gray value image where regions are labeled by their region id (see MTBRegion2D.id) MASK_IMAGE: draw a mask image with equal gray values for all regions COLOR_IMAGE: draw a mask with colored regions TRANSPARENT_IMAGE: draw a mask with colored regions, but the regions are transparent to show the underlying intensity structure of the given target image

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 nondefault parameters like color, grayvalue etc.

Be sure to set the xMin, xMax, yMin, yMax values of the input MTBRegion2DSet, because these values are used to determine the image size!!

Author:
Oliver Gress

Nested Class Summary
static class DrawRegion2DSet.DrawType
          Type of image to be drawn: LABEL_IMAGE: draw gray value image where regions are labeled by their index in the set + 1 ID_IMAGE: draw gray value image where regions are labeled by their region id (see MTBRegion2D.id) MASK_IMAGE: draw a mask image with equal gray values for all regions COLOR_IMAGE: draw a mask with colored regions TRANSPARENT_IMAGE: draw a mask with colored regions, but the regions are transparent to show the underlying intensity structure of the given target image
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
private  java.awt.Color color
           
private  DrawRegion2DSet.DrawType drawType
           
private  java.lang.Double grayValue
           
private  MTBImage.MTBImageType imageType
           
private  MTBRegion2DSet inputRegions
           
private  java.util.Random random
           
private  MTBImage resultImage
           
private  MTBImage targetImage
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
DrawRegion2DSet()
          Default constructor where NO parameters are set.
DrawRegion2DSet(DrawRegion2DSet.DrawType dtype, MTBRegion2DSet regions)
          Simple constructor to create the most common region image types: see DrawType dtype = COLOR_IMAGE: Mask image with randomly colored regions dtype = MASK_IMAGE: Mask image of type MTB_BYTE, where regions have value 255 dtype = LABEL_IMAGE: Label image of type MTB_INT dtype = ID_IMAGE: ID image of type MTB_INT dtype = TRANSPARENT_IMAGE: Image with transparent randomly colored regions, needs a RGB target image to work
DrawRegion2DSet(DrawRegion2DSet.DrawType dtype, MTBRegion2DSet regions, MTBImage targetimage)
          Simple constructor to draw the most common region image types to a given image: dtype = COLOR_IMAGE: Mask image with randomly colored regions dtype = MASK_IMAGE: Mask image of type MTB_BYTE, where regions have value 255 dtype = LABEL_IMAGE: Label image of type MTB_INT dtype = ID_IMAGE: ID image of type MTB_INT dtype = TRANSPARENT_IMAGE: Image with transparent randomly colored regions, needs a RGB target image to work
 
Method Summary
protected  int color2int(java.awt.Color c)
           
 java.awt.Color getColor()
          Get the uniform color of the regions in a color image (COLOR_IMAGE only).
 DrawRegion2DSet.DrawType getDrawType()
          Get the kind of region image drawn by the operator
 java.lang.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
 java.util.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.
protected  java.awt.Color int2Color(int color)
           
protected  void operate()
           
protected  int randomColor(java.util.Random r)
           
 void setColor(java.awt.Color c)
          Set the uniform color of the regions in a color image (COLOR_IMAGE only).
 void setDrawType(DrawRegion2DSet.DrawType dtype)
          Set the kind of region image to be drawn
 void setGrayValue(java.lang.Double value)
          Set the gray value of the regions in a mask image (MASK_IMAGE only).
 void setImageType(MTBImage.MTBImageType type)
          Set the resulting image's datatype.
 void setInputRegions(MTBRegion2DSet regions)
          Set the input regions to be drawn
 void setRandom(java.util.Random r)
          Set a random number generator to draw each region in a random color (COLOR_IMAGE only).
protected  void setResultImage(MTBImage image)
          Set the resulting image.
 void setTargetImage(MTBImage targetimage)
          Specify a target image to which the regions are drawn, specify 'null' to create a new image
 void validateCustom()
           
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.operator.MTBOperator
readResolve
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
deserializeFromXmlFile, fieldContained, getALDPortHashAccessKey, getConstructionMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, isConfigured, parametersToXmlObject, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, runOp, runOp, runOp, serializeToXmlFile, setConstructionMode, setName, setParameter, setParametersFromXml, setParametersFromXml, setVerbose, toStringVerbose, unconfiguredItems, validate, validateGeneric, writeHistory, writeHistory, writeHistory, writeParametersToXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

color

@Parameter(label="Color",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=4,
           description="A color used to paint all regions")
private java.awt.Color color

drawType

@Parameter(label="Draw type",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=2,
           description="The type of image to be drawn")
private DrawRegion2DSet.DrawType drawType

grayValue

@Parameter(label="Gray value",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=3,
           description="A gray value used to paint all regions")
private java.lang.Double grayValue

imageType

@Parameter(label="Output-image type",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=6,
           description="The datatype of the output image")
private MTBImage.MTBImageType imageType

inputRegions

@Parameter(label="Input regions",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=1,
           description="Regions to draw to image")
private MTBRegion2DSet inputRegions

random

@Parameter(label="Random generator",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=5,
           description="a random generator generate a random color for each region")
private java.util.Random random

resultImage

@Parameter(label="Result image",
           required=true,
           direction=OUT,
           mode=STANDARD,
           dataIOOrder=1,
           description="Result image")
private MTBImage resultImage

targetImage

@Parameter(label="Target image",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=7,
           description="Draw regions to this target image")
private MTBImage targetImage
Constructor Detail

DrawRegion2DSet

public DrawRegion2DSet()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Default constructor where NO parameters are set. Don't use this for region image creation.

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

DrawRegion2DSet

public DrawRegion2DSet(DrawRegion2DSet.DrawType dtype,
                       MTBRegion2DSet regions)
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Simple constructor to create the most common region image types: see DrawType dtype = COLOR_IMAGE: Mask image with randomly colored regions dtype = MASK_IMAGE: Mask image of type MTB_BYTE, where regions have value 255 dtype = LABEL_IMAGE: Label image of type MTB_INT dtype = ID_IMAGE: ID image of type MTB_INT dtype = TRANSPARENT_IMAGE: Image with transparent randomly colored regions, needs a RGB target image to work

Parameters:
dtype - drawing type
regions - a set of regions (set xMin,xMax,yMin,yMax which are used to determine image size)
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

DrawRegion2DSet

public DrawRegion2DSet(DrawRegion2DSet.DrawType dtype,
                       MTBRegion2DSet regions,
                       MTBImage targetimage)
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Simple constructor to draw the most common region image types to a given image: dtype = COLOR_IMAGE: Mask image with randomly colored regions dtype = MASK_IMAGE: Mask image of type MTB_BYTE, where regions have value 255 dtype = LABEL_IMAGE: Label image of type MTB_INT dtype = ID_IMAGE: ID image of type MTB_INT dtype = TRANSPARENT_IMAGE: Image with transparent randomly colored regions, needs a RGB target image to work

Parameters:
dtype - drawing type
regions - a set of regions
targetimage - target image to draw the regions to
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

color2int

protected int color2int(java.awt.Color c)

getColor

public java.awt.Color getColor()
Get the uniform color of the regions in a color image (COLOR_IMAGE only).

Returns:
Color or null, if none was specified.

getDrawType

public DrawRegion2DSet.DrawType getDrawType()
Get the kind of region image drawn by the operator


getGrayValue

public java.lang.Double getGrayValue()
Get the gray value of the regions in a mask image (MASK_IMAGE only).

Returns:
Gray value or null, if none was specified

getImageType

public MTBImage.MTBImageType getImageType()
Get the datatype of the resulting image


getInputRegions

public MTBRegion2DSet getInputRegions()
Get the regions that have to be drawn

Returns:
set of regions

getRandom

public java.util.Random getRandom()
Get the random number generator which is responsable to draw each region in a random color (COLOR_IMAGE only).

Returns:
Random number generator or null, if none was specified

getResultImage

public MTBImage getResultImage()
Get the resulting region image. If a target image (InputImage) was specified, this is the same object.


getTargetImage

public MTBImage getTargetImage()
Get the target image to which the regions are drawn, if one was specified.

Returns:
target image or null, if none was specified and the operator creates a new image

int2Color

protected java.awt.Color int2Color(int color)

operate

protected void operate()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                       de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

randomColor

protected int randomColor(java.util.Random r)

setColor

public void setColor(java.awt.Color c)
Set the uniform color of the regions in a color image (COLOR_IMAGE only).


setDrawType

public void setDrawType(DrawRegion2DSet.DrawType dtype)
Set the kind of region image to be drawn

Parameters:
dtype - see DrawType

setGrayValue

public void setGrayValue(java.lang.Double value)
Set the gray value of the regions in a mask image (MASK_IMAGE only). Be aware of the resulting image's datatype.


setImageType

public void setImageType(MTBImage.MTBImageType type)
Set the resulting image's datatype. 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.

Parameters:
type - result image type

setInputRegions

public void setInputRegions(MTBRegion2DSet regions)
Set the input regions to be drawn


setRandom

public void setRandom(java.util.Random r)
Set a random number generator to draw each region in a random color (COLOR_IMAGE only).


setResultImage

protected void setResultImage(MTBImage image)
Set the resulting image.


setTargetImage

public void setTargetImage(MTBImage targetimage)
Specify a target image to which the regions are drawn, specify 'null' to create a new image


validateCustom

public void validateCustom()
                    throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Overrides:
validateCustom in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException