[ImageJ-devel] [ImgLib2] new Gauss implementation
Tobias Pietzsch
pietzsch at mpi-cbg.de
Mon Sep 3 07:55:53 CDT 2012
Hi all,
a while ago I did an alternative implementation of Gaussian smoothing
(started out as trying to see whether the old one could be made faster).
The basic idea is the same: separate and do 1D line convolutions.
The details differ quite a bit. Instead of handling special cases at
the start/end of lines, images that are smaller than the kernel, etc.
this new implementation simply does a bit of unnecessary extra work,
which makes the code shorter and apparently better suited to the JIT.
Currently the "Gauss3" can be found in the branch "gauss3". I'd like to
merge to master soon. Gauss3 can bring quite a bit of speed-up, e.g. on
my laptop
40ms vs. 70ms for a 1000 x 1000 FloatType image, or
78ms vs. 136ms for a 100 x 100 x 100 FloatType image (sigma=3.0).
I also tried it together with the new neighborhood design in
the DogDetection algorithm (algorithms-legacy).
There I had a speed-up on a 953 x 451 x 48 SPIM image of
3349ms vs. 6036ms so almost twice as fast. (This can be found in
the "tobias-neighborhood-experiments" branch).
Instead of the many static methods of Gauss, the interface of
Gauss3 is deliberately simple. There is one static method, basically:
Gauss3.gauss( final double[] sigma,
final RandomAccessible< S > source,
final RandomAccessibleInterval< T > target )
S and T both extend NumericType, but not necessarily the same, so
your source can be UnsignedByteType and your Result DoubleType for
example. You need to out-of-bounds extend the source yourself, if
there is not enough data beyond the borders (of the target interval).
It figures out which temporary type to use for the calculation on
it's own. If the target type T is DoubleType, all calculations are done
in double precision. For all other target RealTypes, float precision is
used. General NumericTypes are computed in their own arithmetic.
The source type S and target type T must be either both RealTypes or
both the same type.
See net.imglib2.algorithm.gauss3.Gauss3Example (in imglib2-tests package
for how to use it).
Doumentation of the internals is still rather sparse. I hope I'll find
some time to improve that soon. I'll try to merge to master next week,
maybe I'll need some hand-holding then to make it play nice with the
fiji javac...
best regards,
Tobias
More information about the ImageJ-devel
mailing list