Module ij
Package ij.gui

Class Wand

java.lang.Object
ij.gui.Wand

public class Wand
extends java.lang.Object
This class implements ImageJ's wand (tracing) tool. The wand selects pixels of equal or similar value or thresholded pixels forming a contiguous area. The wand creates selections that have only one boundary line (inner holes are not excluded from the selection). There may be holes at the boundary, however, if the boundary line touches the same vertex twice (both in 4-connected and 8-connected mode). Version 2009-06-01 (code refurbished; tolerance, 4- & 8-connected options added)
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int EIGHT_CONNECTED
    Wand operation type: trace outline of 8-connected pixels
    static int FOUR_CONNECTED
    Wand operation type: trace outline of 4-connected pixels
    static int LEGACY_MODE
    Wand operation type similar to that of ImageJ 1.42p and before; for backwards compatibility.
    int npoints
    The number of points in the generated outline.
    int[] xpoints
    The x-coordinates of the points in the outline.
    int[] ypoints
    The y-coordinates of the points in the outline.
  • Constructor Summary

    Constructors 
    Constructor Description
    Wand​(ImageProcessor ip)
    Constructs a Wand object from an ImageProcessor.
  • Method Summary

    Modifier and Type Method Description
    static boolean allPoints()
    Returns 'true' if output contains intermediate points for straight lines longer than one pixel.
    void autoOutline​(int startX, int startY)
    Traces the boundary of an area of uniform color, where 'startX' and 'startY' are somewhere inside the area.
    void autoOutline​(int startX, int startY, double lower, double upper)
    Traces an object defined by lower and upper threshold values or an interior hole; whatever is found first ('legacy mode').
    void autoOutline​(int startX, int startY, double lower, double upper, int mode)
    Traces an object defined by lower and upper threshold values.
    void autoOutline​(int startX, int startY, double tolerance, int mode)
    Traces the boundary of the area with pixel values within 'tolerance' of the value of the pixel at the starting location.
    void autoOutline​(int startX, int startY, int lower, int upper)
    This is a variation of legacy autoOutline that uses int threshold arguments.
    static void setAllPoints​(boolean b)
    Set 'true' and output will contain intermediate points for straight lines longer than one pixel.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FOUR_CONNECTED

      public static final int FOUR_CONNECTED
      Wand operation type: trace outline of 4-connected pixels
      See Also:
      Constant Field Values
    • EIGHT_CONNECTED

      public static final int EIGHT_CONNECTED
      Wand operation type: trace outline of 8-connected pixels
      See Also:
      Constant Field Values
    • LEGACY_MODE

      public static final int LEGACY_MODE
      Wand operation type similar to that of ImageJ 1.42p and before; for backwards compatibility. In this mode, no checking is done whether the foreground or the background gets selected; four- or 8-connected behaviour depends on foreground/background and (if no selection) on whether the initial pixel is on a 1-pixel wide line.
      See Also:
      Constant Field Values
    • npoints

      public int npoints
      The number of points in the generated outline.
    • xpoints

      public int[] xpoints
      The x-coordinates of the points in the outline. A vertical boundary at x separates the pixels at x-1 and x.
    • ypoints

      public int[] ypoints
      The y-coordinates of the points in the outline. A horizontal boundary at y separates the pixels at y-1 and y.
  • Constructor Details

    • Wand

      public Wand​(ImageProcessor ip)
      Constructs a Wand object from an ImageProcessor.
  • Method Details

    • autoOutline

      public void autoOutline​(int startX, int startY, double lower, double upper, int mode)
      Traces an object defined by lower and upper threshold values. 'mode' can be FOUR_CONNECTED or EIGHT_CONNECTED. ('LEGACY_MODE' is also supported and may result in selection of interior holes instead of the thresholded area if one clicks left of an interior hole). The start coordinates must be inside the area or left of it. When successful, npoints>0 and the boundary points can be accessed in the public xpoints and ypoints fields.
    • autoOutline

      public void autoOutline​(int startX, int startY, double lower, double upper)
      Traces an object defined by lower and upper threshold values or an interior hole; whatever is found first ('legacy mode'). For compatibility with previous versions of ImageJ. The start coordinates must be inside the area or left of it. When successful, npoints>0 and the boundary points can be accessed in the public xpoints and ypoints fields.
    • autoOutline

      public void autoOutline​(int startX, int startY, int lower, int upper)
      This is a variation of legacy autoOutline that uses int threshold arguments.
    • autoOutline

      public void autoOutline​(int startX, int startY)
      Traces the boundary of an area of uniform color, where 'startX' and 'startY' are somewhere inside the area. When successful, npoints>0 and the boundary points can be accessed in the public xpoints and ypoints fields. For compatibility with previous versions of ImageJ only; otherwise use the reliable method specifying 4-connected or 8-connected mode and the tolerance.
    • autoOutline

      public void autoOutline​(int startX, int startY, double tolerance, int mode)
      Traces the boundary of the area with pixel values within 'tolerance' of the value of the pixel at the starting location. 'tolerance' is in uncalibrated units. 'mode' can be FOUR_CONNECTED or EIGHT_CONNECTED. Mode LEGACY_MODE is for compatibility with previous versions of ImageJ; ignored if tolerance > 0. Mode bit THRESHOLDED_MODE for internal use only; it is set by autoOutline with 'upper' and 'lower' arguments. When successful, npoints>0 and the boundary points can be accessed in the public xpoints and ypoints fields.
    • setAllPoints

      public static void setAllPoints​(boolean b)
      Set 'true' and output will contain intermediate points for straight lines longer than one pixel.
    • allPoints

      public static boolean allPoints()
      Returns 'true' if output contains intermediate points for straight lines longer than one pixel.