Class OpenSplineROI

All Implemented Interfaces:
EditableOutlineROI, LinearROI, RegularROI, RotatableROI, StretchableROI, Cloneable

public class OpenSplineROI extends SplineROI implements Cloneable, StretchableROI, RotatableROI, EditableOutlineROI, LinearROI, RegularROI
A Class representing a curved line on an image, represented by a set of knots, with spline interpolators between the knots to define the shape of the curve.
  • Constructor Details

    • OpenSplineROI

      public OpenSplineROI(double[] x, double[] y, ROIState state) throws ROIException
      Creates a new OpenSplineROI with the specified knot points in mm coordinates.
      Parameters:
      x - an array of x-coordinates for the knot points.
      y - an array of y-coordinates for the knot points.
      state - the ROIState of the newly-created ROI.
      Throws:
      ROIException - if the OpenSplineROI cannot be created as specified.
    • OpenSplineROI

      public OpenSplineROI(double[] x, double[] y, byte userColour, ROIState state, boolean checkIntegrity) throws ROIException
      Creates a new OpenSplineROI with the specified knot points in mm coordinates.
      Parameters:
      x - an array of x-coordinates for the knot points.
      y - an array of y-coordinates for the knot points.
      userColour - the colour of this ROI. A value of 0 indicates that the ROI will be drawn with the default colour for normal ROIs if unselected.
      state - the ROIState of the newly-created ROI.
      checkIntegrity - whether to check the integrity of the ROI.
      Throws:
      ROIException - if the OpenSplineROI cannot be created as specified.
    • OpenSplineROI

      public OpenSplineROI(SplineROI splineROI) throws ROIException
      Creates a new OpenSplineROI with the positions of the knot points taken from the supplied SplineROI.
      Parameters:
      splineROI - the SplineROI from which the knot point positions will be taken.
      Throws:
      ROIException - if the OpenSplineROI cannot be created as specified.
  • Method Details

    • getSquareArea

      public double getSquareArea()
      Returns zero - an Open Spline has no area.
      Specified by:
      getSquareArea in interface RegularROI
      Returns:
      zero.
    • getLength

      public double getLength()
      Description copied from interface: LinearROI
      Returns the length of this ROI in mm.
      Specified by:
      getLength in interface LinearROI
      Returns:
      the length of this ROI in mm.
    • getLengthPix

      public double getLengthPix(float pixelXSize, float pixelYSize)
      Description copied from interface: LinearROI
      Returns the length of this ROI in image pixels.
      Specified by:
      getLengthPix in interface LinearROI
      Parameters:
      pixelXSize - the size of image pixels in the horizontal direction.
      pixelYSize - the size of image pixels in the vertical direction.
      Returns:
      the length of this ROI in image pixels.
    • getIntensityProfile

      public Point2D[] getIntensityProfile(Object pix, PixelDataType dataType, int nCols, int nRows, int offset, float pixelXSize, float pixelYSize, ComplexMode complexMode)
      Description copied from interface: LinearROI
      Returns an array of Point2D representing the pixel intensities along this LinearROI. The x-value of a point is a position along the LinearROI, and the y-value is the intensity. The first and last points will be at the ends of the LinearROI, but the location of the points in between is not prescribed by this interface.
      Specified by:
      getIntensityProfile in interface LinearROI
      Parameters:
      pix - the array of pixel intensities for in which this LinearROI is positioned.
      dataType - the PixelDataType of the array of pixel intensities.
      nCols - the number of columns in the slice.
      nRows - the number of rows in the slice.
      offset - an offset (in pixels) into the pixel value array for the starting pixel of the slice on which this ROI is defined.
      pixelXSize - the size of image pixels in the horizontal direction.
      pixelYSize - the size of image pixels in the vertical direction.
      complexMode - the calculation mode for Complex images. The intensity profile returned will correspond to the mode: the real part, imaginary part, magnitude or phase.
      Returns:
      an array of Point2D representing the pixel intensities along this LinearROI.
    • getStats

      public ROIStats getStats(Object pix, PixelDataType dataType, int nCols, int nRows, int offset, float pixelXSize, float pixelYSize, MaskAction maskAction, MaskMode maskMode, double maskValue, PrintStream intensityOutputStream, boolean isUnitsMM, ComplexMode complexMode)
      Description copied from class: ROI
      Returns statistics about this ROI, and (optionally) performs a masking operation.
      Overrides:
      getStats in class ROI
      Parameters:
      pix - the whole image pixel value array. If pix is null, then the intensity-related stats will all be set to zero.
      dataType - the type of pixels.
      nCols - the number of columns in the slice.
      nRows - the number of rows in the slice.
      offset - an offset (in pixels) into the pixel value array for the starting pixel of the slice on which this ROI is defined.
      pixelXSize - the size of image pixels in the horizontal direction.
      pixelYSize - the size of image pixels in the vertical direction.
      maskAction - one of:
      maskMode - how much of a pixel must be inside ROIs for the pixel to be part of the mask.
      maskValue - the pixel value to set outside/inside the shape when performing masking ops.
      intensityOutputStream - if non-null, pixel intensities within the ROI will be printed to this PrintStream.
      isUnitsMM - true if the (x,y) coordinates of the pixel intensities are to be written in mm, false if the coordinates are to be writtn in pixel units.
      complexMode - the calculation mode for PixelDataType.COMPLEX images. The statistics returned will correspond to the mode: the real part, imaginary part, magnitude or phase.
      Returns:
      statistics about the ROI.
    • toIrregular

      public CurvedLineROI toIrregular()
      Creates a new CurvedLineROI that is close to the shape of this OpenSplineROI.
      Overrides:
      toIrregular in class SplineROI
      Returns:
      a new CurvedLineROI that is close to the shape of this OpenSplineROI.
    • alignKnots

      public static void alignKnots(OpenSplineROI s1, OpenSplineROI s2, int nKnots) throws ROIException
      Aligns the knot points in a pair of OpenSplineROIs, so that there is spatial correspondence as far as possible across the knots.

      The number of knot points in each of the ROIs will be set to the specified number of knot points, and the knots will be evenly spaced in the s-parameter.

      Parameters:
      s1 - the first OpenSplineROI to align.
      s2 - the second OpenSplineROI to align.
      nKnots - the number of knot points in the aligned ROIs.
      Throws:
      ROIException - if the ROIs cannot be aligned.
    • getCopy

      public ROI getCopy()
      Description copied from class: ROI
      Returns a copy of this ROI. The copy will be identical in shape and annotation as the original ROI, but with a history of that of a newly-created ROI.
      Overrides:
      getCopy in class SplineROI
      Returns:
      a copy of this ROI.
    • clone

      public OpenSplineROI clone()
      Description copied from class: ROI
      Returns a clone of this ROI. The copy will be identical in shape and annotation as the original ROI, and with a history identical to the cloned ROI.
      Overrides:
      clone in class SplineROI
      Returns:
      a clone of this ROI, cast to an Object.
    • toString

      public String toString()
      Description copied from class: ROI
      Returns a String describing this ROI.
      Overrides:
      toString in class SplineROI
      Returns:
      a String describing this ROI.
    • getDescription

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

      public static InteractionType getCreateInteractionType()
      Returns the type of interaction needed to create an OpenSplineROI.
      Returns:
      type of interaction needed to create an OpenSplineROI - InteractionType.CLICK_POINTS.
    • getName

      public static String getName()
      Returns a descriptive name for this type of ROI.
      Returns:
      a String describing this type of ROI.
    • 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.