Class ParticleAnalyzer

java.lang.Object
ij.plugin.filter.ParticleAnalyzer
All Implemented Interfaces:
Measurements, PlugInFilter

public class ParticleAnalyzer extends Object implements PlugInFilter, Measurements
Implements ImageJ's Analyze Particles command.

        for each line do
                for each pixel in this line do
                        if the pixel value is "inside" the threshold range then
                                trace the edge to mark the object
                                do the measurement
                                fill the object with a color outside the threshold range
                        else
                                continue the scan
        
  • Field Details

    • SHOW_RESULTS

      public static final int SHOW_RESULTS
      Display results in the ImageJ console.
      See Also:
    • SHOW_SUMMARY

      public static final int SHOW_SUMMARY
      Obsolete, replaced by DISPLAY_SUMMARY
      See Also:
    • SHOW_OUTLINES

      public static final int SHOW_OUTLINES
      Display image containing outlines of measured particles.
      See Also:
    • EXCLUDE_EDGE_PARTICLES

      public static final int EXCLUDE_EDGE_PARTICLES
      Do not measure particles touching edge of image.
      See Also:
    • SHOW_ROI_MASKS

      public static final int SHOW_ROI_MASKS
      Display image containing grayscales masks that identify measured particles.
      See Also:
    • SHOW_PROGRESS

      public static final int SHOW_PROGRESS
      Display a progress bar.
      See Also:
    • CLEAR_WORKSHEET

      public static final int CLEAR_WORKSHEET
      Clear ImageJ console before starting.
      See Also:
    • RECORD_STARTS

      public static final int RECORD_STARTS
      Record starting coordinates so outline can be recreated later using doWand(x,y).
      See Also:
    • DISPLAY_SUMMARY

      public static final int DISPLAY_SUMMARY
      Display a summary.
      See Also:
    • SHOW_NONE

      public static final int SHOW_NONE
      Do not display particle outline image.
      See Also:
    • INCLUDE_HOLES

      public static final int INCLUDE_HOLES
      Flood fill to ignore interior holes.
      See Also:
    • ADD_TO_MANAGER

      public static final int ADD_TO_MANAGER
      Add particles to ROI Manager.
      See Also:
    • SHOW_MASKS

      public static final int SHOW_MASKS
      Display image containing binary masks of measured particles.
      See Also:
    • FOUR_CONNECTED

      public static final int FOUR_CONNECTED
      Use 4-connected particle tracing.
      See Also:
    • IN_SITU_SHOW

      public static final int IN_SITU_SHOW
      Replace original image with masks.
      See Also:
    • SHOW_OVERLAY_OUTLINES

      public static final int SHOW_OVERLAY_OUTLINES
      Display particle outlines as an overlay.
      See Also:
    • SHOW_OVERLAY_MASKS

      public static final int SHOW_OVERLAY_MASKS
      Display filled particle as an overlay.
      See Also:
    • NOTHING

      protected static final int NOTHING
      See Also:
    • OUTLINES

      protected static final int OUTLINES
      See Also:
    • BARE_OUTLINES

      protected static final int BARE_OUTLINES
      See Also:
    • ELLIPSES

      protected static final int ELLIPSES
      See Also:
    • MASKS

      protected static final int MASKS
      See Also:
    • ROI_MASKS

      protected static final int ROI_MASKS
      See Also:
    • OVERLAY_OUTLINES

      protected static final int OVERLAY_OUTLINES
      See Also:
    • OVERLAY_MASKS

      protected static final int OVERLAY_MASKS
      See Also:
    • staticShowChoice

      protected static int staticShowChoice
    • imp

      protected ImagePlus imp
    • rt

      protected ResultsTable rt
    • analyzer

      protected Analyzer analyzer
    • slice

      protected int slice
    • processStack

      protected boolean processStack
    • showResults

      protected boolean showResults
    • excludeEdgeParticles

      protected boolean excludeEdgeParticles
    • showSizeDistribution

      protected boolean showSizeDistribution
    • resetCounter

      protected boolean resetCounter
    • showProgress

      protected boolean showProgress
    • recordStarts

      protected boolean recordStarts
    • displaySummary

      protected boolean displaySummary
    • floodFill

      protected boolean floodFill
    • addToManager

      protected boolean addToManager
    • inSituShow

      protected boolean inSituShow
  • Constructor Details

    • ParticleAnalyzer

      public ParticleAnalyzer(int options, int measurements, ResultsTable rt, double minSize, double maxSize, double minCirc, double maxCirc)
      Constructs a ParticleAnalyzer.
      Parameters:
      options - a flag word created by Oring SHOW_RESULTS, EXCLUDE_EDGE_PARTICLES, etc.
      measurements - a flag word created by ORing constants defined in the Measurements interface
      rt - a ResultsTable where the measurements will be stored
      minSize - the smallest particle size in pixels
      maxSize - the largest particle size in pixels
      minCirc - minimum circularity
      maxCirc - maximum circularity
    • ParticleAnalyzer

      public ParticleAnalyzer(int options, int measurements, ResultsTable rt, double minSize, double maxSize)
      Constructs a ParticleAnalyzer using the default min and max circularity values (0 and 1).
    • ParticleAnalyzer

      public ParticleAnalyzer()
      Default constructor
  • Method Details

    • setup

      public int setup(String arg, ImagePlus imp)
      Description copied from interface: PlugInFilter
      This method is called once when the filter is loaded. 'arg', which may be blank, is the argument specified for this plugin in IJ_Props.txt or in the plugins.config file of a jar archive containing the plugin. 'imp' is the currently active image. This method should return a flag word that specifies the filters capabilities.

      For Plugin-filters specifying the PlugInFilter.FINAL_PROCESSING flag, the setup method will be called again, this time with arg = "final" after all other processing is done.

      Specified by:
      setup in interface PlugInFilter
    • run

      public void run(ImageProcessor ip)
      Description copied from interface: PlugInFilter
      Filters use this method to process the image. If the PlugInFilter.DOES_STACKS flag was set, it is called for each slice in a stack. With PlugInFilter.CONVERT_TO_FLOAT, the filter is called with the image data converted to a FloatProcessor (3 times per image for RGB images). ImageJ will lock the image before calling this method and unlock it when the filter is finished. For PlugInFilters specifying the PlugInFilter.NO_IMAGE_REQUIRED flag and not the PlugInFilter.DONE flag, run(ip) is called once with the argument null.
      Specified by:
      run in interface PlugInFilter
    • showDialog

      public boolean showDialog()
      Displays a modal options dialog.
    • analyze

      public boolean analyze(ImagePlus imp)
      Performs particle analysis on the specified image. Returns false if there is an error.
    • analyze

      public boolean analyze(ImagePlus imp, ImageProcessor ip)
      Performs particle analysis on the specified ImagePlus and ImageProcessor. Returns false if there is an error.
    • saveResults

      protected void saveResults(ImageStatistics stats, Roi roi)
      Saves statistics for one particle in a results table. This is a method subclasses may want to override.
    • drawParticle

      protected void drawParticle(ImageProcessor drawIP, Roi roi, ImageStatistics stats, ImageProcessor mask)
      Draws a selected particle in a separate image. This is another method subclasses may want to override.
    • getOutputImage

      public ImagePlus getOutputImage()
      Returns the "Outlines", "Masks", "Elipses" or "Count Masks" image, or null if "Nothing" is selected in the "Show:" menu.
    • setHideOutputImage

      public void setHideOutputImage(boolean hideOutputImage)
      Set 'hideOutputImage' true to not display the "Show:" image.
    • setFontSize

      public static void setFontSize(int size)
      Sets the size of the font used to label outlines in the next particle analyzer instance.
    • setFontColor

      public static void setFontColor(String color)
      Sets the color ("blue", "black", etc.) of the font used to label outlines in the next particle analyzer instance.
    • setLineWidth

      public static void setLineWidth(int width)
      Sets the outline line width for the next ParticleAnalyzer instance.
    • setRoiManager

      public static void setRoiManager(RoiManager manager)
      Sets the RoiManager to be used by the next ParticleAnalyzer instance. There is a JavaScript example at http://imagej.nih.gov/ij/macros/js/HiddenRoiManager.js
    • setResultsTable

      public static void setResultsTable(ResultsTable rt)
      Sets the ResultsTable to be used by the next ParticleAnalyzer instance.
    • savePreferences

      public static void savePreferences(Properties prefs)
      Called once when ImageJ quits.