Software

Here are some ImageJ macros and plugins that I have written.
Please make sure that you have the latest version of the ImageJ ij.jar file

Disclaimer: The software in these pages is experimental. Use these plugins at your own risk. Although I have made every effort to make sure that they run as intended, there may be bugs and unexpected behaviour in instances that I have not envisaged. Please send any comments, problems or improvements to .

Copyright notice: Please check the copyright notices in the source code of each plugin. Some of the plugins are modifications of earlier versions written by other authors and therefore their original copyright notices apply. Please respect the original authors authorship notices.
If no specific copyright notice is included, then consider the plugin as free software: you can redistribute it and/or modify it under the terms of the GNU General Public license as published by the Free Software Foundation; either version 2 of the license, or (at your option) any later version.
These programs are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the programs; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

IsoPhotContour2 (java & class files) Takes a greyscale image and creates a new image [called IsoPhot] with up to 8 contour lines in the grey scale range. The contour lines can be drawn in different selected colours and depth levels. There is an option to draw the contour lines on a white or on a black background (rather than the greyscale data). There is also an option to convert the image to 8 bit colour image when exiting [Cancel] the plugin, otherwise the result is an 8 bit RGB image.


Blend (java & class files) Blends (linearly) two greyscale or RGB images with a chosen mixing ratio.


List_LUTs and LUTs plugins. Files and examples can be found here.


Align_4 (java & class files) This plugin allows manual alignment (movements in the x and y directions) up to 4 images. Supports transparency of the active image and selection of fiducial points (an origin and a target) for easy alignment. The plugin may be useful to build mosaics of smaller images.


Align_RGB_planes (java & class files) This plugin allows to shift (move in the x and y directions) stretch and rotate the red green and blue planes in an RGB image. Includes a macro to resize images so they are not affected by the cropping due to the rotation. Thanks to Leon Espinosa for suggesting the modification to log the net movement of the planes.


Align_Slice (java & class files) This plugin allows to manually shift (move in the x and y directions) stretch and rotate a particular slice in an image stack.


