Class IJUtils

java.lang.Object
inra.ijpb.util.IJUtils

public class IJUtils
extends java.lang.Object
A collection of utility methods for interacting with ImageJ.
Author:
David Legland
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String[] getOpenImageNames()
    Return an array of String containing the name of all the currently open images.
    static ij.text.TextWindow[] getTableWindows()
    Iterates on the list of TextWindows, and keeps only the ones containing a non-null ResultsTable
    static int[] parseLabelList​(java.lang.String string)
    Extracts a list of integer labels from a string representation.
    static void printImage​(ij.process.ImageProcessor image)
    Deprecated.
    static java.lang.String showElapsedTime​(java.lang.String opName, double timeInMillis, ij.ImagePlus refImage)
    Display elapsed time, converted into seconds, and computes number of processed elements per second.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • showElapsedTime

      public static final java.lang.String showElapsedTime​(java.lang.String opName, double timeInMillis, ij.ImagePlus refImage)
      Display elapsed time, converted into seconds, and computes number of processed elements per second. Also returns the created message.

      Example of use:

      
       // initialize processing 
       ImageStack image = IJ.getImage().getStack();
       Strel3D strel = CubeStrel.fromDiameter(5);
       
       // initialize timing 
       long t0 = System.currentTimeMillis();
       
       // start processing 
       ImageStack res = Morphology.dilation(image, strel);
       ImagePlus resPlus = new ImagePlus("Dilation Result", res);
       resPlus.show();
       
       // Display elapsed time
       long t1 = System.currentTimeMillis();
       IJUtils.showElapsedTime("dilation", t1 - t0, resPlus);
       
      Parameters:
      opName - the name of the operation (algorithm, plugin...)
      timeInMillis - the elapsed time, in milliseconds
      refImage - the image on which process was applied
      Returns:
      the String corresponding to the message displayed in status bar
    • getOpenImageNames

      public static final java.lang.String[] getOpenImageNames()
      Return an array of String containing the name of all the currently open images. If no image is open, returns an array with zero element.
      Returns:
      an array of string containing the name of open images.
    • getTableWindows

      public static final ij.text.TextWindow[] getTableWindows()
      Iterates on the list of TextWindows, and keeps only the ones containing a non-null ResultsTable
      Returns:
      an array containing the list of open TextWindows
    • parseLabelList

      public static final int[] parseLabelList​(java.lang.String string)
      Extracts a list of integer labels from a string representation.
      Parameters:
      string - the String containing labels, separated by commas or spaces.
      Returns:
      the list of integer labels identified within the string
    • printImage

      @Deprecated public static final void printImage​(ij.process.ImageProcessor image)
      Deprecated.
      Prints the content of the given ImageProcessor on the console. This can be used for debugging (small) images.
      Parameters:
      image - the image to display on the console