de.unihalle.informatik.MiToBo.visualization.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.visualization.drawing.DrawRegion2DSet
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator, de.unihalle.informatik.Alida.operator.events.ALDOperatorExecutionProgressEventListener, EventListener

@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. The following 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
  • OLOR_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
  • CONTOURS: draw contours of the regions in a given colour
  • 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, 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 CONTOURS: draw contours of the regions in a given colour
     
    Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
    de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
     
    Field Summary
     
    Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
    completeDAG, name, operatorExecutionEventlistenerList, 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
    DrawRegion2DSet(DrawRegion2DSet.DrawType dtype, MTBRegion2DSet regions, Boolean cloneTargetImage)
              Simple constructor to create the most common region image types: see DrawType
    DrawRegion2DSet(DrawRegion2DSet.DrawType dtype, MTBRegion2DSet regions, MTBImage targetimage)
              Simple constructor to draw the most common region image types to a given image:
     
    Method Summary
    protected  int color2int(Color c)
               
     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
     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.
    protected  Color int2Color(int color)
               
    protected  void operate()
               
    protected  int randomColor(Random r)
               
     void setColor(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(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(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
    addOperatorExecutionProgressEventListener, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getHidingMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, runOp, runOp, runOp, setConstructionMode, setHidingMode, setName, setParameter, setVerbose, toStringVerbose, unconfiguredItems, validate, validateGeneric, writeHistory, writeHistory, writeHistory
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    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

    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,
                           Boolean cloneTargetImage)
                    throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
    Simple constructor to create the most common region image types: see DrawType

    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:

    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

    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

    setInputRegions

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


    getInputRegions

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

    Returns:
    set of regions

    setTargetImage

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


    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

    setDrawType

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

    Parameters:
    dtype - see DrawType

    getDrawType

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


    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

    getImageType

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


    setGrayValue

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


    getGrayValue

    public 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

    setColor

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


    getColor

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

    Returns:
    Color or null, if none was specified.

    setRandom

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


    getRandom

    public 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

    setResultImage

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


    getResultImage

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


    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(Random r)

    color2int

    protected int color2int(Color c)

    int2Color

    protected Color int2Color(int color)


    Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.