Threshold_Colour ( jar file includes source ) (v1.7, requires ImageJ 1.37e) This plugin (a modification of Bob Dougherty's BandPass2 filter) allows to threshold a colour RGB images in the HSB, RGB, CIE Lab and YUV spaces. It suports extracting the range of HSB, RGB, CIE Lab or YUV values from a sample ROI (any type). Extract the files from the zip archive and put them somewhere in the plugins directory (or subdirectory). The Threshold_Colour entry will appear in the Plugins hierarchy, depending of the subdirectory which the plugin is copied to (I suggest the name "Segmentation" to keep all thresholding plugins).

New! Version 1.7 has a new [Macro] button that generates a macro and sends it to the Recorder window (if active) based on the current plugin settings. The zip file also includes RGB2YUV and RGB2Lab plugins which are necessary for that macro (note that these plugins convert an RGB image to YUV and CIE Lab colour spaces but with values mapped into an 8-bit space).


Anaglyph (java & class files) Creates colour or greyscale, red-cyan or red-green anaglyphs, stereo pairs (crossed view stereo pairs) and depth-map images from the depth data and focused image generated with the extended depth of focus plugin. The Anaglyph plugin expects both the "Topology" and "Output" images to be open (they hold the "topographical map" data and the "on focus" data). For Topology images created using other programmes, they can be 8 or 32 bits, but they should not be re-scaled (i.e. depth plane pixel values should be contiguous in the grey scale and start a 0). Because it cannot be known in advance the acquisition direction of the Z sequence, it may be necessary to invert the view sides when checking the red-cyan anaglyph. The plugin has been tested with only a small number of slices (6~20), so please report any problems.


Colour_Deconvolution (java & class files) This plugin implements stain separation using Ruifrok & Johnston's colour deconvolution method described in [1]. Details and examples can be found here.


ThreePointCircularROI (java & class files) This plugin creates a circular ROI based on 3 user selected points on an image. The log window reports the coordinates of the centre of the circle and its radius. Co-linear points (that define an impossible circle) return a radius of -1.


Colour_Correct (java & class files) This plugin corrects the colours of an image by first subtracting the mean RGB values of a number of selected points considered to be 'black' and then subtracts the background by performing the ratio of the image and the mean RGB values of a number of points considered to be 'white' minus the 'black'. It does not correct for uneven illumination. The procedure is:

image = [(original-black)/(white-black)]*255.
This is a simple and quick (although not the best) method to compensate the filament temperature colour of light transmitted images such as bright field microscopy when there is no original illumination source available to perform the correction.

Convex_Hull_Plus (java & class files) This plugin calculates the convex hull and the minimum bounding circle of a binary set (formed by white or black particles).
The Convex Hull is the smallest convex polygon that contains the set. The plugin uses the 'wrapping around' (Graham scan) algorithm.
The Minimum Bounding Circle is the smallest circle that contains the set. An algorithm was modified from Xavier Draye's posting to the ImageJ mailing list. I implemented so it does the calculations based on the convex hull points rather than the whole set (as the points that define the Minimum Bounding Circle must be in the Convex Hull). This should be speed up the computation. Please see the source code for details.
The plugin can display any of the above as a selection or draw them on the image. The plugin also displays in the Log window: the number of points in the Convex Hull, the length of the Convex Hull, the centre coordinates and radius of the Minimal Bounding Circle.
Version 1.1 returns these values in floating point format.
Version 1.2 fixes a bug in the Minimal Bounding Circle routine.


Results_Histogram (java & class files) This plugin creates a histogram from a selected column of the Results Table data. Note that not everything that is shown in the Results window is necessarily in the Results Table. Incorporated into ImageJ 1.35g as the Analyze>Distribution... command.


IJ_Robot (java & class files) This plugin calls the Robot Java class. The purpose of the plugin is to allow the macro language to control other programs via clicking and key presses.
When running the plugin one must specify an 'order' to the robot and some parameters (not all orders require all the parameters).

Move: moves the mouse to a particular position (x, y) on the screen.

[Left|Middle|Right]_Click: Clicks the mouse at a given (x, y) postion with the chose button.

Delay: this is the time in milliseconds that the button is down during a click.

[Left|Middle|Right]_Down: presses the chosen button at the current position (this order does not read the x, y coordinates).

[Left|Middle|Right]_Up: releases the chosen button at the current position (this order does not read the x, y coordinates).

KeyPress: this order will emulate typing the entered string, but will first Click (at the current position), so the cursor is guaranteed to focus in an entry box (maybe this click is not required, please send feedback or suggestions).
KeyPress currently supports the following key presses: 0-9 a-z A-Z space /.,-
To emulate the [enter] key, type the exclamation mark '!'. Other characters are converted to '.'
Note that in Mac OSX with an AZERTY keyboard, the typed string does not get interpreted correctly. Be also aware that some OS do not support some key presses.

GetPixel: reports to the Log window the r,g,b values of the pixel at the specified postion (requires x, y coordinates). It will also return the Width and Height of the screen, as well as the coordinates of the pixel.

CaptureScreen: this is similar to the IJ function Plugins>Utilities>Capture Screen.

A handy way to find the target coordinates is to first grab the screen (which opens as an image in IJ) and check the coordinates with the mouse in IJ (reported in the status bar).

Important!

  1. Be very careful with this plugin. It is really easy to end up clicking in unintended places with undesired results. You have been warned!
  2. It may be necessary to increase the delay time for clicking orders depending on what is needed to be done and the response time of the target program.
  3. It may be also necessary to slow down the macro calls to this plugin between orders by using the macro command: wait(time_in_milliseconds). For instance if you are grabbing an image with an external programme, the grab function may not be available while the snapshot is being taken.
The included demo, seems to work fine in various platforms. Make sure that there are no open images in IJ and that please do not move the mouse while running the macro.





Morphological Operators for ImageJ

Below is my collection of ImageJ plugins to perform various morphological operations.
All plugins are recordable. Some macros that make use of those plugins are also included.
Download the full set as a single zip file from here.
The zip file contains a Morphology folder with all the plugins and macros. Unzip the files in the plugins folder and finally restart ImageJ.
Be aware that while most macros were written to deal with white particles, the plugins, deal with both, black or white particles (this means that the macros can be easily modified to deal with black particles too).
Tested under ImageJ 1.34n.

BinaryConditionalDilate_.class
This plugin dilates (3x3 neighbourhood, 8-connected) particlesin an image (called seed) inside another image (called mask). The procedure can be applied n of times, or until idempotence if n = -1. In that case the procedure becomes is the same as BinaryReconstruction.


BinaryConditionalErode_.class
This plugin erodes (3x3 neighbourhood, 8-connected) particles in an image (called seed) except what is masked in another image (called mask) (i.e. the mask "protects" what should not be eroded). it can be applied n times, or, until idempotence if n = -1.


BinaryConnectivity_.class
Returns the number of connected pixels (+1) to each foreground pixel (8 neighbours): background = 0, single pixel = 1, end of a line = 2, bifurcations = 3, triple points = 4, etc. Brightness/Contrast must be adjusted to see the result.


BinaryDilate_.class
This plugin performs a 3x3 8-neighbour Binary Dilation of a binary image. The differences with the built in Dilation in ImageJ are:

Notice: This plugin will be discontinued since ImageJ 1.33q fixed a bug that prevented border processing and also implements the use "coefficients". Note, however that in ImageJ, the coefficients range from 1 to 8 instead of 0 to 7.

BinaryDilateNoMerge4_.class
BinaryDilateNoMerge8_.class

These plugins perform a conditional binary dilation of a binary image (without merging particles together). The results are similar to a binary watershed transform of the background, partitioning it into areas of influence of the particles. Dilations are done with 4 or 8 pixel structuring elements respectively. The number of iterations can be set. Use -1 for dilation until idempotence.
Very slow, maybe there are better algorithms, but slow seems better than nothing...
If you need to dilate without merging until idempotence, then use the macro Influence_Zones.txt described below.


BinaryErode_.class
This plugin performs a 3x3 8-neighbour Binary Erosion of a binary image.
The differences with the built in Erosion in ImageJ are:

Notice: This plugin will be discontinued since ImageJ 1.33q fixed a bug that prevented border processing and also implements the use "coefficients". Note, however that in ImageJ, the coefficients range from 1 to 8 instead of 0 to 7.

BinaryFill_.class
This plugin fills holes in 8-connected particles (and also in child-particles) of a binary image. This function was incorporated in ImageJ v.1.31o (Process->Binary->Fill holes).


BinaryFilterReconstruct_.class
This plugin filters 8-connected particles in a binary image that otherwise would disappear after n erosions. The difference with morphological Opening is that BinaryFilterReconstruct preserves the original shape or the particles (Opening tends to smooth the boundaries of particles). The algorithm is n erosions, followed by a Binary Reconstruction of the original image based on the eroded image as the seed.
New in 1.3 Changed 'dilations in a mask' for 'floodfill8 in the mask from the seed' to speed up.


BinaryHitOrMiss_.class
This plugin returns the locations of the image that match the kernel pattern.
The pattern is a 3x3 neighbourhood where 0=empty, 1=set, 2=don't care.


BinaryLabel8_.class
ImageJ plugin for labelling particles (8 neighbours) in a binary image.
Can label up to 65530 particles in a unique greyscale value (from 1 to 65531), after that, the colours are recycled.
The output is a new 16 bit greyscale image with re-scaled brightness.

The ideal look up table (LUT) to maximise the contrast between labelled particles is glasbey.lut (included in the zip file). Please read about it in Chris Glasbey's website (the link to the paper is http://www.bioss.ac.uk/staff/chris/colorpaper.pdf ).


BinaryReconstruct_.class
This is a very powerful morphological operation that reconstructs (retains) 8-connected particles in an image (called mask) based on markers present in another image (called seed).
Morphological Reconstruction consists of dilating the seeds inside the mask (so particles that do not have seeds are not reconstructed).
New in 1.5 Changed 'dilations in a mask' for 'floodfill8 in the mask from the seed' to speed up.
This procedure is called "Feature-AND" in reference [2].


BinaryThick_.class
BinaryThick2_.class

These two plugins dilate the locations of the image that match one (BinaryThick_.class) or two (BinaryThick2_.class) kernel patterns.
First dilates then rotates the kernel, if set to do so. The pattern is a 3x3 neighbourhood where 0=empty, 1=set, 2=don't care.


BinaryThin_.class
BinaryThin2_.class
These two plugins erode the locations of the image that match one (BinaryThick_.class) or two (BinaryThick2_.class) kernel patterns.
First erodes then rotates the kernel, if set to do so. The pattern is a 3x3 neighbourhood where 0=empty, 1=set, 2=don't care.


Domes_.class
This plugin extracts "domes" in a greyscale image.
Domes are bright 8-connected regions of up to given height h (measured from their top downwards) in the greyscale function such that all the pixels around the dome have strictly lower greyscale values.
It can also return "basins" (regionally dark regions) instead of domes.
Domes and basins are good candidates to extract reconstruction markers in images with uneven backgrounds. See reference [3].


GreyscaleDilate_.class
GreyscaleErode_.class

These plugins perform a 3x3 Binary Dilation/Erosion of a greyscale image. Same as the Min and Max filters of radius=1 (8 neighbours) in ImageJ, but:


Greyscale "Proper" Morphological Filters (macros)


GreyscaleReconstruct_.class
This plugin reconstructs a greyscale image (the "mask" image) based on a "seed" image. This is an implementation of the parallel algorithm from [3].
It is very important to read Vincent's paper to understand greyscale reconstruction and its applications.
The reconstruction algorithm is: iterated 8-neighbour geodesic dilations of the seed UNDER the mask image until stability is reached (the idempotent limit).
It supports stacks reconstructed by a single seed image and also a single image reconstructed by a stack of seeds. Based on Calculator_Plus by Wayne Rasband.


Morphological Gradients and 2nd Derivative macros


EDM_16bits.txt
This macro produces an Euclidean Distance Map on a binary image [the object over which the EDM is calculated is assumed to be 255 and the background 0]. The macro extends the built in ImageJ command to distances of up to 65535 pixels. The result is a 16 bit image.


Particles4_.class
Particles8_.class
Particles8_Plus.class
These are plugins for estimating various statistics of binary 4- and 8-connected particles.
Warnings!:
1) The plugins assume square pixels only. If your image capture device has an aspect ration different to 1:1, do not use the plugins.
2) These plugins do not return the same values as the built in ImageJ Analyze Particles command because they use an alternative concept to extract area and perimeter. Here, Perimeter and Area are measured from the centres of the boundary pixels of a particle, i.e. the length of the 8-neighbours chain code.
Area disregards "holes" in the particles (i.e. it returns the area inside the boundary), but Pixels returns the number of pixels forming the particle (a particle with holes will therefore have more Area than Pixels).
Also note that here Area is calculated from the polygon formed by the boundary pixels (the chain code). If the particle has no holes, then Area is smaller than Pixels (since the polygon is positioned in the centres of boundary pixels). Note that using this logic, Area for 1 pixel particles is 0, for a 2x2 square it is 1, etc. while the value of Pixels in each particle is what you see.
Likewise, a single pixel particle has a Perimeter of 0, for a 2x2 square it is 4, etc.

