Package com.xinapse.multisliceimage.roi
Class CurvedLineROI
java.lang.Object
com.xinapse.multisliceimage.roi.ROI
com.xinapse.multisliceimage.roi.IrregularROI
com.xinapse.multisliceimage.roi.CurvedLineROI
- All Implemented Interfaces:
EditableOutlineROI,LinearROI,RegularROI,RotatableROI,StretchableROI,Cloneable
A represention of a planar curved line on an image. A CurvedLineROI is made up on multiple
straight-line segments.
-
Field Summary
Fields inherited from class com.xinapse.multisliceimage.roi.IrregularROI
nPoints, POINTSTOKEN, xpts, yptsFields inherited from class com.xinapse.multisliceimage.roi.ROI
BUTTON_ICON_SIZE, handles, PREFERENCES_NODE_NAME, XTOKEN, YTOKEN -
Constructor Summary
ConstructorsConstructorDescriptionCurvedLineROI(double[] x, double[] y, int n, ROIState state) Creates a new CurvedLineROI with the coordinates of the points forming the line given by the x and y arrays in mm coordinates.CurvedLineROI(List<Point2D.Double> pointsList, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, ROIState state) Creates a new CurvedLineROI with the coordinates of the points forming the line given by the List of points in image pixel coordinates.CurvedLineROI(List<Point2D.Double> pointsList, ROIState state) Creates a new CurvedLineROI with the coordinates of the points forming the line given by the List of points in mm coordinates. -
Method Summary
Modifier and TypeMethodDescriptionandNot(ROI roi, IndeterminateProgressMonitor progressMonitor) Logically AND NOTs (subtracts) an ROI from this ROI to create a newjava.util.List<ROI>of ROIs that is the result of subtracting the shape of the supplied ROI from this ROI.clone()Returns a clone of thisROI.booleanIndicates whether thisCurvedLineROIcontains anotherROIentirely within its borders.booleandeleteVertex(Handle handle) Delete a point on the outline of this EditableOutlineROI that is under a handle.booleandraw(Graphics g, Rectangle visibleRectangle, int imageDrawCols, int imageDrawRows, int xOffset, int yOffset, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean drawAnnotation) Draws thisROIif it needs to be be drawn on screen.erasePoints(List<Point2D> erasePoints, float size, int nCols, int nRows, float pixelXSize, float pixelYSize) Erase points from this CurvedLineROI.exclusiveOr(ROI roi, IndeterminateProgressMonitor progressMonitor) Performs an exclusive OR operation on the shape of this ROI with another ROI.static IconReturns an Icon that can be used for a button to create this type of ROI.org.jogamp.vecmath.Point2dReturns the centroid (centre of area) of thisROI.getCopy()Returns a copy of thisROI.static InteractionTypeReturns the type of interaction needed to create a CurvedLineROI.Return a description of this type ofROI.getFollowingVisibleHandle(Handle handle) Returns the visible Handle that is immediately after the specified handle, in the order in which they were placed around the ROI.Point2D[]getIntensityProfile(Object pix, PixelDataType dataType, int nCols, int nRows, int offset, float pixelXSize, float pixelYSize, ComplexMode complexMode) doubleReturns the length of this ROI in mm.doublegetLengthPix(float pixelXSize, float pixelYSize) Returns the length of this ROI in image pixels.static StringgetName()Returns a descriptive name for this type of ROI.doubleReturns the perimeter length of this ROI.getPrecedingVisibleHandle(Handle handle) Returns the visible Handle that is immediately before the specified handle, in the order in which they were placed around the ROI.doubleReturns zero - a curved line has no area.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) Returns statistics about thisROI, and (optionally) performs a masking operation.inthashCode()Returns a hash code value for thisCurvedLineROI.booleaninsertTwoVertices(Handle handle) Insert two points into the outline of this EditableOutlineROI: one just before the one that is under a handle, and one just after.intersect(ROI roi, IndeterminateProgressMonitor progressMonitor) Performs an intersection operation on the shape of this ROI with another ROI.voidmakeConvex(CanAddROIToFrame canAddROIToFrame, float pixelXSize, float pixelYSize, float minConcaveRadius) Make this IrregularROI convex, or at least less concave.voidmove(double dx, double dy) Move thisROIby specified distances (in mm) in the x and y directions.voidmoveVertex(Point2D newPos, Handle handle, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean pixelSnap) Move a point on the outline of this EditableOutlineROI to a new position.union(ROI roi, IndeterminateProgressMonitor progressMonitor) Logically add (forms the union) an ROI to this ROI to create a newjava.util.List<ROI>of ROIs that is the result of adding the shapes of the two ROIs.Methods inherited from class com.xinapse.multisliceimage.roi.IrregularROI
closestPoints, containsVertex, drawInOrthoView, equals, flipHorizontal, flipVertical, getCentre, getFeret, getNormal, getNPoints, getPrincipalAxisAngle, getTheta, getVertex, getVertexHandles, getVertices, join, main, makeConvex, move, orderPoints, removeSelfIntersections, selfIntersects, set, setTheta, setVertex, setVertices, setVertices, setVertices, setVertices, simplify, toSpline, toSpline, toStringMethods inherited from class com.xinapse.multisliceimage.roi.ROI
andNot, andNot, clearDeletionHistory, dilate, exclusiveOr, getAnnotation, getBoundingRectangle, getBoundingRectangle, getCentroid, getClasses, getColor, getDesignTextFontSize, getDisplayedBounds2D, getDisplayedBounds2D, getDisplayedRoiArea, getFeret, getGroupUid, getGroupUid, getHandles, getHandleUnderPoint, getImageSource, getPixelValue, getROIs, getROIs, getROIs, getROIs, getROIs, getSlice, getState, getStats, getStats, getTextColor, getUserColour, group, intersect, intersect, intersects, isDeleted, isEditable, isGroup, isReloaded, isSameAnnotation, isSameColour, isSelected, join, logicalUnion, markDeleted, mmPosToPix, moveROIs, pixPosToMm, printStats, selectDeselect, setAnnotation, setCreationHistory, setGroupUid, setSlice, setState, setTextColor, setTextSize, setUserColour, ungroup, ungroup, union, write, writeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.xinapse.multisliceimage.roi.StretchableROI
getDisplayedBounds2D
-
Constructor Details
-
CurvedLineROI
Creates a new CurvedLineROI with the coordinates of the points forming the line given by the x and y arrays in mm coordinates.- Parameters:
x- an array of x-coordinates for the points forming the line.y- an array of y-coordinates for the points forming the line.n- the number points to be taken from the x and y arrays - must be less than or equal to then length of the smallest array.state- the ROIState of the newly-created ROI.- Throws:
ROIException- if the ROI cannot be created as requested.
-
CurvedLineROI
Creates a new CurvedLineROI with the coordinates of the points forming the line given by the List of points in mm coordinates.- Parameters:
pointsList- a List of points forming the line.state- the ROIState of the newly-created ROI.- Throws:
ROIException- if the ROI cannot be created as requested.
-
CurvedLineROI
public CurvedLineROI(List<Point2D.Double> pointsList, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, ROIState state) throws ROIException Creates a new CurvedLineROI with the coordinates of the points forming the line given by the List of points in image pixel coordinates.- Parameters:
pointsList- a List of points forming the line.nCols- the number of columns in the image.nRows- the number of rows in the image.pixelXSize- the width of an image pixel in mm.pixelYSize- the height of an image pixel in mm.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.- Throws:
ROIException- if the ROI cannot be created as requested.
-
-
Method Details
-
getCreateInteractionType
Returns the type of interaction needed to create a CurvedLineROI.- Returns:
- type of interaction needed to create a CurvedLineROI - InteractionType.CLICK_OUTLINE.
-
move
public void move(double dx, double dy) Description copied from class:ROIMove thisROIby specified distances (in mm) in the x and y directions.- Overrides:
movein classIrregularROI- Parameters:
dx- the distance to move in the x-direction.dy- the distance to move in the y-direction.
-
getPrecedingVisibleHandle
Description copied from interface:EditableOutlineROIReturns the visible Handle that is immediately before the specified handle, in the order in which they were placed around the ROI.- Specified by:
getPrecedingVisibleHandlein interfaceEditableOutlineROI- Overrides:
getPrecedingVisibleHandlein classIrregularROI- Parameters:
handle- the handle for which to get the preceding handle.- Returns:
- the preceding visible Handle, or null if there is no preceding visible handle.
-
getFollowingVisibleHandle
Description copied from interface:EditableOutlineROIReturns the visible Handle that is immediately after the specified handle, in the order in which they were placed around the ROI.- Specified by:
getFollowingVisibleHandlein interfaceEditableOutlineROI- Overrides:
getFollowingVisibleHandlein classIrregularROI- Parameters:
handle- the handle for which to get the following handle.- Returns:
- the following visible Handle, or null if there is no following visible handle.
-
moveVertex
public void moveVertex(Point2D newPos, Handle handle, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean pixelSnap) throws ROIException Description copied from interface:EditableOutlineROIMove a point on the outline of this EditableOutlineROI to a new position.- Specified by:
moveVertexin interfaceEditableOutlineROI- Overrides:
moveVertexin classIrregularROI- Parameters:
newPos- the new location of the vertex in real-space coordinates.handle- the Handle that the user has grabbed, used to identify the vertex to be moved.nCols- the number of image columns.nRows- the number of image rows.pixelXSize- the pixel width in mm.pixelYSize- the pixel height in mm.pixelSnap- whether pixel snap is turned on.- Throws:
ROIException- if the vertex cannot be moved to the requested position.
-
getSquareArea
public double getSquareArea()Returns zero - a curved line has no area.- Specified by:
getSquareAreain interfaceRegularROI- Returns:
- zero.
-
deleteVertex
Description copied from interface:EditableOutlineROIDelete a point on the outline of this EditableOutlineROI that is under a handle.- Specified by:
deleteVertexin interfaceEditableOutlineROI- Overrides:
deleteVertexin classIrregularROI- Parameters:
handle- the Handle that the user has grabbed, used to identify the vertex to be deleted.- Returns:
- true if a point is successfully deleted.
-
insertTwoVertices
Description copied from interface:EditableOutlineROIInsert two points into the outline of this EditableOutlineROI: one just before the one that is under a handle, and one just after.- Specified by:
insertTwoVerticesin interfaceEditableOutlineROI- Overrides:
insertTwoVerticesin classIrregularROI- Parameters:
handle- the Handle that the user has grabbed, used to identify the vertex around which the new vertices are to be placed.- Returns:
- true if a point is successfully inserted.
-
erasePoints
public List<IrregularROI> erasePoints(List<Point2D> erasePoints, float size, int nCols, int nRows, float pixelXSize, float pixelYSize) Erase points from this CurvedLineROI. erasePoints may edit this CurvedLineROI by deleting points, or it may split this CurvedLineROI into two or more new CurvedLineROIs. If more than one CurvedLineROI is returned, then the (edited) original CurvedLineROI will be in the list of returned CurvedLineROIs, and will be the remaining CurvedLineROI which is biggest (has the most points).- Overrides:
erasePointsin classIrregularROI- Parameters:
erasePoints- a List of points through which the erasing pen has passed.size- the size of the erasing pen in mm.nCols- the number of image columns.nRows- the number of image rows.pixelXSize- the pixel width in mm.pixelYSize- the pixel height in mm.- Returns:
- a List of CurvedLineROIs resulting from the points erasure.
-
makeConvex
public void makeConvex(CanAddROIToFrame canAddROIToFrame, float pixelXSize, float pixelYSize, float minConcaveRadius) Description copied from class:IrregularROIMake this IrregularROI convex, or at least less concave. The supplied pixel sizes are used to decide on the separation between data points around the IrregularROI. A minimum radius of curvature for concave radii of curvature is given. The action of making the ROI convex will be executed asynchronously using aSwingWorkerthat will update theImageDisplayerwhen finished.- Overrides:
makeConvexin classIrregularROI- Parameters:
canAddROIToFrame- theCanAddROIToFrameto be updated when the operation is complete.pixelXSize- the width of an image pixel in mm.pixelYSize- the height of an image pixel in mm.minConcaveRadius- the minimum radius of curvature for concave parts of thisROI.
-
getLength
public double getLength()Description copied from interface:LinearROIReturns the length of this ROI in mm. -
getLengthPix
public double getLengthPix(float pixelXSize, float pixelYSize) Description copied from interface:LinearROIReturns the length of this ROI in image pixels.- Specified by:
getLengthPixin interfaceLinearROI- 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:LinearROIReturns an array ofPoint2Drepresenting the pixel intensities along thisLinearROI. The x-value of a point is a position along theLinearROI, and the y-value is the intensity. The first and last points will be at the ends of theLinearROI, but the location of the points in between is not prescribed by this interface.- Specified by:
getIntensityProfilein interfaceLinearROI- Parameters:
pix- the array of pixel intensities for in which thisLinearROIis positioned.dataType- thePixelDataTypeof 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
Point2Drepresenting the pixel intensities along this LinearROI.
-
getPerimeter
public double getPerimeter()Returns the perimeter length of this ROI. The perimeter of a CurvedLineROI is defined as twice its length.- Overrides:
getPerimeterin classIrregularROI- Returns:
- the perimeter length of this ROI.
-
getCentroid
public org.jogamp.vecmath.Point2d getCentroid()Description copied from class:ROIReturns the centroid (centre of area) of thisROI.- Overrides:
getCentroidin classIrregularROI- Returns:
- the centroid of this
ROI.
-
union
Description copied from class:ROILogically add (forms the union) an ROI to this ROI to create a newjava.util.List<ROI>of ROIs that is the result of adding the shapes of the two ROIs. -
andNot
Description copied from class:ROILogically AND NOTs (subtracts) an ROI from this ROI to create a newjava.util.List<ROI>of ROIs that is the result of subtracting the shape of the supplied ROI from this ROI. -
intersect
Description copied from class:ROIPerforms an intersection operation on the shape of this ROI with another ROI.- Overrides:
intersectin classIrregularROI- Parameters:
roi- the ROI with which to perform the intersection operation.progressMonitor- if non-null, the IndeterminateProgressMonitor that can be used to cancel the operation.- Returns:
- a List<ROI> of ROIs that result from the operation.
-
exclusiveOr
Description copied from class:ROIPerforms an exclusive OR operation on the shape of this ROI with another ROI.- Overrides:
exclusiveOrin classROI- Parameters:
roi- the ROI with which to perform the XOR operation.progressMonitor- if non-null, the IndeterminateProgressMonitor that can be used to cancel the operation.- Returns:
- a List<ROI> of ROIs that result from the operation.
-
draw
public boolean draw(Graphics g, Rectangle visibleRectangle, int imageDrawCols, int imageDrawRows, int xOffset, int yOffset, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean drawAnnotation) Description copied from class:ROIDraws thisROIif it needs to be be drawn on screen.- Overrides:
drawin classIrregularROI- Parameters:
g- the graphics context for the drawing operation.visibleRectangle- the part of the image that can be seen on-screen.imageDrawCols- width of the area in which this portion of the image is to be drawn.imageDrawRows- height of the area in which this portion of the image is to be drawn.xOffset- a horizontal offset for drawing operations.yOffset- a vertical offset for drawing operations.nCols- the number of columns in the image on which thisROIis defined.nRows- the number of rows in the image on which thisROIis defined.pixelXSize- pixel width for the image on which thisROIis defined.pixelYSize- pixel height for the image on which thisROIis defined.drawAnnotation- a flag to indicate whether annotation should be drawn.- Returns:
trueif theROIis visible and been drawn on screen;falseotherwise.
-
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:ROIReturns statistics about thisROI, and (optionally) performs a masking operation.- Overrides:
getStatsin classROI- 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 thisROIis defined.pixelXSize- the size of image pixels in the horizontal direction.pixelYSize- the size of image pixels in the vertical direction.maskAction- one of:MaskAction.NONEfor no masking;MaskAction.MASK_INSIDEto set pixel values to maskValue inside the shape; orMaskAction.MASK_OUTSIDEto set the pixel values to maskValue outside the shape.MaskAction.MASK_INSIDE_SOFTto perform soft masking inside the shape;MaskAction.MASK_OUTSIDE_SOFTto perform soft masking outside the shape.
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 thisPrintStream.isUnitsMM-trueif the (x,y) coordinates of the pixel intensities are to be written in mm,falseif the coordinates are to be writtn in pixel units.complexMode- the calculation mode forPixelDataType.COMPLEXimages. The statistics returned will correspond to the mode: the real part, imaginary part, magnitude or phase.- Returns:
- statistics about the ROI.
-
contains
Indicates whether thisCurvedLineROIcontains anotherROIentirely within its borders. ACurvedLineROInever contains anotherROI, since it has zero area.- Overrides:
containsin classIrregularROI- Parameters:
roi- theROIto be tested for containment within thisROI.- Returns:
falsealways.
-
hashCode
public int hashCode()Returns a hash code value for thisCurvedLineROI.- Overrides:
hashCodein classIrregularROI- Returns:
- a hash code value for this
CurvedLineROI.
-
getCopy
Description copied from class:ROIReturns a copy of thisROI. 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:
getCopyin classIrregularROI- Returns:
- a copy of this ROI.
-
clone
Description copied from class:ROIReturns a clone of thisROI. The copy will be identical in shape and annotation as the original ROI, and with a history identical to the clonedROI.- Overrides:
clonein classIrregularROI- Returns:
- a clone of this
ROI, cast to anObject.
-
getDescription
Description copied from class:ROIReturn a description of this type ofROI.- Overrides:
getDescriptionin classIrregularROI- Returns:
- a String describing the type of this
ROI.
-
getName
Returns a descriptive name for this type of ROI.- Returns:
- a String describing this type of ROI.
-
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.
-