
// PlotProfile.java
// Andrew Davison, ad@coe.psu.ac.th, April. 2023

/* Run a plot profile on the supplied file, displaying
   the plot and a table of results. The table is saved
   to a text file.

   Usage:
     > compile PlotProfile.java
     > run PlotProfile <fnm>
   e.g.
     > run PlotProfile boats.png
     > run PlotProfile fluorescentLight.png
*/


import ij.*;
import ij.gui.*;
import ij.process.*;
import ij.plugin.*;
import ij.measure.*;


public final class PlotProfile
{


  public static void main(String args[])
  {
    if (args.length != 1) {
      System.out.println("Usage: run PlotProfile <fnm>");
      return;
    }

    ImagePlus imp = new ImagePlus(args[0]);
    imp.show();

    imp.setRoi(0, 0, imp.getWidth(), imp.getHeight());

    Profiler prof = new Profiler();
    prof.run("");
        // Analyze --> Plot Profile

    Plot plot = prof.getPlot();
    ImagePlus plotImp = plot.getImagePlus();

    ResultsTable rt = plot.getResultsTable();
    rt.show("Plot Values");  // the table in a window

    System.out.println("Saving table to plot.txt");
    rt.save("plot.txt");

    ImageUtils.waitGone(plotImp);
    System.exit(0);
  }  // end of main()


} // end  of PlotProfile class

