
// Contrast.java
// Andrew Davison, ad@coe.psu.ac.th, April 2023

/* Enhancing the contrast of an image, followed by
   smoothing, using both run() and the API.

   Usage:
     > compile Contrast.java
     > run Contrast
*/


import ij.*;
import ij.plugin.*;
import ij.plugin.filter.*;

public class Contrast
{

  public static void main(String[] args)
  {
    ImagePlus imp = new ImagePlus("dim.jpg");
    imp.show();
    IJ.wait(2000);   // so changes can be seen

/*
    IJ.run(imp, "Enhance Contrast...", "saturated=0.50 equalize");
    IJ.wait(2000);

      // Process --> Enhance Contrast
    IJ.run(imp, "Smooth", "");
      // Process --> Enhance Contrast
*/

    ContrastEnhancer ce = new ContrastEnhancer();
    ce.stretchHistogram(imp, 0.5);
    ce.equalize(imp);
    imp.updateAndDraw();
    IJ.wait(2000);

    Filters filts = new Filters();
    filts.setup("smooth", imp);
        // "invert", "smooth", "sharpen", "edge", "add", "noise"
    filts.run(imp.getProcessor());
    imp.updateAndDraw();

  } /* main */


}  // end of Contrast class
