Skip to content

Commit 7058869

Browse files
gselzerctrueden
authored andcommitted
WIP: fix deconvolution ops
1 parent e2126b4 commit 7058869

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/main/java/net/imagej/ops/deconvolve/RichardsonLucyCorrection.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929

3030
package net.imagej.ops.deconvolve;
3131

32-
import java.util.Iterator;
3332
import java.util.concurrent.ExecutorService;
3433
import java.util.function.BiFunction;
3534
import java.util.function.Function;
3635

36+
import net.imglib2.Cursor;
3737
import net.imglib2.Dimensions;
38+
import net.imglib2.IterableInterval;
39+
import net.imglib2.RandomAccess;
3840
import net.imglib2.RandomAccessibleInterval;
3941
import net.imglib2.img.Img;
4042
import net.imglib2.type.numeric.ComplexType;
@@ -44,9 +46,9 @@
4446
import org.scijava.Priority;
4547
import org.scijava.ops.OpDependency;
4648
import org.scijava.ops.core.Op;
47-
import org.scijava.ops.core.computer.Computer3;
4849
import org.scijava.ops.core.computer.Computer5;
4950
import org.scijava.ops.core.computer.Computer7;
51+
import org.scijava.ops.core.inplace.Inplace3First;
5052
import org.scijava.param.Parameter;
5153
import org.scijava.plugin.Plugin;
5254
import org.scijava.struct.ItemIO;
@@ -88,14 +90,17 @@ public class RichardsonLucyCorrection<I extends RealType<I>, O extends RealType<
8890

8991
//TODO is this allowed (to divide an O by an I)? Should it be?
9092
// @OpDependency(name = "math.divide") TODO: allow the matcher to fix this
91-
private Computer3<Iterable<O>, Iterable<I>, Double, Iterable<O>> divide = (in1, in2, in3, out) -> {
92-
Iterator<O> itr1 = in1.iterator();
93-
Iterator<I> itr2 = in2.iterator();
94-
Iterator<O> itrout = out.iterator();
93+
private Inplace3First<IterableInterval<O>, RandomAccessibleInterval<I>, Double> divide = (io, in2, in3) -> {
94+
Cursor<O> ioCursor = io.cursor();
95+
RandomAccess<I> inRA = in2.randomAccess();
9596

96-
while(itr1.hasNext() && itr2.hasNext() && itrout.hasNext()) {
97-
Double val2 = itr2.next().getRealDouble();
98-
itrout.next().setReal(val2 == 0 ? in3 : itr1.next().getRealDouble() / val2);
97+
while(ioCursor.hasNext()) {
98+
Double val1 = ioCursor.next().getRealDouble();
99+
inRA.setPosition(ioCursor);
100+
Double val2 = inRA.get().getRealDouble();
101+
if(val2 != 0) System.out.println(val2);
102+
if(val1 == 0) ioCursor.next().setReal(in3);
103+
else ioCursor.next().setReal(val2 / val1);
99104
}
100105
};
101106

@@ -115,10 +120,8 @@ public void compute(RandomAccessibleInterval<I> observed,
115120
ExecutorService es,
116121
RandomAccessibleInterval<O> correction)
117122
{
118-
RandomAccessibleInterval<O> copyReblurred = copy.apply(reblurred);
119-
120123
// divide observed image by reblurred
121-
divide.compute(Views.iterable(reblurred), Views.iterable(observed), 0.0, Views.iterable(copyReblurred));
124+
divide.mutate(Views.iterable(reblurred), observed, 0.0);
122125

123126
// correlate with psf to compute the correction factor
124127
// Note: FFT of psf is pre-computed and set as an input parameter of the op

src/main/java/net/imagej/ops/deconvolve/RichardsonLucyF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public class RichardsonLucyF<I extends RealType<I> & NativeType<I>, O extends Re
108108
@OpDependency(name = "filter.padInputFFTMethods")
109109
private Function4<RandomAccessibleInterval<I>, Dimensions, Boolean, OutOfBoundsFactory<I, RandomAccessibleInterval<I>>, RandomAccessibleInterval<I>> padOp;
110110

111-
@OpDependency(name = "filter.padShiftFFTKernel")
111+
@OpDependency(name = "filter.padShiftKernelFFTMethods")
112112
private BiFunction<RandomAccessibleInterval<K>, Dimensions, RandomAccessibleInterval<K>> padKernelOp;
113113

114114
@OpDependency(name = "filter.createFFTOutput")

src/main/java/net/imagej/ops/filter/convolve/ConvolveFFTC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
public class ConvolveFFTC<I extends RealType<I>, O extends RealType<O>, K extends RealType<K>, C extends ComplexType<C>>
6868
implements Computer7<RandomAccessibleInterval<I>, RandomAccessibleInterval<K>, RandomAccessibleInterval<C>, RandomAccessibleInterval<C>, Boolean, Boolean, ExecutorService, RandomAccessibleInterval<O>> {
6969

70-
@OpDependency(name = "math.complexConjugateMultiply")
70+
@OpDependency(name = "math.multiply")
7171
private BiComputer<RandomAccessibleInterval<C>, RandomAccessibleInterval<C>, RandomAccessibleInterval<C>> mul;
7272

7373
@OpDependency(name = "filter.linearFilter")

0 commit comments

Comments
 (0)