Template Matching and Slice Alignment--- ImageJ Plugins

You can download this plugin here.
And required javacv library files: javacv.jar, javacpp.jar, opencv.jar
And platform-dependent library files:
Put the above jar files into your ImageJ's plugins folder, and restart ImageJ.
Please see Installation for more details. 
Sample images are here
Java source code: cvMatch_Template.java and Align slices.java

Description

This ImageJ plugin contains two functions. The first one is the cvMatch_Template. It implements the template matching function from the OpenCV library. The java interface of OpenCV was done through the javacv library. It is quite similar as the existing template matching plugin but runs much faster and users could choose among six matching methods:

1.Squared difference

2.Normalized squared difference

3.Cross correlation

4.Normalized cross correlation

5.Correlation coefficient

6.Normalized correlation coefficient

The detailed algorithms could be found here.

The cvMatch_Template will search an specific object (image pattern) over an image of interest by the user specified method.


   
 
 template  best match
 multi-match


The second function Align_slices in stack utilized the previous matching function to do slice registration(alignment) based on a selected landmark. This function will try to find the landmark or the most similar image pattern in every slice and translate each slice so that the landmark pattern will be the same position through out the whole stack. It could be used to fix the drift of a time-lapse image stacks, as shown in the following example:

#New feature: subpixel registration, updated 2011/5/13. Please see here for details.

 
 
 
 before alignment
 after alignment
alignment with subpixel registration
Microtubule growth under TIRF microscope. Image courtesy of Didier PORTRAN.
(Physics of the Cytoskeleton and Morphogenesis, iRTSV/CEA, France)

System Requirement

ImageJ 1.44 or later, running on Java 1.6

Installation

-Determine your system architecture: for windows 7 or 8, you might run ImageJ under 32bit or 64bit. If your ImageJ.exe is under Program files(x86), then you are using 32bit.
-Download the Tamplate_Matching.jar and put it into your ImageJ's plugins folder
-Download the system-independent library files: javacv.jar, javacpp.jar, opencv.jar, and put them into your ImageJ's plugins folder
-Download the system-dependent library files: 32-bit Windows , 64-bit Windows, 64-bit Mac, 32-bit Linux or 64-bit Linux and put the one corresponding to your system into your ImageJ's plugins folder
-Restart ImageJ, you will find a new entry under the plugins menu (Plugins>Template Matching)
-Try with the sample image to see if everything worked correctly.

Tutorials

Tutorial for cvMatch_Template

Tutorial for Align slices in stack

Updates

#2015/2/07: Recompiled to support most recent javacv/opencv libraries (v. 0.10)

#2014/7/23: Recompiled to support more recent javacv/opencv libraries (now supports win32, win64, mac64, linux32, linux64)

#2012/2/29: Added the pre-compiled opencv library file for the 64-bit window system.  (Thanks Yevhen Katrukha for providing the library files)

# 2011/5/30: Fixed the memory leak issue caused by the OpenCV interface.

# 2011/5/13: Boundary area for searching landmark.

# 2011/5/13: Subpixel registration.

Troubleshooting

#Q: I got a error message right after launching the plugin saying "java.lang.UnsupportedClassVersionError: Bad version number in .class file.............".
  A:
It occurs when the Java version used for ImageJ (Java 1.5.xxx for ImageJ-32bit in MacOS X, Java 1.6.xxx for ImageJ-64bit in MacOS X and all the window-versions)  is not compatible with the Java version used for compiling this plugin (Java 1.6.xxxx). To avoid this use the 64-bit ImageJ in Mac.

#Q: The plugin launched correctly, but after entering the parameters in the dialog window or after selecting the ROI, I got a error message saying "Plugin or class not found:"Align_slices"
(java.lang.NoClassDefFoundError: name/audet/samuel/javacv/jna/cxcore$
". 
  A:
It happens because ImageJ failed to find the javacv and jna interface. You probably forgot to put the  javacv.jar and jna.jar along with the Template_Matching.jar  into ImageJ's plugins folder. Please follow the steps written in the Installation part.

#Q: The plugin launched correctly, but after entering the parameters in the dialog window or after selecting the ROI, I got a error message saying "java.lang.UnsatisfiedLinkError: Unable to load library 'cxcore': ...................
  A:
It happens because the system failed to load the opencv library. You probably forgot to download and put the library files (32-bit on windows or 64-bit on Mac) into correct place (ex: C:\Program Files\ImageJ or /usr/lib). Please follow the steps written in the Installation part.

Publications

1. Tseng, Q. et al. A new micropatterning method of soft substrates reveals that different tumorigenic signals can promote or reduce cell contraction levels. Lab on a Chip 11, 2231 (2011).

2. Tseng, Q. et al. Spatial Organization of the Extracellular Matrix Regulates Cell–cell Junction Positioning. PNAS (2012).doi:10.1073/pnas.1106377109

3. Tseng, Qingzong. 2011. “Study of multicellular architecture with controlled microenvironment”. Ph.D. dissertation, Université de Grenoble. http://tel.archives-ouvertes.fr/tel-00622264.

Credit

Thanks to Samual Audit and his javacv library which allows me to use the very powerful OpenCV library from java.

Any question or comment, please contact Qingzong TSENG (qztseng at gmail.com). Or through my Linkedin: tw.linkedin.com/pub/qingzong-tseng/58/807/b41/


Back to the main plugin page