Skip to content

Commit 4c5b75f

Browse files
authored
Merge pull request #291 from scijava/scijava-ops-image/correlate-dep-misname
Rename Op dependency
2 parents 82d58a2 + a165b19 commit 4c5b75f

2 files changed

Lines changed: 77 additions & 1 deletion

File tree

scijava-ops-image/src/main/java/org/scijava/ops/image/filter/correlate/CorrelateFFTF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class CorrelateFFTF<I extends RealType<I> & NativeType<I>, O extends Real
6666
@OpDependency(name = "create.img")
6767
private BiFunction<Dimensions, O, RandomAccessibleInterval<O>> outputCreator;
6868

69-
@OpDependency(name = "filter.pad")
69+
@OpDependency(name = "filter.padInputFFT")
7070
private Functions.Arity4<RandomAccessibleInterval<I>, Dimensions, Boolean, OutOfBoundsFactory<I, RandomAccessibleInterval<I>>, RandomAccessibleInterval<I>> padOp;
7171

7272
@OpDependency(name = "filter.padShiftFFTKernel")
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* #%L
3+
* Image processing operations for SciJava Ops.
4+
* %%
5+
* Copyright (C) 2014 - 2025 SciJava developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
//
30+
31+
package org.scijava.ops.image.filter.correlate;
32+
33+
import net.imglib2.RandomAccessibleInterval;
34+
import net.imglib2.img.array.ArrayImgs;
35+
import net.imglib2.type.numeric.complex.ComplexFloatType;
36+
import net.imglib2.type.numeric.real.FloatType;
37+
import org.junit.jupiter.api.Assertions;
38+
import org.junit.jupiter.api.Test;
39+
import org.scijava.ops.image.AbstractOpTest;
40+
41+
import java.util.Arrays;
42+
43+
/**
44+
* Tests for {@code filter.correlate} Ops
45+
*
46+
* @author Gabriel Selzer
47+
*/
48+
public class CorrelateTest extends AbstractOpTest {
49+
50+
@Test
51+
public void testCorrelate() {
52+
// Create an image with the center pixel set
53+
var img = ArrayImgs.unsignedBytes(9, 9);
54+
var impulse = new long[] {4, 4};
55+
img.randomAccess().setPositionAndGet(impulse).set(1);
56+
57+
// Create an identity kernel
58+
var kernel = ArrayImgs.unsignedBytes(5, 5);
59+
kernel.getAt(2, 2).set(1);
60+
61+
// Correlate with Ops
62+
var output = ops.op("filter.correlate").input(img, kernel, new FloatType(), new ComplexFloatType()).apply();
63+
Assertions.assertInstanceOf(RandomAccessibleInterval.class, output);
64+
var actual = (RandomAccessibleInterval<FloatType>) output;
65+
66+
// Check the result
67+
var cursor = actual.cursor();
68+
while (cursor.hasNext()) {
69+
var actualValue = cursor.next().get();
70+
var pos = cursor.positionAsLongArray();
71+
// The only pixel that should be set is the center pixel.
72+
var expected = Arrays.equals(impulse, pos) ? 1 : 0;
73+
Assertions.assertEquals(expected, actualValue, 1e-6);
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)