Book Image

Image Processing with ImageJ

Book Image

Image Processing with ImageJ

Overview of this book

Digital image processing is an increasingly important field across a vast array of scientific disciplines. ImageJ's long history and ever-growing user base makes it a perfect candidate for solving daily tasks involving all kinds of image analysis processes. Image Processing with ImageJ is a practical book that will guide you from the most basic analysis techniques to the fine details of implementing new functionalities through the ImageJ plugin system, all of it through the use of examples and practical cases. ImageJ is an excellent public domain imaging analysis platform that can be very easily used for almost all your image processing needs. Image Processing with ImageJ will start by showing you how to open a number of different images, become familiar with the different options, and perform simple analysis operations using the provided image samples. You will also learn how to make modifications through ImageJ filters and how to make local measurements using the selections system. You will also find the instructions necessary to record all the steps you perform so they can be saved and re-run on the same image to ensure analysis reproducibility. Finally, you will get to know some different ImageJ plugins and will learn how to implement your own.
Table of Contents (13 chapters)
Image Processing with ImageJ
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Adding a GUI to your plugin


Just as we did while developing macros, there is a way to add a user interface to your plugin. This will allow us to ask the user for input regarding specific parameters that your code will use before running. This is done through methods of the GenericDialog class. Consider the following example, which will also introduce other concepts:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;

public class Dialog_Example implements PlugInFilter {

    ImagePlus imp;
    boolean dialogCanceled = false;
    int radius = 3;
    int filterType;

    public int setup(String arg, ImagePlus imp) {
   	   this.imp = imp;
   	   return DOES_ALL;
    }

    public void run(ImageProcessor ip) {
      doDialog();
      if (dialogCanceled) return;    
      RankFilters rf = new RankFilters();
      rf.rank(ip, radius, filterType);
    }

    private void doDialog() {    
   	   GenericDialog gd = new GenericDialog("Dialog example"...