Skip to content

Commit

Permalink
Merge pull request #558 from imagej/decon_iteration
Browse files Browse the repository at this point in the history
Decon iteration
  • Loading branch information
bnorthan authored Jun 14, 2018
2 parents c63e09e + f41edc3 commit 010510b
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 126 deletions.
113 changes: 60 additions & 53 deletions src/main/java/net/imagej/ops/deconvolve/DeconvolveNamespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ RandomAccessibleInterval<O> richardsonLucy(
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyF.class)
public <
I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<I> in,
final RandomAccessibleInterval<K> kernel, final long[] borderSize,
Expand All @@ -159,8 +158,7 @@ RandomAccessibleInterval<O> richardsonLucy(
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyF.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<I> in,
final RandomAccessibleInterval<K> kernel, final long[] borderSize,
Expand All @@ -178,8 +176,7 @@ RandomAccessibleInterval<O> richardsonLucy(
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyF.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<I> in,
final RandomAccessibleInterval<K> kernel, final long[] borderSize,
Expand All @@ -199,123 +196,141 @@ RandomAccessibleInterval<O> richardsonLucy(
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2, final int maxIterations)
{
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<O> result =
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
maxIterations);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput, final int maxIterations)
{
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<O> result =
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, maxIterations);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput,
final RandomAccessibleInterval<C> fftKernel, final int maxIterations,
final Interval imgConvolutionInterval)
final RandomAccessibleInterval<C> fftKernel, final int maxIterations)
{
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<O> result =
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, fftKernel, maxIterations, imgConvolutionInterval);
fftInput, fftKernel, maxIterations);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput,
final RandomAccessibleInterval<C> fftKernel,
final boolean performInputFFT, final int maxIterations,
final Interval imgConvolutionInterval)
final boolean performInputFFT, final int maxIterations)
{
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<O> result =
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, fftKernel, performInputFFT, maxIterations,
imgConvolutionInterval);
fftInput, fftKernel, performInputFFT, maxIterations);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput,
final RandomAccessibleInterval<C> fftKernel,
final boolean performInputFFT, final boolean performKernelFFT,
final int maxIterations, final Interval imgConvolutionInterval)
final int maxIterations)
{
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<O> result =
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, fftKernel, performInputFFT, performKernelFFT, maxIterations,
imgConvolutionInterval);
fftInput, fftKernel, performInputFFT, performKernelFFT, maxIterations);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput,
final RandomAccessibleInterval<C> fftKernel,
final boolean performInputFFT, final boolean performKernelFFT,
final int maxIterations, final Interval imgConvolutionInterval,
final UnaryInplaceOp<O, O> accelerator)
final int maxIterations, final UnaryInplaceOp<O, O> accelerator)
{
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<O> result =
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, fftKernel, performInputFFT, performKernelFFT, maxIterations,
imgConvolutionInterval, accelerator);
accelerator);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput,
final RandomAccessibleInterval<C> fftKernel,
final boolean performInputFFT, final boolean performKernelFFT,
final int maxIterations, final Interval imgConvolutionInterval,
final UnaryInplaceOp<O, O> accelerator,
final int maxIterations, final UnaryInplaceOp<O, O> accelerator,
final UnaryComputerOp<RandomAccessibleInterval<O>, RandomAccessibleInterval<O>> update)
{
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<O> result =
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, fftKernel, performInputFFT, performKernelFFT, maxIterations,
imgConvolutionInterval, accelerator, update);
accelerator, update);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput,
final RandomAccessibleInterval<C> fftKernel,
final boolean performInputFFT, final boolean performKernelFFT,
final int maxIterations, final Interval imgConvolutionInterval,
final UnaryInplaceOp<O, O> accelerator,
final int maxIterations, final UnaryInplaceOp<O, O> accelerator,
final UnaryComputerOp<RandomAccessibleInterval<O>, RandomAccessibleInterval<O>> update,
RandomAccessibleInterval<O> raiExtendedEstimate)
{
Expand All @@ -324,22 +339,20 @@ RandomAccessibleInterval<O> richardsonLucy(
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, fftKernel, performInputFFT, performKernelFFT, maxIterations,
imgConvolutionInterval, accelerator, update, raiExtendedEstimate);
accelerator, update, raiExtendedEstimate);
return result;
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyC.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucy(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
final RandomAccessibleInterval<K> in2,
final RandomAccessibleInterval<C> fftInput,
final RandomAccessibleInterval<C> fftKernel,
final boolean performInputFFT, final boolean performKernelFFT,
final int maxIterations, final Interval imgConvolutionInterval,
final UnaryInplaceOp<O, O> accelerator,
final int maxIterations, final UnaryInplaceOp<O, O> accelerator,
final UnaryComputerOp<RandomAccessibleInterval<O>, RandomAccessibleInterval<O>> update,
RandomAccessibleInterval<O> raiExtendedEstimate,
final ArrayList<UnaryInplaceOp<RandomAccessibleInterval<O>, RandomAccessibleInterval<O>>> iterativePostProcessing)
Expand All @@ -349,8 +362,7 @@ RandomAccessibleInterval<O> richardsonLucy(
(RandomAccessibleInterval<O>) ops().run(
net.imagej.ops.deconvolve.RichardsonLucyC.class, out, in1, in2,
fftInput, fftKernel, performInputFFT, performKernelFFT, maxIterations,
imgConvolutionInterval, accelerator, update, raiExtendedEstimate,
iterativePostProcessing);
accelerator, update, raiExtendedEstimate, iterativePostProcessing);
return result;
}

