Skip to content

Commit 431da40

Browse files
elevanshinerm
authored andcommitted
Apply obf constant value if non-circulant
If non-circulant mode is desired, apply the OutOfBoundsConstantValueFactory.
1 parent 98b46a0 commit 431da40

2 files changed

Lines changed: 42 additions & 7 deletions

File tree

scijava-ops-image/src/main/java/org/scijava/ops/image/deconvolve/PadAndRichardsonLucy.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import net.imglib2.Dimensions;
3737
import net.imglib2.FinalDimensions;
3838
import net.imglib2.RandomAccessibleInterval;
39+
import net.imglib2.outofbounds.OutOfBoundsConstantValueFactory;
3940
import net.imglib2.outofbounds.OutOfBoundsMirrorFactory;
4041
import net.imglib2.outofbounds.OutOfBoundsFactory;
4142
import net.imglib2.type.NativeType;
@@ -216,16 +217,30 @@ public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input,
216217
@Nullable Boolean accelerate, @Nullable long[] borderSize,
217218
@Nullable OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput)
218219
{
219-
if (obfInput == null) obfInput = new OutOfBoundsMirrorFactory<>(
220-
OutOfBoundsMirrorFactory.Boundary.SINGLE);
221-
220+
// default to circulant
222221
if (nonCirculant == null) {
223-
this.nonCirculant = false;
222+
nonCirculant = false;
223+
this.nonCirculant = nonCirculant;
224224
}
225225
else {
226226
this.nonCirculant = nonCirculant;
227227
}
228228

229+
// out of bounds factory will be different depending on if circulant or
230+
// non-circulant is used
231+
if (obfInput == null) {
232+
233+
if (!nonCirculant) {
234+
obfInput = new OutOfBoundsMirrorFactory<>(
235+
OutOfBoundsMirrorFactory.Boundary.SINGLE);
236+
}
237+
else if (nonCirculant) {
238+
obfInput = new OutOfBoundsConstantValueFactory<>(Util
239+
.getTypeFromInterval(input).createVariable());
240+
}
241+
}
242+
243+
// default to no acceleration
229244
if (accelerate == null) {
230245
accelerate = false;
231246
}

scijava-ops-image/src/main/java/org/scijava/ops/image/deconvolve/PadAndRichardsonLucyTV.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import net.imglib2.FinalDimensions;
3939
import net.imglib2.RandomAccessibleInterval;
4040
import net.imglib2.outofbounds.OutOfBoundsMirrorFactory;
41+
import net.imglib2.outofbounds.OutOfBoundsConstantValueFactory;
4142
import net.imglib2.outofbounds.OutOfBoundsFactory;
4243
import net.imglib2.type.NativeType;
4344
import net.imglib2.type.numeric.ComplexType;
@@ -206,10 +207,29 @@ public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input,
206207
Float regularizationFactor, @Nullable long[] borderSize,
207208
@Nullable OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput)
208209
{
209-
if (obfInput == null) obfInput = new OutOfBoundsMirrorFactory<>(
210-
OutOfBoundsMirrorFactory.Boundary.SINGLE);
210+
// default to circulant
211+
if (nonCirculant == null) {
212+
nonCirculant = false;
213+
this.nonCirculant = nonCirculant;
214+
}
215+
else {
216+
this.nonCirculant = nonCirculant;
217+
}
218+
219+
// out of bounds factory will be different depending on if circulant or
220+
// non-circulant is used
221+
if (obfInput == null) {
222+
223+
if (!nonCirculant) {
224+
obfInput = new OutOfBoundsMirrorFactory<>(
225+
OutOfBoundsMirrorFactory.Boundary.SINGLE);
226+
}
227+
else if (nonCirculant) {
228+
obfInput = new OutOfBoundsConstantValueFactory<>(Util
229+
.getTypeFromInterval(input).createVariable());
230+
}
231+
}
211232

212-
this.nonCirculant = nonCirculant;
213233
this.maxIterations = maxIterations;
214234
this.regularizationFactor = regularizationFactor;
215235

0 commit comments

Comments
 (0)