[ImageJ-devel] How do I Perform an Image Convolution?

Brian Northan bnorthan at gmail.com
Fri Jan 23 15:14:56 CST 2015


Hi Michael

Also can you tell me where I should look for FFTConvolution within
> https://github.com/imglib as I cannot seem to locate it.
>

It is licensed as GPL so it is in a slightly different spot....

https://github.com/imglib/imglib2-algorithm-gpl/tree/master/src/main/java/net/imglib2/algorithm/fft2


I do not understand either of these resulting image sizes, when I use
> ImageJ to perform the FFT I get a resulting image where each dimension is
> the smallest power of two equal or greater than the source image dimensions.
>

The images are resized so that the FFT can be performed efficiently.   A
particular FFT implementation may not support every buffer size.  Looks
like that ImageJ implementation only supports power of 2.  ImgLib supports
non-power of 2 sizes... but it will still extend the image slightly so the
FFT can be performed faster.

Some of the differences you are seeing are because 'FourierTransform' has
different preprocessing and extension related settings.

If you look at FourierTransform.java you can see that the constructor you
used in turn calls another constructor which sets defaults values for some
parameters

https://github.com/imglib/imglib2-algorithm-gpl/blob/master/src/main/java/net/imglib2/algorithm/
fft/FourierTransform.java

Also in both cases it looks as though the FFT produced might be containing
> only half of the information in the X dimension (hence the resulting images
> appearing to be roughly twitch as tall as they are wide)
>

That sounds correct.  An ND FFT is achieved by performing a a real to
complex transform in the first dimension that dimension will have n/2+1
complex coefficients.  A complex to complex transform is performed in the
remaining dimensions.

Brian

On Thu, Jan 22, 2015 at 12:28 PM, Michael Ellis <michael.ellis at dsuk.biz>
wrote:

