Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
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

A sample plugin


We will start digging into this topic by analyzing the following plugin code. That will give us a nice starting point to introduce the different aspects for developing ImageJ plugins:

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

public class Test_Plugin implements PlugIn {
    public void run(String arg) {
        int width = 300;
   	     int height = 300;   	 
ImageProcessor ip = new ByteProcessor(width, height);
  ip.setColor(Color.black);
   	   ip.fill();
       for(int x = 0; x < width; x++) {
   	    for(int y = 0; y < height; y++) {
   	      if (x == y || (width - x) == y)
   	        ip.putPixel(x, y, 255);
   	     }
   	   }
   	   ImagePlus imp = new ImagePlus("Result image", ip);    
   	   imp.show();
    }
}

First things first: this is a plugin, and not a macro. To edit it, navigate to Plugins | New | Plugin. A sample skeleton will be opened and you just need to fill in the run(arg...

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 €18.99/month. Cancel anytime