com.xinapse.multisliceimage.roi
Class ContourROI

java.lang.Object
  extended by com.xinapse.multisliceimage.roi.ROI
      extended by com.xinapse.multisliceimage.roi.IrregularROI
          extended by com.xinapse.multisliceimage.roi.ContourROI
All Implemented Interfaces:
EditableOutlineROI, RotatableROI, StretchableROI, java.lang.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 always on the boundaries between pixels (of the image on which the contour was formed).

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 Summary
static int SEARCH_SIZE
          The size of the area of pixels to search for the maximum gradient.
 
Fields inherited from class com.xinapse.multisliceimage.roi.IrregularROI
nPoints, POINTSTOKEN, xpts, ypts
 
Fields inherited from class com.xinapse.multisliceimage.roi.ROI
handles, PREFERENCES_NODE_NAME, XTOKEN, YTOKEN
 
Method Summary
static javax.swing.Icon getButtonIcon()
          Returns an Icon that can be used for a button to create this type of ROI.
static InteractionType getCreateInteractionType()
          Returns the type of interaction needed to create a ContouredROI.
 java.lang.String getDescription()
          Return a description of this type of ROI.
static java.util.List<ContourROI> getInstances(java.lang.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.
static java.util.List<ROI> getInstances(javax.vecmath.Point3i startPoint, ContourMode contourMode, double level, IntensityRelation intensityRelation, boolean threeDEdgeDetection, boolean threeDPropagation, int plusMinusSlices, java.lang.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)
          Create a ContourROI by contouring from a start point on the image.
 double getLevel()
          Returns the intensity level that this ContourROI followed.
static java.lang.String getName()
          Returns the name of the type of ROI.
static void main(java.lang.String[] args)
          Run the self-test on this class.
 
Methods inherited from class com.xinapse.multisliceimage.roi.IrregularROI
clone, closestPoints, contains, deleteVertex, dilate, draw, drawInOrthoView, equals, erasePoints, flipHorizontal, flipVertical, getCentre, getCopy, getFeret, getFollowingHandle, getNPoints, getPerimeter, getPrecedingHandle, getTheta, getVertex, getVertexHandles, getVertices, hashCode, insertTwoVertices, intersects, join, makeConvex, move, move, moveVertex, selfIntersects, set, setTheta, setVertex, setVertices, setVertices, setVertices, setVertices, toString
 
Methods inherited from class com.xinapse.multisliceimage.roi.ROI
add, add, addMorphological, clearDeletionHistory, clearStats, dilate, exclusiveOr, getAnnotation, getBoundingRectangle, getBoundingRectangle, getCachedStatistics, getClasses, getColor, getDisplayedBounds2D, getDisplayedBounds2D, getDisplayedRoiArea, getFeret, getHandles, getHandleUnderPoint, getImageSource, getPixelValue, getROIs, getROIs, getROIs, getSlice, getState, getStats, getStats, getStats, getTextColor, getTextFontSize, getUserColour, intersect, isDeleted, isEditable, isReloaded, isSelected, join, markDeleted, mmPosToPix, moveROIs, pixPosToMm, printStats, selectDeselect, setAnnotation, setCreationHistory, setSlice, setState, setTextColor, setTextSize, setUserColour, subtract, subtract, write, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.xinapse.multisliceimage.roi.StretchableROI
getDisplayedBounds2D
 

Field Detail

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:
Constant Field Values
Method Detail

getLevel

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


getCreateInteractionType

public static InteractionType getCreateInteractionType()
Returns the type of interaction needed to create a ContouredROI.

Returns:
type of interaction needed to create a ContourROI - InteractionType.CLICK.

getInstances

public static java.util.List<ROI> getInstances(javax.vecmath.Point3i startPoint,
                                               ContourMode contourMode,
                                               double level,
                                               IntensityRelation intensityRelation,
                                               boolean threeDEdgeDetection,
                                               boolean threeDPropagation,
                                               int plusMinusSlices,
                                               java.lang.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 com.xinapse.util.CancelledException to be thrown.
Returns:
a java.util.List<ContourROI> of ContourROIs representing the contour(s) generated from the startPoint. For 2-D contouring, a 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 java.util.List<ContourROI> getInstances(java.lang.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 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.
Returns:
a java.util.List<ROI> of ContourROIs that represent the contours on the image slice.

getDescription

public java.lang.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 java.lang.String getName()
Returns the name of the type of ROI.

Returns:
the name "Contour".

main

public static void main(java.lang.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 javax.swing.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.


Copyright 2006-2011 Xinapse Systems Limited. All Rights Reserved.