Skip to content

Commit 0ba7f92

Browse files
committed
Beautify FFT Ops
1 parent d20fb73 commit 0ba7f92

4 files changed

Lines changed: 25 additions & 32 deletions

File tree

scijava-ops-image/src/main/java/org/scijava/ops/image/filter/fft/CreateOutputFFTMethods.java

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import net.imglib2.img.Img;
3636

3737
import org.scijava.function.Functions;
38+
import org.scijava.ops.spi.Nullable;
3839
import org.scijava.ops.spi.OpDependency;
3940

4041
/**
@@ -52,13 +53,16 @@ public class CreateOutputFFTMethods<T> implements Functions.Arity3<Dimensions, T
5253
/**
5354
* TODO
5455
*
55-
* @param Dimensions
56-
* @param outType
56+
* @param paddedDimensions the size of the output image
57+
* @param outType the type of the output image
5758
* @param fast
5859
* @return the output
5960
*/
6061
@Override
61-
public Img<T> apply(Dimensions paddedDimensions, T outType, Boolean fast) {
62+
public Img<T> apply(Dimensions paddedDimensions, T outType, @Nullable Boolean fast) {
63+
if (fast == null) {
64+
fast = true;
65+
}
6266

6367
Dimensions paddedFFTMethodsFFTDimensions = FFTMethodsUtility.getFFTDimensionsRealToComplex(fast,
6468
paddedDimensions);
@@ -67,23 +71,3 @@ public Img<T> apply(Dimensions paddedDimensions, T outType, Boolean fast) {
6771
}
6872

6973
}
70-
71-
/**
72-
*@implNote op names='filter.createFFTOutput'
73-
*/
74-
class CreateOutputFFTMethodsSimple<T> implements BiFunction<Dimensions, T, Img<T>> {
75-
@OpDependency(name = "filter.createFFTOutput")
76-
private Functions.Arity3<Dimensions, T, Boolean, Img<T>> create;
77-
78-
/**
79-
* TODO
80-
*
81-
* @param Dimensions
82-
* @param outType
83-
* @return the output
84-
*/
85-
@Override
86-
public Img<T> apply(Dimensions paddedDimensions, T outType) {
87-
return create.apply(paddedDimensions, outType, true);
88-
}
89-
}

scijava-ops-image/src/main/java/org/scijava/ops/image/filter/fft/FFTMethodsOpF.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import org.scijava.function.Computers;
4040
import org.scijava.function.Functions;
41+
import org.scijava.ops.spi.Nullable;
4142
import org.scijava.ops.spi.OpDependency;
4243

4344
/**
@@ -51,7 +52,7 @@
5152
* @implNote op names='filter.fft', priority='100.'
5253
*/
5354
public class FFTMethodsOpF<T extends RealType<T>, C extends ComplexType<C>> implements
54-
Functions.Arity4<RandomAccessibleInterval<T>, long[], Boolean, C, RandomAccessibleInterval<C>> {
55+
Functions.Arity4<RandomAccessibleInterval<T>, C, long[], Boolean, RandomAccessibleInterval<C>> {
5556

5657
@OpDependency(name = "filter.padInputFFTMethods")
5758
private Functions.Arity4<RandomAccessibleInterval<T>, Dimensions, Boolean, OutOfBoundsFactory<T, RandomAccessibleInterval<T>>, RandomAccessibleInterval<T>> padOp;
@@ -73,14 +74,22 @@ public class FFTMethodsOpF<T extends RealType<T>, C extends ComplexType<C>> impl
7374
* TODO
7475
*
7576
* @param input
77+
* @param fftType the complex type of the output
7678
* @param borderSize the size of border to apply in each dimension
7779
* @param fast whether to perform a fast FFT; default true
78-
* @param fftType the complex type of the output
7980
* @return the output
8081
*/
8182
@Override
82-
public RandomAccessibleInterval<C> apply(final RandomAccessibleInterval<T> input, final long[] borderSize,
83-
final Boolean fast, final C fftType) {
83+
public RandomAccessibleInterval<C> apply( //
84+
final RandomAccessibleInterval<T> input, //
85+
final C fftType, //
86+
@Nullable long[] borderSize, //
87+
@Nullable Boolean fast //
88+
) {
89+
90+
if (fast == null) {
91+
fast = true;
92+
}
8493
// calculate the padded size
8594
long[] paddedSize = new long[input.numDimensions()];
8695

scijava-ops-image/src/test/java/org/scijava/ops/image/OpRegressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class OpRegressionTest {
4242

4343
@Test
4444
public void opDiscoveryRegressionIT() {
45-
long expected = 1875;
45+
long expected = 1877;
4646
long actual = ops.infos().size();
4747
assertEquals(expected, actual);
4848
}

scijava-ops-image/src/test/java/org/scijava/ops/image/filter/FFTTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void testFFT3DOp() {
7777
final Img<FloatType> inverse = TestImgGeneration.floatArray(false, dimensions);
7878

7979
final RandomAccessibleInterval<ComplexFloatType> out = ops.op("filter.fft")
80-
.arity4().input(in, null, true, new ComplexFloatType())
80+
.arity2().input(in, new ComplexFloatType())
8181
.outType(new Nil<RandomAccessibleInterval<ComplexFloatType>>() {}).apply();
8282
ops.op("filter.ifft").arity1().input(out).output(inverse).compute();
8383

@@ -124,19 +124,19 @@ public void testFastFFT3DOp() {
124124
// parameter we have to pass null for the
125125
// output parameter).
126126
final RandomAccessibleInterval<ComplexFloatType> fft1 = ops.op("filter.fft")
127-
.arity4().input(inOriginal, null, false, new ComplexFloatType())
127+
.arity4().input(inOriginal, new ComplexFloatType(), null, false)
128128
.outType(new Nil<RandomAccessibleInterval<ComplexFloatType>>() {}).apply();
129129

130130
// call FFT passing true for "fast" The FFT op will pad the input to the
131131
// fast
132132
// size.
133133
final RandomAccessibleInterval<ComplexFloatType> fft2 = ops.op("filter.fft")
134-
.arity4().input(inOriginal, null, true, new ComplexFloatType())
134+
.arity2().input(inOriginal, new ComplexFloatType())
135135
.outType(new Nil<RandomAccessibleInterval<ComplexFloatType>>() {}).apply();
136136

137137
// call fft using the img that was created with the fast size
138138
final RandomAccessibleInterval<ComplexFloatType> fft3 = ops.op("filter.fft")
139-
.arity4().input(inFast, null, true, new ComplexFloatType())
139+
.arity2().input(inFast, new ComplexFloatType())
140140
.outType(new Nil<RandomAccessibleInterval<ComplexFloatType>>() {}).apply();
141141

142142
// create an image to be used for the inverse, using the original

0 commit comments

Comments
 (0)