Why to write such a plugin?
This was created to return exactly the number of pixels in particles when dealing with synthetic images (such as percolation clusters).
The Analyze Particles command in ImageJ performs a different measurement of the perimeter of particles.

These plugins can label the particles in different colours. Some colours are reserved for the particle detection and various calculations, so there are only 250 labelling colours available (1 to 251). It is therefore possible when using Particles4_ that two 4-connected particles which are corner neighbours could end up labelled with the same colour and therefore look like an 8-connected particle (this could happen when a very large particle is surrounded by many small ones). Although the labelling may be confusing, the statistics generated are correct.(If one only needs to label the particles unequivocally, then it is better to use the BinaryLabel8_.class plugin because it can label up to 65530 particles in unique greyscale values --after that, it also recycles the labelling colour.)

The plugins can draw the centre of mass (rounded to the nearest pixel, labelled or not) of each particle or the start coordinates of each particle (the only pixel with 100% certainty that it belongs to the particle). These may be useful for reconstruction purposes (see the KeepParticlesInRange.txt macro below and BinaryReconstruct_ plugin above).
Filtered particles (smaller than the minimum and larger than the maximum sizes) are deleted from the image.

New in Version 1.6
The labels of the options have been modified so they are consistent with those of the built in Analyzer in ImageJ.
A new option "Overwrite Results" was added to prevent the macro asking to save or delete the current Results when executing from a macro.
The results of the particle analysis are now sent to the ResultsTable, so the data generated can be retrieved from a macro for further processing. The macros below show how to do it.