Expand Down Expand Up @@ -439,8 +451,7 @@ RandomAccessibleInterval<O> richardsonLucyTV(
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyTVF.class)
public <
I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucyTV(
final RandomAccessibleInterval<I> in,
final RandomAccessibleInterval<K> kernel, final long[] borderSize,
Expand All @@ -459,8 +470,7 @@ RandomAccessibleInterval<O> richardsonLucyTV(
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyTVF.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucyTV(
final RandomAccessibleInterval<I> in,
final RandomAccessibleInterval<K> kernel, final long[] borderSize,
Expand All @@ -479,8 +489,7 @@ RandomAccessibleInterval<O> richardsonLucyTV(
}

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyTVF.class)
public <
I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucyTV(
final RandomAccessibleInterval<I> in,
final RandomAccessibleInterval<K> kernel, final long[] borderSize,
Expand All @@ -502,8 +511,7 @@ RandomAccessibleInterval<O> richardsonLucyTV(
// -- richardson lucy correction ops

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyCorrection.class)
public <
I extends RealType<I>, O extends RealType<O>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucyCorrection(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<I> in1,
Expand All @@ -522,8 +530,7 @@ RandomAccessibleInterval<O> richardsonLucyCorrection(
// -- richardson lucy update ops

@OpMethod(op = net.imagej.ops.deconvolve.RichardsonLucyTVUpdate.class)
public <
I extends RealType<I>, O extends RealType<O>, C extends ComplexType<C>>
public <I extends RealType<I>, O extends RealType<O>, C extends ComplexType<C>>
RandomAccessibleInterval<O> richardsonLucyUpdate(
final RandomAccessibleInterval<O> out,
final RandomAccessibleInterval<O> in, final float regularizationFactor)
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/net/imagej/ops/deconvolve/RichardsonLucyC.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

/**
* Richardson Lucy algorithm for (@link RandomAccessibleInterval) (Lucy, L. B.
* (1974).
* "An iterative technique for the rectification of observed distributions".)
* (1974). "An iterative technique for the rectification of observed
* distributions".)
*
* @author Brian Northan
* @param <I>
Expand All @@ -70,8 +70,7 @@
* @param <C>
*/

@Plugin(type = Ops.Deconvolve.RichardsonLucy.class,
priority = Priority.HIGH)
@Plugin(type = Ops.Deconvolve.RichardsonLucy.class, priority = Priority.HIGH)
public class RichardsonLucyC<I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
extends AbstractIterativeFFTFilterC<I, O, K, C> implements
Ops.Deconvolve.RichardsonLucy
Expand Down Expand Up @@ -155,17 +154,27 @@ public void initialize() {
public void compute(RandomAccessibleInterval<I> in,
RandomAccessibleInterval<K> kernel, RandomAccessibleInterval<O> out)
{
// create FFT input memory if needed
if (getFFTInput() == null) {
setFFTInput(getCreateOp().calculate(in));
}

// create FFT kernel memory if needed
if (getFFTKernel() == null) {
setFFTKernel(getCreateOp().calculate(in));
}

// if a starting point for the estimate was not passed in then create
// estimate Img and use the input as the starting point
if (raiExtendedEstimate == null) {

raiExtendedEstimate = createOp.calculate(getImgConvolutionInterval());
raiExtendedEstimate = createOp.calculate(in);

copyOp.compute(in, raiExtendedEstimate);
}

// create image for the reblurred
raiExtendedReblurred = createOp.calculate(getImgConvolutionInterval());
raiExtendedReblurred = createOp.calculate(in);

// perform fft of psf
fftKernelOp.compute(kernel, getFFTKernel());
Expand Down
Loading

0 comments on commit 010510b

Please sign in to comment.