Class ContourROI

All Implemented Interfaces:
EditableOutlineROI, RotatableROI, StretchableROI, Cloneable

public class ContourROI extends IrregularROI
A class for edge detection and contour following. A ContourROI is an IrregularROI formed by contour following, at a certain intensity level on an image slice. The intensity level can be retrieved from the ContourROI using its getLevel() method.

The points that form the vertices of a contour are generally on the boundaries between pixels (of the image on which the contour was formed). However, this depends on whether pixel snap is turned on.

A contour may be formed on any type of image. For colour images (PixelDataType.RGB_BY_PLANE, PixelDataType.RGB_INTERLACED, PixelDataType.COLOURPACKED) contouring is performed on the luminance value (= (0.299 * Red) + (0.587 * Green) + (0.114 * Blue)). For PixelDataType.COMPLEX images, contouring is performed on the real part, imaginary part, magnitude or phase of the image, depending on the ComplexMode argument to the contouring method.

  • Field Details

    • SEARCH_SIZE

      public static final int SEARCH_SIZE
      The size of the area of pixels to search for the maximum gradient. This will apply for images with square pixels (2-D search) or cubic (3-D search) voxels. For images with non-isotropic pixel size, the area searched will be approximately square or cubic, and the number of number of pixels searched will be adapted to make it so. Should be an odd number.
      See Also:
  • Method Details

    • getLevel

      public double getLevel()
      Returns the intensity level that this ContourROI followed.
      Returns:
      the intensity level that this ContourROI followed.
    • getCreateInteractionType

      public static InteractionType getCreateInteractionType()
      Returns the type of interaction needed to create a ContourROI.
      Returns:
      type of interaction needed to create a ContourROI - InteractionType.CLICK.
    • getInstances

      public static List<ROI> getInstances(org.jogamp.vecmath.Point3i startPoint, ContourMode contourMode, double level, IntensityRelation intensityRelation, boolean threeDEdgeDetection, boolean threeDPropagation, short plusMinusSlices, Object pixels, PixelDataType dataType, ComplexMode complexMode, int nCols, int nRows, int nSlices, float pixelXSize, float pixelYSize, float pixelZSize, byte userColour, boolean pixelSnap, boolean snapCentre, ContourWorker contourWorker) throws ROIException, CancelledException
      Create a ContourROI by contouring from a start point on the image.
      Parameters:
      startPoint - the starting location (mouse click point, in image pixel coordinates) within the image slice from which edge detection or contour following is initiated.
      contourMode - the ContourMode for finding the start point of the contour.
      level - the intensity level.
      intensityRelation - the intensity relationship between the contoured feature and the background.
      threeDEdgeDetection - whether edge detection should be in 3-D.
      threeDPropagation - whether contour propagation should be in 3-D.
      plusMinusSlices - for 3-D propagation, the maximum number of slices either side of the seed slice to propagate.
      pixels - the arrays of image intensity values.
      dataType - the PixelDataType of the image pixels.
      complexMode - the ComplexMode for contouring on Complex images.
      nCols - the number of columns in the image.
      nRows - the number of rows in the image.
      nSlices - the number of slices in the image.
      pixelXSize - the width of an image pixel.
      pixelYSize - the height of an image pixel.
      pixelZSize - the depth of an image pixel.
      userColour - an index into the palette of user-defined ROI colours.
      pixelSnap - whether to snap the contours to the nearest pixel corners/centres.
      snapCentre - if true, snap to the centre of pixels; if false snap to the corners.
      contourWorker - if non-null, a check is made of contourWorker to see if creation of contours has been cancelled. Cancellation causes a CancelledException to be thrown.
      Returns:
      a java.util.List<ContourROI> of ContourROIs representing the contour(s) generated from the startPoint. For 2-D contouring, the list will contain a single contour. If threeDPropagation is true, contours are propagated to adjacent slices, and the list contains all ROIs in all slices.
      Throws:
      ROIException - if contour following fails.
      CancelledException - if contouring is cancelled by the user, or programmatically.
    • getInstances

      public static List<ContourROI> getInstances(Object pixels, PixelDataType dataType, ComplexMode complexMode, BitSet mask, int slice, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, double level, IntensityRelation intensityRelation, boolean pixelSnap, boolean snapCentre)
      Returns a java.util.List of ContourROIs that form all the contours at a certain intensity level on a slice of pixels.
      Parameters:
      pixels - the 1-D array of pixels representing a 2- or more dimensional raster of intensities.
      dataType - the PixelDataType of the image pixels.
      complexMode - the ComplexMode for contouring on PixelDataType.COMPLEX images.
      mask - a binary mask of pixels to be considered for contouring.
      slice - the image slice on which the contours will be formed.
      nCols - the number of columns in the image.
      nRows - the number of rows in the image.
      pixelXSize - the width of an image pixel.
      pixelYSize - the height of an image pixel.
      userColour - an index into the palette of user-defined ROI colours.
      level - the intensity level of the contours.
      intensityRelation - the intensity relationship between the contoured feature and the background.
      pixelSnap - whether to snap the contours to the nearest pixel corners/centres.
      snapCentre - if true, snap to the centre of pixels; if false snap to the corners.
      Returns:
      a java.util.List<ROI> of ContourROIs that represent the contours on the image slice.
    • getDescription

      public String getDescription()
      Description copied from class: ROI
      Return a description of this type of ROI.
      Overrides:
      getDescription in class IrregularROI
      Returns:
      a String describing the type of this ROI.
    • getName

      public static String getName()
      Returns the name of the type of ROI.
      Returns:
      the name "Contour".
    • main

      public static void main(String[] args)
      Run the self-test on this class.
      Parameters:
      args - the program arguments. The first argument should be the name of an image for which contours will be created. Contour will only be created for the first slice of the image. The second argument should be the name of an ROI file for the ContourROIs created.
    • getButtonIcon

      public static Icon getButtonIcon()
      Returns an Icon that can be used for a button to create this type of ROI.
      Returns:
      an Icon that can be used to represent this type of ROI.