Note: Although these plugins can analyse stacks, the results from all the slices are stored in the same ResultsTable. The data has an extra column named 'Stack' that indicates where the measurements belong to. Therefore, the macro examples above need to be modified to work properly with stacks.

New in Version 1.7
The plugin analysis has been extended to include the following new parameters:

Particles8_Plus adds more parameters (complete list below).

New in Version 1.8
Fixed bug that did not delete single border pixels when "exclude edge particles" was selected. Added CountCorrect parameter for unbiased counting of particles. This parameter should be used with "exclude edge particles" checked.
Here is the complete list of parameters:

Example macros that show some of the new parameters: DrawBoundingBox.txt, DrawFeret&Breadth.txt, DrawMinR&MaxR.txt.
The macro UnbiasedCounting.txt counts particles that touch the top and right image frames but not the bottom and left frames.
The macro UnbiasedParticleArea.txt estimates the corrected average particle area and number using the CountCorrect parameter.


New in Version 1.8a of Particles8_Plus
Fixed a bug in the Minimal Bounding Circle routine.
Added an example macro: DrawBoundingCircle.txt.

New in Version 1.9
When the image is a stack, the stack label is written to the Results window ("null" otherwise).
Changed some parameter names that caused problems when importing the data into SPSS.
DrawFeret&Breadth.txt was updated to use the new parameter names.

New in Version 2.0
More parameters are calculated by the plugin (the value -1 indicates that the parameter is no possible to calculate): The measurements can be redirected to another image. "Redirection" means that the plugin will use the current binary image to extract the particle profiles and morphometrical parameters, and a further 8bit greyscale image (typically the original image from which the binary image was created) to extract the greyscale statistics corresponding to the particles. This second greyscale image must be open and its name specified in the Redirect to box. When redirection is selected, the following greyscale statistics are produced: New in Version 2.1
Removed the "\n" from the slice label, otherwise the Results table is not formatted correctly.


Classify_Particles.class
This plugin allows to classify the particles based on the data produced by other plugins. Here are all the details.


References



Back


Last updated on 28/Sep/2006.