Template matching plugin

I am working on a .tif stack of uCT images, and the stack is off-kilter. I downloaded the template matching pugin to align the images, but this error keeps popping up.

Fiji Is Just) ImageJ 2.0.0-rc-44/1.50e; Java 1.8.0_66 [64-bit]; Windows 7 6.1; 41MB of 6022MB (<1%)
java.lang.NoClassDefFoundError: org/bytedeco/javacpp/helper/opencv_core$CvArr
	at TemplateMatching.Align_slices.alignSlices(Align_slices.java:164)
	at TemplateMatching.Align_slices.run(Align_slices.java:96)
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:263)
	at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:112)
	at ij.IJ.runUserPlugIn(IJ.java:214)
	at ij.IJ.runPlugIn(IJ.java:176)
	at ij.Executer.runCommand(Executer.java:136)
	at ij.Executer.run(Executer.java:65)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.helper.opencv_core$CvArr
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 9 more

Can someone kindly let me know what i can do to solve this issue, or if there is an alternative option for aligning my stack.


Hi @jubilee,

from the stack trace I would guess that you are missing the Java wrapper for OpenCV. Could you please be more specific about which template plugin you have installed / are trying to use?

In any case, you could fall back to Fiji and the available registration plugins. The StackReg plugin for example is ready to use when you download Fiji.

All the best,


There are two Template Matching plugins listed on the official plugin list (1,2), so you should make clear which one you’re using.
From the stack trace you posted, I conclude it must be this one:

Did you follow the installation instructions on that page? In particular:

  • 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
1 Like

Thank you for your responses Stefan and Jan.

I was trying to use the " align slices in stack" option, but i just figured the i had not put the supporting files in the appropriate plugin folder, which let to the error message.

All clear now.


1 Like

I am interested in any follow up. I also have the same error while trying to use the same plugin and following the same instructions.

Late follow up, you can have a try with Multi-Template Matching for object-localisation in Fiji

1 Like