Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Image Processing with ImageJ

You're reading from   Image Processing with ImageJ Get familiar with one of the world's most highly regarded Digital Image processors, ImageJ. This tutorial takes you through every aspect of viewing, processing, and analysing 2D, 3D, and 4D images, clearly and comprehensively.

Arrow left icon
Product type Paperback
Published in Sep 2013
Publisher Packt
ISBN-13 9781783283958
Length 140 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

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"...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image