public class FFTConvolution<R extends RealType<R>> extends Object
setKernel(RandomAccessibleInterval< R > kernel)
or
setKernel(RandomAccessible< R > kernel, Interval kernelInterval)
. The Fourier
convolution will keep the FFT of the image which will speed up all
convolutions after the initial run() call. NOTE: There is no checking if the
sizes are compatible. If the new kernel has smaller or larger dimensions, it
will simply fail. It is up to you to look for that. NOTE: This is not
influenced by whether the computation is performed in-place or not, just the
FFT of the image is kept.
In the same way, you can sequentially convolve varying images with the same
kernel. For that, you simply have to replace the image after the first run()
call by calling either setImg(RandomAccessibleInterval< R > img)
or
setImg(RandomAccessible< R > img, Interval imgInterval)
. The Fourier
convolution will keep the FFT of the kernel which will speed up all
convolutions after the initial run() call. NOTE: There is no checking if the
sizes are compatible. If the new input has smaller or larger dimensions, it
will simply fail. It is up to you to look for that. NOTE: This is not
influenced by whether the computation is performed in-place or not, just the
FFT of the kernel is kept.Constructor and Description |
---|
FFTConvolution(Img<R> img,
Img<R> kernel)
Compute a Fourier space based convolution in-place (img will be replaced
by the convolved result).
|
FFTConvolution(Img<R> img,
Img<R> kernel,
ExecutorService service)
Compute a Fourier space based convolution in-place (img will be replaced
by the convolved result).
|
FFTConvolution(Img<R> img,
Img<R> kernel,
RandomAccessibleInterval<R> output)
Compute a Fourier space based convolution The image will be extended by
mirroring with single boundary, the kernel will be zero-padded.
|
FFTConvolution(Img<R> img,
Img<R> kernel,
RandomAccessibleInterval<R> output,
ExecutorService service)
Compute a Fourier space based convolution The image will be extended by
mirroring with single boundary, the kernel will be zero-padded.
|
FFTConvolution(RandomAccessible<R> img,
Interval imgInterval,
RandomAccessible<R> kernel,
Interval kernelInterval,
ImgFactory<ComplexFloatType> factory)
Compute a Fourier space based convolution in-place (img will be replaced
by the convolved result).
|
FFTConvolution(RandomAccessible<R> img,
Interval imgInterval,
RandomAccessible<R> kernel,
Interval kernelInterval,
ImgFactory<ComplexFloatType> factory,
ExecutorService service)
Compute a Fourier space based convolution in-place (img will be replaced
by the convolved result).
|
FFTConvolution(RandomAccessible<R> img,
Interval imgInterval,
RandomAccessible<R> kernel,
Interval kernelInterval,
RandomAccessibleInterval<R> output,
ImgFactory<ComplexFloatType> factory)
Compute a Fourier space based convolution.
|
FFTConvolution(RandomAccessible<R> img,
Interval imgInterval,
RandomAccessible<R> kernel,
Interval kernelInterval,
RandomAccessibleInterval<R> output,
ImgFactory<ComplexFloatType> factory,
ExecutorService service)
Compute a Fourier space based convolution.
|
FFTConvolution(RandomAccessibleInterval<R> img,
RandomAccessibleInterval<R> kernel,
ImgFactory<ComplexFloatType> factory)
Compute a Fourier space based convolution in-place (img will be replaced
by the convolved result).
|
FFTConvolution(RandomAccessibleInterval<R> img,
RandomAccessibleInterval<R> kernel,
ImgFactory<ComplexFloatType> factory,
ExecutorService service)
Compute a Fourier space based convolution in-place (img will be replaced
by the convolved result).
|
FFTConvolution(RandomAccessibleInterval<R> img,
RandomAccessibleInterval<R> kernel,
RandomAccessibleInterval<R> output,
ImgFactory<ComplexFloatType> factory)
Compute a Fourier space based convolution The image will be extended by
mirroring with single boundary, the kernel will be zero-padded.
|
FFTConvolution(RandomAccessibleInterval<R> img,
RandomAccessibleInterval<R> kernel,
RandomAccessibleInterval<R> output,
ImgFactory<ComplexFloatType> factory,
ExecutorService service)
Compute a Fourier space based convolution The image will be extended by
mirroring with single boundary, the kernel will be zero-padded.
|
Modifier and Type | Method and Description |
---|---|
static <R extends RealType<R>> |
computeConvolution(Img<ComplexFloatType> fftImg,
Img<ComplexFloatType> fftKernel,
RandomAccessibleInterval<R> output,
boolean keepImgFFT,
boolean div,
ExecutorService service) |
static <R extends RealType<R>> |
computeImgFFT(Interval imgConvolutionInterval,
RandomAccessible<R> img,
ImgFactory<ComplexFloatType> fftFactory,
ExecutorService service) |
static <R extends RealType<R>> |
computeKernelFFT(Interval kernelConvolutionInterval,
long[] min,
long[] max,
boolean complexConjugate,
RandomAccessible<R> kernel,
ImgFactory<ComplexFloatType> fftFactory,
ExecutorService service) |
void |
convolve() |
static <R extends RealType<R>> |
convolve(RandomAccessible<R> img,
Interval imgInterval,
RandomAccessible<R> kernel,
Interval kernelInterval,
RandomAccessibleInterval<R> output,
ImgFactory<ComplexFloatType> factory,
boolean div,
ExecutorService service) |
static ExecutorService |
createExecutorService()
Utility function to create an ExecutorService
Number of threads utilized matches available processors in runtime.
|
static ExecutorService |
createExecutorService(int nThreads)
Utility function to create an ExecutorService
|
ImgFactory<ComplexFloatType> |
fftImgFactory() |
boolean |
getComplexConjugate() |
boolean |
getDiv() |
protected static ImgFactory<ComplexFloatType> |
getFFTFactory(Img<? extends RealType<?>> img) |
Img<ComplexFloatType> |
imgFFT() |
boolean |
keepImgFFT() |
Img<ComplexFloatType> |
kernelFFT() |
static void |
multiplyDivideComplex(Img<ComplexFloatType> img,
Img<ComplexFloatType> kernel,
boolean div) |
void |
setComputeComplexConjugate(boolean complexConjugate) |
void |
setDiv(boolean div) |
void |
setExecutorService(ExecutorService service)
Set the executor service to use.
|
void |
setFFTImgFactory(ImgFactory<ComplexFloatType> factory) |
void |
setImg(RandomAccessible<R> img,
Interval imgInterval) |
void |
setImg(RandomAccessibleInterval<R> img) |
void |
setImgFFT(Img<ComplexFloatType> fftImg)
Sets the FFT image as computed, be very careful with this method, if any parameters of the FFT are wrong, this will fail
WARNING: if you do not set keepImgFFT, this image will be modified during convolution
|
void |
setKeepImgFFT(boolean keep) |
void |
setKernel(RandomAccessible<R> kernel,
Interval kernelInterval) |
void |
setKernel(RandomAccessibleInterval<R> kernel) |
void |
setKernelFFT(Img<ComplexFloatType> fftKernel)
Sets the FFT kernel as computed, be very careful with this method, if any parameters of the FFT are wrong, this will fail
|
void |
setOutput(RandomAccessibleInterval<R> output) |
static Pair<Interval,Interval> |
setupFFTs(Interval imgInterval,
Interval kernelInterval,
long[] min,
long[] max) |
public FFTConvolution(Img<R> img, Img<R> kernel)
ImgFactory
for creating the FFT will be identical to the one used by the 'img' if
possible, otherwise an ArrayImgFactory
or CellImgFactory
depending on the size.
ExecutorService will be created on convolve()
with threads equal
to number of processors equal to the runtime.img
- - the imagekernel
- - the convolution kernelpublic FFTConvolution(Img<R> img, Img<R> kernel, ExecutorService service)
ImgFactory
for creating the FFT will be identical to the one used by the 'img' if
possible, otherwise an ArrayImgFactory
or CellImgFactory
depending on the size.img
- - the imagekernel
- - the convolution kernelservice
- - service providing threads for multi-threadingpublic FFTConvolution(Img<R> img, Img<R> kernel, RandomAccessibleInterval<R> output)
ImgFactory
for creating the FFT will be identical to the one used
by the 'img' if possible, otherwise an ArrayImgFactory
or
CellImgFactory
depending on the size.
ExecutorService will be created on convolve()
with threads equal
to number of processors equal to the runtime.img
- - the imagekernel
- - the convolution kerneloutput
- - the result of the convolutionpublic FFTConvolution(Img<R> img, Img<R> kernel, RandomAccessibleInterval<R> output, ExecutorService service)
ImgFactory
for creating the FFT will be identical to the one used
by the 'img' if possible, otherwise an ArrayImgFactory
or
CellImgFactory
depending on the size.img
- - the imagekernel
- - the convolution kerneloutput
- - the result of the convolutionservice
- - service providing threads for multi-threadingpublic FFTConvolution(RandomAccessibleInterval<R> img, RandomAccessibleInterval<R> kernel, ImgFactory<ComplexFloatType> factory)
convolve()
with threads equal
to number of processors equal to the runtime.img
- - the imagekernel
- - the convolution kernelfactory
- - the ImgFactory
to create the fourier transformspublic FFTConvolution(RandomAccessibleInterval<R> img, RandomAccessibleInterval<R> kernel, ImgFactory<ComplexFloatType> factory, ExecutorService service)
img
- - the imagekernel
- - the convolution kernelfactory
- - the ImgFactory
to create the fourier transformsservice
- - service providing threads for multi-threadingpublic FFTConvolution(RandomAccessibleInterval<R> img, RandomAccessibleInterval<R> kernel, RandomAccessibleInterval<R> output, ImgFactory<ComplexFloatType> factory)
convolve()
with threads equal
to number of processors equal to the runtime.img
- - the imagekernel
- - the convolution kerneloutput
- - the outputfactory
- - the ImgFactory
to create the fourier transformspublic FFTConvolution(RandomAccessibleInterval<R> img, RandomAccessibleInterval<R> kernel, RandomAccessibleInterval<R> output, ImgFactory<ComplexFloatType> factory, ExecutorService service)
img
- - the imagekernel
- - the convolution kerneloutput
- - the outputfactory
- - the ImgFactory
to create the fourier transformsservice
- - service providing threads for multi-threadingpublic FFTConvolution(RandomAccessible<R> img, Interval imgInterval, RandomAccessible<R> kernel, Interval kernelInterval, ImgFactory<ComplexFloatType> factory)
Interval
required to perform
the Fourier convolution is significantly bigger than the Interval
provided here.
Interval size of img and kernel: size(img) + 2*(size(kernel)-1) + pad to
fft compatible size
ExecutorService will be created on convolve()
with threads equal
to number of processors equal to the runtime.img
- - the inputimgInterval
- - the input interval (i.e. the area to be convolved)kernel
- - the kernelkernelInterval
- - the kernel intervalfactory
- - the ImgFactory
to create the fourier transformspublic FFTConvolution(RandomAccessible<R> img, Interval imgInterval, RandomAccessible<R> kernel, Interval kernelInterval, ImgFactory<ComplexFloatType> factory, ExecutorService service)
Interval
required to perform
the Fourier convolution is significantly bigger than the Interval
provided here.
Interval size of img and kernel: size(img) + 2*(size(kernel)-1) + pad to
fft compatible sizeimg
- - the inputimgInterval
- - the input interval (i.e. the area to be convolved)kernel
- - the kernelkernelInterval
- - the kernel intervalfactory
- - the ImgFactory
to create the fourier transformsservice
- - service providing threads for multi-threadingpublic FFTConvolution(RandomAccessible<R> img, Interval imgInterval, RandomAccessible<R> kernel, Interval kernelInterval, RandomAccessibleInterval<R> output, ImgFactory<ComplexFloatType> factory)
Interval
required to perform the Fourier convolution is significantly bigger than
the Interval
provided here.
Interval size of img and kernel: size(img) + 2*(size(kernel)-1) + pad to
fft compatible size
ExecutorService will be created on convolve()
with threads equal
to number of processors equal to the runtime.img
- - the inputimgInterval
- - the input interval (i.e. the area to be convolved)kernel
- - the kernelkernelInterval
- - the kernel intervaloutput
- - the output data+intervalfactory
- - the ImgFactory
to create the fourier transformspublic FFTConvolution(RandomAccessible<R> img, Interval imgInterval, RandomAccessible<R> kernel, Interval kernelInterval, RandomAccessibleInterval<R> output, ImgFactory<ComplexFloatType> factory, ExecutorService service)
Interval
required to perform the Fourier convolution is significantly bigger than
the Interval
provided here.
Interval size of img and kernel: size(img) + 2*(size(kernel)-1) + pad to
fft compatible sizeimg
- - the inputimgInterval
- - the input interval (i.e. the area to be convolved)kernel
- - the kernelkernelInterval
- - the kernel intervaloutput
- - the output data+intervalfactory
- - the ImgFactory
to create the fourier transformsservice
- - service providing threads for multi-threadingpublic void setImg(RandomAccessibleInterval<R> img)
public void setImg(RandomAccessible<R> img, Interval imgInterval)
public void setKernel(RandomAccessibleInterval<R> kernel)
public void setKernel(RandomAccessible<R> kernel, Interval kernelInterval)
public void setOutput(RandomAccessibleInterval<R> output)
public void setComputeComplexConjugate(boolean complexConjugate)
complexConjugate
- - If the complex conjugate of the FFT of the kernel should be
used.public boolean getComplexConjugate()
public void setDiv(boolean div)
div
- - perform deconvolution instead of convolution.public boolean getDiv()
public void setKeepImgFFT(boolean keep)
public boolean keepImgFFT()
public void setFFTImgFactory(ImgFactory<ComplexFloatType> factory)
public ImgFactory<ComplexFloatType> fftImgFactory()
public Img<ComplexFloatType> imgFFT()
public Img<ComplexFloatType> kernelFFT()
public void setKernelFFT(Img<ComplexFloatType> fftKernel)
fftKernel
- - the FFT of the kernelpublic void setImgFFT(Img<ComplexFloatType> fftImg)
fftImg
- - the FFT of the imagepublic void convolve()
public static Pair<Interval,Interval> setupFFTs(Interval imgInterval, Interval kernelInterval, long[] min, long[] max)
public static <R extends RealType<R>> Img<ComplexFloatType> computeImgFFT(Interval imgConvolutionInterval, RandomAccessible<R> img, ImgFactory<ComplexFloatType> fftFactory, ExecutorService service)
public static <R extends RealType<R>> Img<ComplexFloatType> computeKernelFFT(Interval kernelConvolutionInterval, long[] min, long[] max, boolean complexConjugate, RandomAccessible<R> kernel, ImgFactory<ComplexFloatType> fftFactory, ExecutorService service)
public static <R extends RealType<R>> void computeConvolution(Img<ComplexFloatType> fftImg, Img<ComplexFloatType> fftKernel, RandomAccessibleInterval<R> output, boolean keepImgFFT, boolean div, ExecutorService service)
public static final <R extends RealType<R>> void convolve(RandomAccessible<R> img, Interval imgInterval, RandomAccessible<R> kernel, Interval kernelInterval, RandomAccessibleInterval<R> output, ImgFactory<ComplexFloatType> factory, boolean div, ExecutorService service)
public static final void multiplyDivideComplex(Img<ComplexFloatType> img, Img<ComplexFloatType> kernel, boolean div)
protected static ImgFactory<ComplexFloatType> getFFTFactory(Img<? extends RealType<?>> img)
public void setExecutorService(ExecutorService service)
convolve()
, using
as many Thread
s as Runtime.availableProcessors()
, which
will be ExecutorService.shutdownNow()
when done.
Otherwise, the caller is responsible for shutting down the provided
ExecutorService
.service
- - Executor service to use.public static final ExecutorService createExecutorService()
public static final ExecutorService createExecutorService(int nThreads)
nThreads
- - number of threads to utilizeCopyright © 2015–2022 ImgLib2. All rights reserved.