From 5e54257b376cdbba432dd6ee8b1e30e4fa0751e2 Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Thu, 6 Aug 2026 15:02:58 -0500 Subject: [PATCH 1/4] Rename Op dependency "filter.pad" is not a valid Op name --- .../org/scijava/ops/image/filter/correlate/CorrelateFFTF.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scijava-ops-image/src/main/java/org/scijava/ops/image/filter/correlate/CorrelateFFTF.java b/scijava-ops-image/src/main/java/org/scijava/ops/image/filter/correlate/CorrelateFFTF.java index 72dd6482a..dcb77c063 100644 --- a/scijava-ops-image/src/main/java/org/scijava/ops/image/filter/correlate/CorrelateFFTF.java +++ b/scijava-ops-image/src/main/java/org/scijava/ops/image/filter/correlate/CorrelateFFTF.java @@ -66,7 +66,7 @@ public class CorrelateFFTF & NativeType, O extends Real @OpDependency(name = "create.img") private BiFunction> outputCreator; - @OpDependency(name = "filter.pad") + @OpDependency(name = "filter.padInputFFT") private Functions.Arity4, Dimensions, Boolean, OutOfBoundsFactory>, RandomAccessibleInterval> padOp; @OpDependency(name = "filter.padShiftFFTKernel") From 3f5dd0e6e19b1ff1cbafa847f27510c36288c3ee Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Thu, 6 Aug 2026 15:51:47 -0500 Subject: [PATCH 2/4] Write a unit test --- .../image/filter/convolve/ConvolveTest.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java index 04b6a4448..f104e17d4 100644 --- a/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java +++ b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java @@ -30,14 +30,21 @@ package org.scijava.ops.image.filter.convolve; +import net.imglib2.*; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.view.Views; +import org.apache.commons.math3.complex.Complex; +import org.junit.jupiter.api.Assertions; import org.scijava.ops.image.AbstractOpTest; -import net.imglib2.RandomAccessibleInterval; import net.imglib2.outofbounds.OutOfBoundsFactory; import net.imglib2.type.numeric.complex.ComplexFloatType; import net.imglib2.type.numeric.real.FloatType; import org.junit.jupiter.api.Test; import org.scijava.types.Nil; +import java.util.Arrays; + /** * Tests involving convolvers. */ @@ -59,6 +66,33 @@ public void testConvolve() { {} // ).outType(new Nil>() {}).function(); } + + @Test + public void testCorrelate() { + // Create an image with the center pixel set + var img = ArrayImgs.unsignedBytes(9, 9); + var impulse = new long[] {4, 4}; + img.randomAccess().setPositionAndGet(impulse).set(1); + + // Create an identity kernel + var kernel = ArrayImgs.unsignedBytes(5, 5); + kernel.getAt(2, 2).set(1); + + // Correlate with Ops + var output = ops.op("filter.correlate").input(img, kernel, new FloatType(), new ComplexFloatType()).apply(); + Assertions.assertInstanceOf(RandomAccessibleInterval.class, output); + var actual = (RandomAccessibleInterval) output; + + // Check the result + var cursor = actual.cursor(); + while (cursor.hasNext()) { + var actualValue = cursor.next().get(); + var pos = cursor.positionAsLongArray(); + // The only pixel that should be set is the center pixel. + var expected = Arrays.equals(impulse, pos) ? 1 : 0; + Assertions.assertEquals(expected, actualValue, 1e-6); + } + } } // // /** Tests that the correct convolver is selected when using a small kernel. */ From 11923cc545cebb39f3aefdb5b514f4e2cddfb86d Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Mon, 17 Aug 2026 13:53:17 -0500 Subject: [PATCH 3/4] Move test to its own file --- .../image/filter/convolve/ConvolveTest.java | 36 +-------- .../image/filter/correlate/CorrelateTest.java | 74 +++++++++++++++++++ 2 files changed, 75 insertions(+), 35 deletions(-) create mode 100644 scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java diff --git a/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java index f104e17d4..04b6a4448 100644 --- a/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java +++ b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/convolve/ConvolveTest.java @@ -30,21 +30,14 @@ package org.scijava.ops.image.filter.convolve; -import net.imglib2.*; -import net.imglib2.img.array.ArrayImgs; -import net.imglib2.type.numeric.integer.UnsignedByteType; -import net.imglib2.view.Views; -import org.apache.commons.math3.complex.Complex; -import org.junit.jupiter.api.Assertions; import org.scijava.ops.image.AbstractOpTest; +import net.imglib2.RandomAccessibleInterval; import net.imglib2.outofbounds.OutOfBoundsFactory; import net.imglib2.type.numeric.complex.ComplexFloatType; import net.imglib2.type.numeric.real.FloatType; import org.junit.jupiter.api.Test; import org.scijava.types.Nil; -import java.util.Arrays; - /** * Tests involving convolvers. */ @@ -66,33 +59,6 @@ public void testConvolve() { {} // ).outType(new Nil>() {}).function(); } - - @Test - public void testCorrelate() { - // Create an image with the center pixel set - var img = ArrayImgs.unsignedBytes(9, 9); - var impulse = new long[] {4, 4}; - img.randomAccess().setPositionAndGet(impulse).set(1); - - // Create an identity kernel - var kernel = ArrayImgs.unsignedBytes(5, 5); - kernel.getAt(2, 2).set(1); - - // Correlate with Ops - var output = ops.op("filter.correlate").input(img, kernel, new FloatType(), new ComplexFloatType()).apply(); - Assertions.assertInstanceOf(RandomAccessibleInterval.class, output); - var actual = (RandomAccessibleInterval) output; - - // Check the result - var cursor = actual.cursor(); - while (cursor.hasNext()) { - var actualValue = cursor.next().get(); - var pos = cursor.positionAsLongArray(); - // The only pixel that should be set is the center pixel. - var expected = Arrays.equals(impulse, pos) ? 1 : 0; - Assertions.assertEquals(expected, actualValue, 1e-6); - } - } } // // /** Tests that the correct convolver is selected when using a small kernel. */ diff --git a/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java new file mode 100644 index 000000000..8214b8848 --- /dev/null +++ b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java @@ -0,0 +1,74 @@ +/* + * #%L + * Image processing operations for SciJava Ops. + * %% + * Copyright (C) 2014 - 2025 SciJava developers. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +// + +package org.scijava.ops.image.filter.correlate; + +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.numeric.complex.ComplexFloatType; +import net.imglib2.type.numeric.real.FloatType; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.scijava.ops.image.AbstractOpTest; + +import java.util.Arrays; + +/** + * Tests involving convolvers. + */ +public class CorrelateTest extends AbstractOpTest { + + @Test + public void testCorrelate() { + // Create an image with the center pixel set + var img = ArrayImgs.unsignedBytes(9, 9); + var impulse = new long[] {4, 4}; + img.randomAccess().setPositionAndGet(impulse).set(1); + + // Create an identity kernel + var kernel = ArrayImgs.unsignedBytes(5, 5); + kernel.getAt(2, 2).set(1); + + // Correlate with Ops + var output = ops.op("filter.correlate").input(img, kernel, new FloatType(), new ComplexFloatType()).apply(); + Assertions.assertInstanceOf(RandomAccessibleInterval.class, output); + var actual = (RandomAccessibleInterval) output; + + // Check the result + var cursor = actual.cursor(); + while (cursor.hasNext()) { + var actualValue = cursor.next().get(); + var pos = cursor.positionAsLongArray(); + // The only pixel that should be set is the center pixel. + var expected = Arrays.equals(impulse, pos) ? 1 : 0; + Assertions.assertEquals(expected, actualValue, 1e-6); + } + } +} From a165b199ecbe2f85fe91f309ed4d0c3f24c95a0a Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Mon, 17 Aug 2026 13:54:45 -0500 Subject: [PATCH 4/4] Fix CorrelateTest javadoconvolvec --- .../org/scijava/ops/image/filter/correlate/CorrelateTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java index 8214b8848..9293c655e 100644 --- a/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java +++ b/scijava-ops-image/src/test/java/org/scijava/ops/image/filter/correlate/CorrelateTest.java @@ -41,7 +41,9 @@ import java.util.Arrays; /** - * Tests involving convolvers. + * Tests for {@code filter.correlate} Ops + * + * @author Gabriel Selzer */ public class CorrelateTest extends AbstractOpTest {