> Curtis,
>
> I am once again looking into trying to perform the image alignment
> function as done in Example6c but using the new Fourier code.
>
> Thus far I have discovered that how to perform FFTs and inverse FFTs
> using imglib/imglib2-algorithm-fft
>
> However, when I compare the results generated by the deprecated version:
>             // compute fourier transform of the template
>             final FourierTransform< FloatType, ComplexFloatType> fft
>                     = new FourierTransform< FloatType, ComplexFloatType>(
>                             image, new ComplexFloatType());
>             fft.process();
>             Img< ComplexFloatType> fftImage = fft.getResult();
>
>
> And the new version
>
>             ImgFactory<ComplexFloatType> fftImgFactory =
> image.factory().imgFactory(new ComplexFloatType());
>
>             // Compute fourier transform
>             Img< ComplexFloatType> fft = FFT.realToComplex(image,
> fftImgFactory);
>
> I find the results differ.
>
> The original images is the “WingTemplate.tif" image that comes with
> Example6c. This is of size 64x64 (8 bit pixels).
>
> The new FFT.realToComplex yields a Fourier image that is size 37x72
> The older FourierTransform yields an image that is size 41x80
>
> I do not understand either of these resulting image sizes, when I use
> ImageJ to perform the FFT I get a resulting image where each dimension is
> the smallest power of two equal or greater than the source image dimensions.
>
> Also in both cases it looks as though the FFT produced might be containing
> only half of the information in the X dimension (hence the resulting images
> appearing to be roughly twitch as tall as they are wide)
>
> Also the old Fourier code produces the brightest spot on the right hand
> side of the image, exactly half way down (width -1, height /2 -1) whereas
> the new Fourier code produces the a brightest spot at the top left of the
> image (0,0) I think this is something to with quadrant swapping but I am
> honestly at a loss here.
>
> Both methods old and new can have their corresponding inverse fourier
> transforms created to recreate the original image (or something that is
> very close).
>
> Even if the new Fourier method is correct can anyone point me in the right
> direction for what I would need to do to convert the Example6c from using
> the deprecated old Fourier code to the new Fourier code.
>
> Also can you tell me where I should look for FFTConvolution within
> https://github.com/imglib as I cannot seem to locate it.
>
> Many thanks in advance of any help — Michael Ellis
>
>
>
>
>
> On 18 Dec 2014, at 22:28, Curtis Rueden <ctrueden at WISC.EDU> wrote:
>
> Hi Michael,
>
> > The Example6c has not been updated to reflect the new way of doing
> > things.
>
> Indeed. If you end up updating it, a pull request to that effect would be
> most welcome!
>
> > You previously pointed me at the ImageJ OPS library. Is that th best
> > way of achieving the convolution?
>
> The most future-proof, in that OPS is the direction we are going. However,
> at this point in time it won't be the smoothest ride, since the OPS library
> is still in incubation.
>
> Furthermore, the main OPS convolve routine leans on the ImgLib2
> FFTConvolution implementation, so if all you need is the low-level
> function, then OPS is probably not necessary for you.
>
> > [INFO] Restricted to JDK 1.6 yet com.sun:tools:jar:1.4.2:system
> > contains com/sun/codemodel/internal/ClassType.class targeted to JDK
> > 1.8
>
> This was a bug in the Maven build configuration, addressed earlier this
> week. Should work with the latest master.
>
> > So what are the minimal hoops I need to jump though to setup ops such
> > that the code below will compile? (I want to avoid dragging in any
> > ImageJ 1 legacy code)
> >
> >         Img<FloatType> result = image.copy();
> >         Op op = ops.op("convolve", result, image, templateInverse);
>
> OPS does not depend on ImageJ1. (The only ImageJ2 component that does is
> called imagej-legacy, and is expressly for the purpose of backwards
> compatibility.)
>
> Easiest would be to start with the "using-ops" tutorial project, and edit
> the code from there.
>
>
> https://github.com/imagej/imagej-tutorials/tree/31a5771277682e5f1ef45112094d147539dc4bc7/using-ops
>
> FTR, you can invoke the routine with something like:
>
>     Object result = ops.convolve(image, templateInverse);
>
> However, in attempting a quick test of the convolve routine, I ran into
> some obstacles with the current code. My advice at the moment is to just
> use FFTConvolution directly for your needs.
>
> > For the record, I am suspicious about Java annotations!
>
> I agree with your concerns: they do unfortunately obfuscate the execution
> flow. However, they also bring many advantages. In particular, the way we
> are using them provides: 1) a dependency injection mechanism without the
> need for any external configuration files; and 2) a very succinct syntax
> for parameterized commands. We are shooting for DRY ("Don't Repeat
> Yourself") code here [1], not just in the core, but particularly for plugin
> developers [2].
>
> I think the best way to counter the mystery surrounding the inner workings
> is to thoroughly document how things work.
>
> Regards,
> Curtis
>
> P.S. Related to FFTConvolution, see also these issues:
> * https://github.com/imglib/imglib2-algorithm-fft/pull/1
> * https://github.com/imglib/imglib2/issues/61
> * https://github.com/imagej/imagej-ops/issues/12
>
> [1] http://imagej.net/Philosophy#Convention_over_configuration
> [2] Example:
> http://curtis.imagej.net/2013-03-15-imagej-research-paper/plugin-comparison.png
>
> On Wed, Dec 10, 2014 at 1:09 PM, Michael Ellis <michael.ellis at dsuk.biz>
> wrote:
>>
>> Curtis,
>>
>> Thanks for this reply and I am now turning my attention to use of the
>> FFT.
>>
>> It seems the FFT was moved from imglib2-algorithm
>> to imglib2-algorithm-fft (due I think to licensing issues).
>>
>> I need to achieve what is done in imglib2-tutorials/Example6c.java at
>> master · imglib/imglib2-tutorials
>> <https://github.com/imglib/imglib2-tutorials/blob/master/src/main/java/Example6c.java>
>>
>> The Example6c has not been updated to reflect the new way of doing
>> things. If I clone the imglib/imglib2-tutorials
>> <https://github.com/imglib/imglib2-tutorials> project I see the
>> following are all deprecated.
>>
>> import net.imglib2.algorithm.fft.FourierConvolution;
>> import net.imglib2.algorithm.fft.FourierTransform;
>> import net.imglib2.algorithm.fft.InverseFourierTransform;
>>
>> I have managed to make progress and think I have got fourier and inverse
>> fourier transforms working. So that just leaves the convolution.
>>
>> You previously pointed me at the ImageJ OPS library. Is that th best way
>> of achieving the convolution?
>>
>> The ImageJ OPS example however depends on ImageJ. The ImageJ OPS test
>> programs don’t help me either since the test classes do some magic wizardry
>> that I do not understand at all i.e. with Contexts, Java annotations and
>> some injection stuff.
>>
>> So what are the minimal hoops I need to jump though to setup ops such
>> that the code below will compile? (I want to avoid dragging in any ImageJ 1
>> legacy code)
>>
>> Img<FloatType> result = image.copy(); Op op = ops.op("convolve", result,
>> image, templateInverse);
>>
>> Also in downloading the ImageJ-Ops project and running maven compile, I
>> get the following. I realise that I am at Java8 and that might be jumping
>> the gun a bit, but Java 6 is well past its sell by date and if you are
>> on a new Apple Mac, Java 6 is not a comfortable option.
>>
>> [INFO] Restricted to JDK 1.6 yet com.sun:tools:jar:1.4.2:system contains
>> com/sun/codemodel/internal/ClassType.class targeted to JDK 1.8
>> [WARNING] Rule 1:
>> org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with
>> message:
>> Found Banned Dependency: com.sun:tools:jar:1.4.2
>>
>> For the record, I am suspicious about Java annotations! *For me at least*
>> They fro not help with trying to understand code as I cannot make out how
>> to call the code in question. The feel rather like something layered on top
>> of a language rather than an intrinsic built in.  They give me that
>> uncomfortable feeling that C++ Standard Template Library did - and that
>> gave me nightmares when it came time to debug code.
>>
>> Thanks in anticipation of any light you can throw into my darkness!
>>
>> — Michael Ellis
>>
>>
>>
>>
>>
>>
>>
>> On 5 Dec 2014, at 18:31, Curtis Rueden <ctrueden at WISC.EDU> wrote:
>>
>> Hi Michael,
>>
>> > It looks like there is a new FFT but the tutorials use the older
>> > version.
>> >
>> > What should I go with?
>>
>> The library for doing FFT is imglib2-algorithm-fft:
>>     https://github.com/imglib/imglib2-algorithm-fft
>>
>> Regarding the "new FFT", perhaps you refer to this?
>>     https://github.com/imglib/imglib2-algorithm-fft/pull/1
>>
>> At the moment there are licensing issues with imglib2-algorithm-fft (it
>> depends on the Mines JTK library which has a license incompatible with
>> GPL). That PR addresses the issues by using the JTransforms library instead.
>>
>> You also might want to consider using the higher level ImageJ OPS library:
>>     https://github.com/imagej/imagej-ops
>>
>> Thanks to the efforts of Brian Northan, we are about to merge an OP
>> wrapper for FFT:
>>     https://github.com/imagej/imagej-ops/pull/76
>>
>> Note that these components are still in the 0.x incubation phase, meaning
>> they do not have stable APIs. That said, we would really appreciate early
>> adopters who can try out the code and help drive things in the right
>> direction.
>>
>> We will be reviewing and merging these improvements over the next few
>> days, then cutting new releases of imglib2-algorithm-fft and imagej-ops. At
>> that point, it should be easier for you to try them out.
>>
>> The relevant tutorials are based on imglib2-algorithm-fft:
>>
>> https://github.com/imglib/imglib2-tutorials/blob/929de9b7482c312ff9c51ab52aa632779ef058f3/src/main/java/Example6b.java
>>
>> https://github.com/imglib/imglib2-tutorials/blob/929de9b7482c312ff9c51ab52aa632779ef058f3/src/main/java/Example6c.java
>>
>> And IIUC the changes above are internal so the tutorial code should not
>> requiring updating (beyond an update to the version of
>> imglib2-algorithm-fft in the POM, of course).
>>
>> Regards,
>> Curtis
>>
>> On Fri, Dec 5, 2014 at 12:21 PM, Michael Ellis <michael.ellis at dsuk.biz>
>> wrote:
>>
>>> Once again, Curtis
>>>
>>> I really appreciate your help with this.
>>>
>>> Next questions on the horizon will involve the ImgLib2 algorithm FFT
>>> classes. It looks like there is a new FFT but the tutorials use the older
>>> version.
>>>
>>> What should I go with?
>>>
>>> My aim is build an application, which as part of it will be doing image
>>> alignment using FFT phase correlation.
>>>
>>> Regards — Michael Ellis
>>>
>>>
>>> On 5 Dec 2014, at 18:13, Curtis Rueden <ctrueden at wisc.edu> wrote:
>>>
>>> Hi Michael,
>>>
>>> > gives me a self contained runnable jar. Progress! I’m learning.
>>> >
>>> > BUT as before when I run the jar, I get the Exception: No compatible
>>> > service: org.scijava.service.SciJavaService
>>>
>>> Self contained runnable JARs (i.e., uber-jars) are convenient in some
>>> ways, but come with a host of problems.
>>>
>>> 1) If you do not shade your dependencies (i.e., rename their packages),
>>> then you may ship duplicate and/or incompatible classes with other
>>> libraries. This makes your library much harder to reuse in a shared system
>>> such as an ImageJ installation.
>>>
>>> 2) You cannot ship piecemeal updates to individual dependencies -- i.e.,
>>> every time your code changes, you must ship a new (possibly very large) new
>>> JAR file to your users.
>>>
>>> 3) The SciJava annotation processor, responsible for indexing the
>>> @Plugin annotations that drive SciJava/ImageJ2/etc. plugins, writes the
>>> metadata into a resource file at META-INF/json/org.scijava.plugin.Plugin
>>> within the JAR. If you try to create an uber-jar via the assembly or shade
>>> plugin, the default combination algorithm will overwrite those files,
>>> stomping the annotations.
>>>
>>> We wrote some code which offers one way around this:
>>>
>>> https://github.com/imagej/imagej/blob/imagej-2.0.0-rc-17/pom.xml#L614-L631
>>>
>>> For more on uber-jars, see also:
>>>
>>> http://imagej.net/Frequently_Asked_Questions#How_can_I_call_ImageJ_from_my_software.3F
>>>
>>> The gist is: avoid using an uber-jar unless you really need it.
>>>
>>> > I’ve got it working with your help!
>>>
>>> Awesome, congratulations. Let us know if you encounter any more
>>> roadblocks.
>>>
>>> Regards,
>>> Curtis
>>>
>>> On Fri, Dec 5, 2014 at 12:03 PM, Michael Ellis <michael.ellis at dsuk.biz>
>>> wrote:
>>>
>>>> Adding a build section to the POM:
>>>>
>>>>   <build>
>>>>     <plugins>
>>>>       <plugin>
>>>>         <groupId>org.apache.maven.plugins</groupId>
>>>>         <artifactId>maven-shade-plugin</artifactId>
>>>>         <version>2.3</version>
>>>>         <executions>
>>>>           <execution>
>>>>             <phase>package</phase>
>>>>             <goals>
>>>>               <goal>shade</goal>
>>>>             </goals>
>>>>             <configuration>
>>>>               <transformers>
>>>>                 <transformer
>>>> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
>>>>                   <manifestEntries>
>>>>                     <Main-Class>com.mycompany.app.App</Main-Class>
>>>>                     <Build-Number>123</Build-Number>
>>>>                   </manifestEntries>
>>>>                 </transformer>
>>>>               </transformers>
>>>>             </configuration>
>>>>           </execution>
>>>>         </executions>
>>>>       </plugin>
>>>>     </plugins>
>>>>   </build>
>>>>
>>>> To the POM gives me a self contained runnable jar. Progress! I’m
>>>> learning.
>>>>
>>>> BUT as before when I run the jar, I get the Exception: No compatible
>>>> service: org.scijava.service.SciJavaService
>>>> =================================================================
>>>>
>>>> [Michaels-Retina:~/temp/deleteme/my-app] michaelellis% java -jar
>>>> target/my-app-1.0-SNAPSHOT.jar
>>>> Hello World!
>>>> Exception: No compatible service: org.scijava.service.SciJavaService
>>>> =================================================================
>>>>
>>>> Still vexed!
>>>>
>>>>
>>>> On 5 Dec 2014, at 17:17, Curtis Rueden <ctrueden at wisc.edu> wrote:
>>>>
>>>> Hi Michael,
>>>>
>>>> > mvn claims to build everything OK
>>>>
>>>> Yep, it did build successfully.
>>>>
>>>> > % java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
>>>> > Error: A JNI error has occurred, please check your installation and
>>>> try again
>>>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>>> io/scif/SCIFIO
>>>>
>>>> Maven is primarily a build tool. It puts the correct JARs on your
>>>> classpath at compile time. In your case, that is scifio-0.17.1.jar and its
>>>> dependencies.
>>>>
>>>> However, the way you are launching your program is not putting the
>>>> required dependencies on the classpath. You put only
>>>> my-app-1.0-SNAPSHOT.jar on the classpath, and its dependencies are missing.
>>>> So of course Java cannot find the needed classes.
>>>>
>>>> The gist is: it is your responsibility to assemble the dependencies and
>>>> ensure they are on the classpath somehow when you launch your application.
>>>>
>>>> There are several ways to accomplish this. Here is one generally useful
>>>> way using Maven, which does not assume you are doing anything
>>>> ImageJ-related:
>>>>
>>>>     $ mvn dependency:copy-dependencies
>>>>     $ java -cp 'target/my-app-1.0-SNAPSHOT.jar:target/dependency/*'
>>>> com.mycompany.app.App
>>>>
>>>> The "copy-dependencies" goal copies all the JAR files needed by your
>>>> program into the target/dependency folder, for easy subsequent consumption.
>>>>
>>>> Alternately, the "ImageJ way" of dealing with deployment is to ship all
>>>> needed dependencies in the "jars" folder of your ImageJ application. We
>>>> created a Maven goal for this too, which you can use as follows:
>>>>
>>>>     $ mvn -Dimagej.app.directory=/Applications/ImageJ.app
>>>> -Ddelete.other.versions=true
>>>>
>>>> Which will copy your JAR and its dependencies into your ImageJ
>>>> installation at /Applications/ImageJ.app. But note that in order for this
>>>> goal to work, you must extend the pom-imagej parent (see
>>>> https://github.com/imagej/minimal-ij1-plugin for an example).
>>>>
>>>> A third solution is to use the exec-maven-plugin to launch your
>>>> application directly using Maven. E.g.:
>>>> https://github.com/imagej/imagej/blob/imagej-2.0.0-rc-17/pom.xml#L255-L278
>>>>
>>>> Regards,
>>>> Curtis
>>>>
>>>> On Fri, Dec 5, 2014 at 11:03 AM, Michael Ellis <michael.ellis at dsuk.biz>
>>>> wrote:
>>>>
>>>>> Curtis,
>>>>>
>>>>> Thanks but it is still not working.
>>>>>
>>>>> I have cut out using NetBeans and am now just using the CLI and a text
>>>>> editor.
>>>>>
>>>>> POM as follows:
>>>>>
>>>>> ========================================================
>>>>> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>>>>> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>>>>>   <modelVersion>4.0.0</modelVersion>
>>>>>
>>>>>   <groupId>com.mycompany.app</groupId>
>>>>>   <artifactId>my-app</artifactId>
>>>>>   <version>1.0-SNAPSHOT</version>
>>>>>   <packaging>jar</packaging>
>>>>>
>>>>>   <name>my-app</name>
>>>>>   <url>http://maven.apache.org</url>
>>>>>
>>>>>   <properties>
>>>>>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>>>>   </properties>
>>>>>
>>>>> <repositories>
>>>>> <repository>
>>>>> <id>imagej.public</id>
>>>>> <url>http://maven.imagej.net/content/groups/public</url>
>>>>> </repository>
>>>>> </repositories>
>>>>>
>>>>>   <dependencies>
>>>>>     <dependency>
>>>>>       <groupId>junit</groupId>
>>>>>       <artifactId>junit</artifactId>
>>>>>       <version>3.8.1</version>
>>>>>       <scope>test</scope>
>>>>>     </dependency>
>>>>>
>>>>> <dependency>
>>>>>   <groupId>io.scif</groupId>
>>>>>   <artifactId>scifio</artifactId>
>>>>>   <version>0.17.1</version>
>>>>> </dependency>
>>>>>
>>>>>   </dependencies>
>>>>> </project>
>>>>> ========================================================
>>>>>
>>>>> File hierarchy:
>>>>>
>>>>> .
>>>>> ./.DS_Store
>>>>> ./pom.xml
>>>>> ./src
>>>>> ./src/main
>>>>> ./src/main/java
>>>>> ./src/main/java/com
>>>>> ./src/main/java/com/mycompany
>>>>> ./src/main/java/com/mycompany/app
>>>>> ./src/main/java/com/mycompany/app/App.java
>>>>> ./src/test
>>>>> ./src/test/java
>>>>> ./src/test/java/com
>>>>> ./src/test/java/com/mycompany
>>>>> ./src/test/java/com/mycompany/app
>>>>> ./src/test/java/com/mycompany/app/AppTest.java
>>>>> ========================================================
>>>>>
>>>>> App.java as follows:
>>>>>
>>>>> package com.mycompany.app;
>>>>>
>>>>> import io.scif.FormatException;
>>>>> import io.scif.ImageMetadata;
>>>>> import io.scif.Plane;
>>>>> import io.scif.Reader;
>>>>> import io.scif.SCIFIO;
>>>>>
>>>>> public class App
>>>>> {
>>>>>     public static void main( String[] args )
>>>>>     {
>>>>> try {
>>>>>         System.out.println( "Hello World!" );
>>>>> SCIFIO scifio = new SCIFIO();
>>>>> String sampleImage
>>>>> =
>>>>> "8bit-signed&pixelType=int8&lengths=50,50,3,5,7&axes=X,Y,Z,Channel,Time.fake";
>>>>> final Reader reader =
>>>>> scifio.initializer().initializeReader(sampleImage);
>>>>> System.out.printf("reader=%s%n", reader );
>>>>>         } catch (Exception e) {
>>>>>         System.out.printf("Exception: %s%n", e.getMessage() );
>>>>>         }
>>>>>     }
>>>>> }
>>>>>
>>>>> ========================================================
>>>>>
>>>>> mvm -U install
>>>>>
>>>>> [Michaels-Retina:~/temp/deleteme/my-app] michaelellis% mvn -U install
>>>>> [INFO] Scanning for projects...
>>>>> [INFO]
>>>>>
>>>>> [INFO]
>>>>> ------------------------------------------------------------------------
>>>>> [INFO] Building my-app 1.0-SNAPSHOT
>>>>> [INFO]
>>>>> ------------------------------------------------------------------------
>>>>> [INFO]
>>>>> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
>>>>> my-app ---
>>>>> [INFO] Using 'UTF-8' encoding to copy filtered resources.
>>>>> [INFO] skip non existing resourceDirectory
>>>>> /Users/michaelellis/temp/deleteme/my-app/src/main/resources
>>>>> [INFO]
>>>>> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
>>>>> my-app ---
>>>>> [INFO] Changes detected - recompiling the module!
>>>>> [INFO] Compiling 1 source file to
>>>>> /Users/michaelellis/temp/deleteme/my-app/target/classes
>>>>> [INFO]
>>>>> [INFO] --- maven-resources-plugin:2.6:testResources
>>>>> (default-testResources) @ my-app ---
>>>>> [INFO] Using 'UTF-8' encoding to copy filtered resources.
>>>>> [INFO] skip non existing resourceDirectory
>>>>> /Users/michaelellis/temp/deleteme/my-app/src/test/resources
>>>>> [INFO]
>>>>> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile)
>>>>> @ my-app ---
>>>>> [INFO] Changes detected - recompiling the module!
>>>>> [INFO] Compiling 1 source file to
>>>>> /Users/michaelellis/temp/deleteme/my-app/target/test-classes
>>>>> [INFO]
>>>>> [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my-app
>>>>> ---
>>>>> [INFO] Surefire report directory:
>>>>> /Users/michaelellis/temp/deleteme/my-app/target/surefire-reports
>>>>>
>>>>> -------------------------------------------------------
>>>>>  T E S T S
>>>>> -------------------------------------------------------
>>>>> Running com.mycompany.app.AppTest
>>>>> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005
>>>>> sec
>>>>>
>>>>> Results :
>>>>>
>>>>> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
>>>>>
>>>>> [INFO]
>>>>> [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my-app ---
>>>>> [INFO] Building jar:
>>>>> /Users/michaelellis/temp/deleteme/my-app/target/my-app-1.0-SNAPSHOT.jar
>>>>> [INFO]
>>>>> [INFO] --- maven-install-plugin:2.4:install (default-install) @ my-app
>>>>> ---
>>>>> [INFO] Installing
>>>>> /Users/michaelellis/temp/deleteme/my-app/target/my-app-1.0-SNAPSHOT.jar to
>>>>> /Users/michaelellis/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar
>>>>> [INFO] Installing /Users/michaelellis/temp/deleteme/my-app/pom.xml to
>>>>> /Users/michaelellis/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.pom
>>>>> [INFO]
>>>>> ------------------------------------------------------------------------
>>>>> [INFO] BUILD SUCCESS
>>>>> [INFO]
>>>>> ------------------------------------------------------------------------
>>>>> [INFO] Total time: 1.962 s
>>>>> [INFO] Finished at: 2014-12-05T16:59:50+00:00
>>>>> [INFO] Final Memory: 18M/242M
>>>>> [INFO] ————————————————————————————————————
>>>>>
>>>>> ========================================================
>>>>>
>>>>> mvn claims to build everything OK there seems to be no inclusion of
>>>>> any scif libraries or class files.
>>>>>
>>>>>
>>>>> When I run it I get:
>>>>>
>>>>> [Michaels-Retina:~/temp/deleteme/my-app] michaelellis% java -cp
>>>>> target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
>>>>> Error: A JNI error has occurred, please check your installation and
>>>>> try again
>>>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>>>> io/scif/SCIFIO
>>>>> at java.lang.Class.getDeclaredMethods0(Native Method)
>>>>> at java.lang.Class.privateGetDeclaredMethods(Class.java:2699)
>>>>> at java.lang.Class.privateGetMethodRecursive(Class.java:3046)
>>>>> at java.lang.Class.getMethod0(Class.java:3016)
>>>>> at java.lang.Class.getMethod(Class.java:1782)
>>>>> at
>>>>> sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
>>>>> at
>>>>> sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
>>>>> Caused by: java.lang.ClassNotFoundException: io.scif.SCIFIO
>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>>>>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>>>>> ... 7 more
>>>>>
>>>>>
>>>>> ========================================================
>>>>>
>>>>> I’ve been banging my head against this for two days now.
>>>>>
>>>>> So any help appreciated
>>>>>
>>>>>
>>>>> On 5 Dec 2014, at 16:35, Curtis Rueden <ctrueden at WISC.EDU> wrote:
>>>>>
>>>>> Hi Michael,
>>>>>
>>>>> > The POM for io.scif:scifio:jar:0.17.1 is missing, no dependency
>>>>> > information available
>>>>>
>>>>> Make sure you have the following <repositories> block in your POM:
>>>>>
>>>>> <repositories>
>>>>> <repository>
>>>>> <id>imagej.public</id>
>>>>> <url>http://maven.imagej.net/content/groups/public</url>
>>>>> </repository>
>>>>> </repositories>
>>>>>
>>>>> Then rebuild with the "-U" flag. I don't know how to do this from
>>>>> NetBeans, but you only need to do it once from the CLI -- then you can
>>>>> return to NetBeans and it should work.
>>>>>
>>>>> Regards,
>>>>> Curtis
>>>>>
>>>>> On Fri, Dec 5, 2014 at 6:07 AM, Michael Ellis <michael.ellis at dsuk.biz>
>>>>> wrote:
>>>>>
>>>>>> I have followed the advice offered by Curtis regarding adding
>>>>>> the io.scif: scifio dependency to my POM
>>>>>>
>>>>>> The dependency part of my POM looks like this:
>>>>>>
>>>>>>     <dependencies>
>>>>>>         <dependency>
>>>>>>             <groupId>net.imglib2</groupId>
>>>>>>             <artifactId>imglib2</artifactId>
>>>>>>             <version>2.2.1-SNAPSHOT</version>
>>>>>>             <type>jar</type>
>>>>>>         </dependency>
>>>>>>         <dependency>
>>>>>>             <groupId>io.scif</groupId>
>>>>>>             <artifactId>scifio</artifactId>
>>>>>>             <version>0.17.1</version>
>>>>>>             <type>jar</type>
>>>>>>         </dependency>
>>>>>>     </dependencies>
>>>>>>
>>>>>> I am using NetBeans IDE, configured for use with maven project (I am
>>>>>> slo using Java 8 and JavaFX)
>>>>>>
>>>>>> However when I attempt to Build (or Build with Dependencies)  within
>>>>>> NetBeans, I get the following error message:
>>>>>> ============================================================
>>>>>>
>>>>>> cd /Users/michaelellis/Documents/Development/MavenImgLib2FX;
>>>>>> JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
>>>>>> "/Applications/NetBeans/NetBeans
>>>>>> 8.0.app/Contents/Resources/NetBeans/java/maven/bin/mvn" install
>>>>>> Scanning for projects...
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> Building MavenImgLib2FX 1.0-SNAPSHOT
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> The POM for io.scif:scifio:jar:0.17.1 is missing, no dependency
>>>>>> information available
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> BUILD FAILURE
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> Total time: 0.341s
>>>>>> Finished at: Fri Dec 05 10:34:41 GMT 2014
>>>>>> Final Memory: 7M/245M
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> Failed to execute goal on project MavenImgLib2FX: Could not resolve
>>>>>> dependencies for project biz.dsuk:MavenImgLib2FX:jar:1.0-SNAPSHOT: Failure
>>>>>> to find io.scif:scifio:jar:0.17.1 in
>>>>>> http://repo.maven.apache.org/maven2 was cached in the local
>>>>>> repository, resolution will not be reattempted until the update interval of
>>>>>> central has elapsed or updates are forced -> [Help 1]
>>>>>>
>>>>>> To see the full stack trace of the errors, re-run Maven with the -e
>>>>>> switch.
>>>>>> Re-run Maven using the -X switch to enable full debug logging.
>>>>>>
>>>>>> For more information about the errors and possible solutions, please
>>>>>> read the following articles:
>>>>>> [Help 1]
>>>>>> http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
>>>>>>
>>>>>> ============================================================
>>>>>>
>>>>>> If I open a terminal window and cd into the project directory and:
>>>>>>
>>>>>> mvn clean package
>>>>>>
>>>>>> It succeeds.
>>>>>>
>>>>>> However, when I then attempt to run the project with:
>>>>>>
>>>>>> java -cp MavenImgLib2FX-1.0-SNAPSHOT.jar
>>>>>> biz.dsuk.mavenimglib2fx.MainApp
>>>>>>
>>>>>> The application starts to execute but throws “No compatible service:
>>>>>> io.scif.SCIFIOService” exception.
>>>>>> ============================================================
>>>>>>
>>>>>> img1=CellImg [20x30]
>>>>>> BufferedImage=BufferedImage at 3137c585: type = 10 ColorModel:
>>>>>> #pixelBits = 8 numComponents = 1 color space =
>>>>>> java.awt.color.ICC_ColorSpace at 134d9d5f transparency = 1 has alpha =
>>>>>> false isAlphaPre = false ByteInterleavedRaster: width = 707 height = 699
>>>>>> #numDataElements 1 dataOff[0] = 0
>>>>>> Loading image...
>>>>>> Exception in Application start method
>>>>>> java.lang.reflect.InvocationTargetException
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>> at
>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>>>>> at
>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>> at java.lang.reflect.Method.invoke(Method.java:497)
>>>>>> at
>>>>>> com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:363)
>>>>>> at
>>>>>> com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:303)
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>> at
>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>>>>> at
>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>> at java.lang.reflect.Method.invoke(Method.java:497)
>>>>>> at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
>>>>>> Caused by: java.lang.RuntimeException: Exception in Application start
>>>>>> method
>>>>>> at
>>>>>> com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
>>>>>> at
>>>>>> com.sun.javafx.application.LauncherImpl.lambda$launchApplication$150(LauncherImpl.java:157)
>>>>>> at
>>>>>> com.sun.javafx.application.LauncherImpl$$Lambda$50/553264065.run(Unknown
>>>>>> Source)
>>>>>> at java.lang.Thread.run(Thread.java:745)
>>>>>> Caused by: java.lang.IllegalArgumentException: No compatible service:
>>>>>> io.scif.SCIFIOService
>>>>>> at
>>>>>> org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:243)
>>>>>> at
>>>>>> org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:194)
>>>>>> at
>>>>>> org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:170)
>>>>>> at org.scijava.Context.<init>(Context.java:244)
>>>>>> at org.scijava.Context.<init>(Context.java:203)
>>>>>> at org.scijava.Context.<init>(Context.java:142)
>>>>>> at org.scijava.Context.<init>(Context.java:128)
>>>>>> at io.scif.SCIFIO.<init>(SCIFIO.java:81)
>>>>>> at biz.dsuk.mavenimglib2fx.MainApp.start(MainApp.java:38)
>>>>>> at
>>>>>> com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$156(LauncherImpl.java:821)
>>>>>> at
>>>>>> com.sun.javafx.application.LauncherImpl$$Lambda$53/681110827.run(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.javafx.application.PlatformImpl.lambda$runAndWait$169(PlatformImpl.java:326)
>>>>>> at
>>>>>> com.sun.javafx.application.PlatformImpl$$Lambda$47/693632176.run(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.javafx.application.PlatformImpl.lambda$null$167(PlatformImpl.java:295)
>>>>>> at
>>>>>> com.sun.javafx.application.PlatformImpl$$Lambda$49/1260282780.run(Unknown
>>>>>> Source)
>>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>>> at
>>>>>> com.sun.javafx.application.PlatformImpl.lambda$runLater$168(PlatformImpl.java:294)
>>>>>> at
>>>>>> com.sun.javafx.application.PlatformImpl$$Lambda$48/1364335809.run(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
>>>>>> Exception running application biz.dsuk.mavenimglib2fx.MainApp
>>>>>> ============================================================
>>>>>>
>>>>>> If I remove the calls to the SCIO code and build and run from the
>>>>>> command line, all works well.
>>>>>>
>>>>>> The SCIO source code that I am using is lifted/amended from one of
>>>>>> the tutorials and is as follows:
>>>>>>
>>>>>> ============================================================
>>>>>>             imagePath =
>>>>>> "8bit-signed&pixelType=int8&lengths=50,50,3,5,7&axes=X,Y,Z,Channel,Time.fake";
>>>>>>             System.out.println("Loading image... '" + imagePath +
>>>>>> "'");
>>>>>>             SCIFIO scifio = new SCIFIO();
>>>>>>             final Reader reader =
>>>>>> scifio.initializer().initializeReader(imagePath);
>>>>>> ============================================================
>>>>>>
>>>>>> This source code works file in the SCIFIO tutorial.
>>>>>>
>>>>>> Any help gratefully appreciated!!!!!
>>>>>>
>>>>>> — Michael Ellis
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 3 Dec 2014, at 19:31, Curtis Rueden <ctrueden at WISC.EDU> wrote:
>>>>>>
>>>>>> Hi Michael,
>>>>>>
>>>>>> > How do I establish what Maven projects I need to include?
>>>>>>
>>>>>> One way to check is using the dependency-maven-plugin like so:
>>>>>>
>>>>>>     mvn dependency:analyze
>>>>>>
>>>>>> This will tell you:
>>>>>>
>>>>>> A) Dependencies you declared but do not actually use; and
>>>>>> B) Dependencies you did not declare directly, but actually need.
>>>>>>
>>>>>> Note that this will only work if your project compiles successfully.
>>>>>> In other words, it is easier to start with "too many" dependencies and pare
>>>>>> down, rather than trying to "build up" from zero.
>>>>>>
>>>>>> So in your case, you can start with the ImgLib2 Examples dependencies
>>>>>> block, run dependency:analyze, and adjust the POM according to its
>>>>>> recommendations.
>>>>>>
>>>>>> > When I go to my NetBeans project dependence, select Add dependency,
>>>>>> > then type SCIF to the query text box, I get a huge list of
>>>>>> > possibilities.
>>>>>>
>>>>>> The dependency you probably want is io.scif:scifio (i.e.: a groupId
>>>>>> of io.scif, and an artifactId of scifio). Presumably at the latest version.
>>>>>> You can search for that here:
>>>>>>
>>>>>>
>>>>>> http://maven.imagej.net/index.html#nexus-search;gav~io.scif~scifio~~~
>>>>>>
>>>>>> So your dependency block in this case would be:
>>>>>>
>>>>>>     <dependency>
>>>>>>       <groupId>io.scif</groupId>
>>>>>>       <artifactId>scifio</artifactId>
>>>>>>       <version>0.17.1</version>
>>>>>>     </dependency>
>>>>>>
>>>>>> Note that that block of XML is available for copy-pasting from the
>>>>>> link above.
>>>>>>
>>>>>> > I am completely new to maven
>>>>>>
>>>>>> For more information, see:
>>>>>>     http://imagej.net/Maven
>>>>>>
>>>>>> Regards,
>>>>>> Curtis
>>>>>>
>>>>>> On Tue, Dec 2, 2014 at 6:05 PM, Michael Ellis <michael.ellis at dsuk.biz
>>>>>> > wrote:
>>>>>>
>>>>>>> I am investigating the using ImgLib2 for a project.
>>>>>>>
>>>>>>> I am using NetBeans and have managed to create a NetBeans Mavern
>>>>>>> project and have  added a dependency for ImgLib2 Core Library and that
>>>>>>> seems to be working OK.
>>>>>>>
>>>>>>> I now want to add the least possible requirements for the purpose of
>>>>>>> opening some image files.
>>>>>>>
>>>>>>> How do I establish what Maven projects I need to include?
>>>>>>>
>>>>>>> I have cloned  the ImgLib2 Examples project and got that working but
>>>>>>> that seems to include all manner of things that I suspect I do not need.
>>>>>>>
>>>>>>> When I go to my NetBeans project dependence, select Add dependency,
>>>>>>> then type SCIF to the query text box, I get a huge list of possibilities.
>>>>>>>
>>>>>>> I am completely new to maven and so do not know what I am doing with
>>>>>>> it!
>>>>>>>
>>>>>>> — Michael Ellis
>>>>>>> Digital Scientific UK Ltd.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> ImageJ-devel mailing list
>>>>>>> ImageJ-devel at imagej.net
>>>>>>> http://imagej.net/mailman/listinfo/imagej-devel
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> ImageJ-devel mailing list
>>>>>> ImageJ-devel at imagej.net
>>>>>> http://imagej.net/mailman/listinfo/imagej-devel
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> ImageJ-devel mailing list
>>>>> ImageJ-devel at imagej.net
>>>>> http://imagej.net/mailman/listinfo/imagej-devel
>>>>>
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> ImageJ-devel mailing list
>>>> ImageJ-devel at imagej.net
>>>> http://imagej.net/mailman/listinfo/imagej-devel
>>>>
>>>>
>>>
>>>
>>
>>
>> _______________________________________________
>> ImageJ-devel mailing list
>> ImageJ-devel at imagej.net
>> http://imagej.net/mailman/listinfo/imagej-devel
>>
>>
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20150123/9e56332d/attachment-0001.html>


More information about the ImageJ-devel mailing list