Package qupath.process.gui
Class WandToolEventHandler
java.lang.Object
qupath.lib.gui.viewer.tools.handlers.BrushToolEventHandler
qupath.process.gui.WandToolEventHandler
- All Implemented Interfaces:
EventListener
,EventHandler<MouseEvent>
Wand tool, which acts rather like the brush - except that it expands regions
(sometimes rather too eagerly?) based upon local pixel values.
- Author:
- Pete Bankhead
-
Property Summary
TypePropertyDescriptionstatic DoubleProperty
Property representing the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.static DoubleProperty
Property representing the Gaussian sigma value used to smooth the image when applying the wand.Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.static BooleanProperty
Property specifying whether the wand tool should be influenced by pixel values painted on image overlays. -
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static enum
Enum reflecting different color images that may be used by the Wand tool. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected PathObject
createNewAnnotation
(MouseEvent e, double x, double y) Create a new annotation and set it in the current viewer.protected Geometry
createShape
(MouseEvent e, double x, double y, boolean useTiles, Geometry addToShape) Create a new Geometry using the specified tool, assuming a user click/drag at the provided x & y coordinates.protected void
ensureCursorType
(Cursor cursor) Ensure that the specified cursor is set in the current viewer.protected double
Don't actually need the diameter for calculations here, but it's helpful for setting the cursorprotected PathObject
protected QuPathViewer
static double
Query the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.static double
Query the Gaussian sigma value used to smooth the image when applying the wand.static boolean
Query whether the wand tool should be influenced by pixel values painted on image overlays.void
handle
(MouseEvent event) void
protected Point2D
mouseLocationToImage
(MouseEvent e, boolean constrainToBounds, boolean snapToPixel) protected Geometry
refineGeometryByParent
(Geometry geometry) protected ROI
refineROIByParent
(ROI currentROI) Apply clipping based on the current parent object.protected boolean
Query whether parent clipping should be applied.protected boolean
Returns true if the tool requests that pixel coordinates be snapped to integer values.protected void
Reset the constraining objects.static void
setWandSensitivity
(double sensitivity) Set the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.static void
setWandSigmaPixels
(double sigma) Set the Gaussian sigma value used to smooth the image when applying the wand.static void
setWandUseOverlays
(boolean useOverlays) Set whether the wand tool should be influenced by pixel values painted on image overlays.protected void
updatingConstrainingObjects
(QuPathViewer viewer, double xx, double yy, Collection<PathObject> exclusions) New annotations can be constrained while they are being drawn, to avoid overlaps with existing annotations or to ensure they are drawn within a parent annotation.static DoubleProperty
Property representing the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.static DoubleProperty
Property representing the Gaussian sigma value used to smooth the image when applying the wand.Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.static BooleanProperty
Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.Methods inherited from class qupath.lib.gui.viewer.tools.handlers.BrushToolEventHandler
createNewROI, getGeometryFactory, getRequestedCursor, isSubtractMode, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, preferReturnToMove
-
Property Details
-
wandType
Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.- See Also:
-
wandUseOverlays
Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.- See Also:
-
wandSigmaPixels
Property representing the Gaussian sigma value used to smooth the image when applying the wand.- See Also:
-
wandSensitivity
Property representing the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.- See Also:
-
-
Constructor Details
-
WandToolEventHandler
Constructor.- Parameters:
qupath
-
-
-
Method Details
-
wandTypeProperty
Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.- Returns:
-
wandUseOverlaysProperty
Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.- Returns:
- See Also:
-
getWandUseOverlays
public static boolean getWandUseOverlays()Query whether the wand tool should be influenced by pixel values painted on image overlays.If false, only RGB values of the underlying image will be used.
- Returns:
-
setWandUseOverlays
public static void setWandUseOverlays(boolean useOverlays) Set whether the wand tool should be influenced by pixel values painted on image overlays. If false, only RGB values of the underlying image will be used.- Parameters:
useOverlays
-
-
wandSigmaPixelsProperty
Property representing the Gaussian sigma value used to smooth the image when applying the wand.- Returns:
- See Also:
-
getWandSigmaPixels
public static double getWandSigmaPixels()Query the Gaussian sigma value used to smooth the image when applying the wand.- Returns:
-
setWandSigmaPixels
public static void setWandSigmaPixels(double sigma) Set the Gaussian sigma value used to smooth the image when applying the wand.- Parameters:
sigma
-
-
wandSensitivityProperty
Property representing the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.- Returns:
- See Also:
-
getWandSensitivity
public static double getWandSensitivity()Query the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.- Returns:
-
setWandSensitivity
public static void setWandSensitivity(double sensitivity) Set the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.- Parameters:
sensitivity
-
-
createShape
protected Geometry createShape(MouseEvent e, double x, double y, boolean useTiles, Geometry addToShape) Description copied from class:BrushToolEventHandler
Create a new Geometry using the specified tool, assuming a user click/drag at the provided x & y coordinates.- Overrides:
createShape
in classBrushToolEventHandler
- Parameters:
e
-x
-y
-useTiles
- If true, request generating a shape from existing tile objects.addToShape
- If provided, it can be assumed that any new shape ought to be added to this one. The purpose is that this method may (optionally) use the shape to refine the one it will generate, e.g. to avoid having isolated or jagged boundaries.- Returns:
-
getBrushDiameter
protected double getBrushDiameter()Don't actually need the diameter for calculations here, but it's helpful for setting the cursor- Overrides:
getBrushDiameter
in classBrushToolEventHandler
-
createNewAnnotation
Create a new annotation and set it in the current viewer.- Parameters:
e
-x
-y
-- Returns:
-
ensureCursorType
Ensure that the specified cursor is set in the current viewer.- Parameters:
cursor
-
-
requestPixelSnapping
protected boolean requestPixelSnapping()Returns true if the tool requests that pixel coordinates be snapped to integer values. Default returns true.- Returns:
-
getViewer
-
mouseLocationToImage
protected Point2D mouseLocationToImage(MouseEvent e, boolean constrainToBounds, boolean snapToPixel) -
requestParentClipping
Query whether parent clipping should be applied.This might depend upon the MouseEvent.
- Parameters:
e
-- Returns:
-
refineROIByParent
Apply clipping based on the current parent object.Returns an empty ROI if this result of the clipping is an empty area.
- Parameters:
currentROI
-- Returns:
-
refineGeometryByParent
-
updatingConstrainingObjects
protected void updatingConstrainingObjects(QuPathViewer viewer, double xx, double yy, Collection<PathObject> exclusions) New annotations can be constrained while they are being drawn, to avoid overlaps with existing annotations or to ensure they are drawn within a parent annotation.This method requests that the constraining objects are identified now based upon the specified mouse position. It is useful when starting to draw with a tool that makes use of constraining objects.
- Parameters:
viewer
- the viewer that may contain potential constraining objectsxx
- x-coordinate in the image space of the starting point for the new objectyy
- y-coordinate in the image space of the starting point for the new objectexclusions
- objects not to consider (e.g. the new ROI being created)
-
resetConstrainingObjects
protected void resetConstrainingObjects()Reset the constraining objects. These should be done as soon as they are no longer required, to prevent a memory leak by inadvertently holding on to an object hierarchy too long. -
getCurrentParent
-
mouseClicked
-
handle
- Specified by:
handle
in interfaceEventHandler<MouseEvent>
-