Skip to content

Commit 18c1fe9

Browse files
committed
Fixed incompatibility in MaximaFinder
1 parent 61c897c commit 18c1fe9

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/main/java/com/github/celldynamics/quimp/plugin/protanalysis/MaximaFinder.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.github.celldynamics.quimp.plugin.qanalysis.STmap;
1313

1414
import ij.plugin.filter.MaximumFinder;
15+
import ij.process.ByteProcessor;
1516
import ij.process.ImageProcessor;
1617

1718
/**
@@ -57,7 +58,16 @@ public MaximaFinder(ImageProcessor ip) {
5758
*/
5859
public void computeMaximaIJ(double tolerance) {
5960
MaximumFinder mf = new MaximumFinder();
60-
maxima = mf.getMaxima(ip, tolerance, false);
61+
// maxima = mf.getMaxima(ip, tolerance, false); // stopped working for 1.52n
62+
ByteProcessor ret = mf.findMaxima(ip, tolerance, MaximumFinder.SINGLE_POINTS, false);
63+
maxima = new Polygon();
64+
for (int x = 0; x < ret.getWidth(); ++x) {
65+
for (int y = 0; y < ret.getHeight(); ++y) {
66+
if (ret.get(x, y) > 0) {
67+
maxima.addPoint(x, y);
68+
}
69+
}
70+
}
6171
LOGGER.debug("Found maxima: " + maxima.npoints);
6272
}
6373

src/test/java/com/github/celldynamics/quimp/plugin/protanalysis/MaximaFinderTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.github.celldynamics.quimp.plugin.qanalysis.STmap;
2222
import com.github.celldynamics.quimp.utils.QuimPArrayUtils;
2323

24+
import ij.ImagePlus;
2425
import ij.process.FloatProcessor;
2526
import ij.process.ImageProcessor;
2627

@@ -104,20 +105,24 @@ public void tearDown() throws Exception {
104105
*/
105106
@Test
106107
public void testMaximaFinder() throws Exception {
107-
int[] expectedX = { 160, 110, 134, 266, 40, 359, 79, 236, 288, 273, 212, 127, 73, 8, 331, 70,
108-
270, 147, 368, 13 };
108+
int[] expectedX = { 8, 13, 40, 70, 73, 79, 110, 127, 134, 147, 160, 212, 236, 266, 270, 273,
109+
288, 331, 359, 368 };
109110
int[] expectedY =
110-
{ 20, 89, 129, 62, 63, 97, 50, 77, 31, 126, 80, 132, 57, 42, 58, 15, 102, 31, 103, 40 };
111+
{ 42, 40, 63, 15, 57, 50, 89, 132, 129, 31, 20, 80, 77, 62, 102, 126, 31, 58, 97, 103 };
111112
// these values have been read from matlab using above points
112-
double[] expectedVal = { 21.00, 15.15, 15.06, 15.05, 14.58, 14.52, 14.48, 14.34, 14.14, 13.28,
113-
13.03, 12.44, 11.83, 11.75, 11.55, 11.08, 11.07, 10.90, 10.64, 10.43 };
113+
double[] expectedVal = { 11.75, 10.43, 14.58, 11.08, 11.83, 14.48, 15.15, 12.44, 15.06, 10.90,
114+
21.00, 13.03, 14.34, 15.05, 11.07, 13.28, 14.14, 11.55, 14.52, 10.64 };
114115
MaximaFinder mf = new MaximaFinder(imp);
116+
new ImagePlus("", imp).show();
115117
mf.computeMaximaIJ(10);
116118
Polygon ret = mf.getMaxima();
117119
double[] val = mf.getMaxValues();
118120
LOGGER.debug(Arrays.toString(val));
119-
assertThat(ret.xpoints, is(expectedX));
120-
assertThat(ret.ypoints, is(expectedY));
121+
assertThat(ret.npoints, is(20));
122+
for (int i = 0; i < 20; i++) {
123+
assertThat(ret.xpoints[i], is(expectedX[i]));
124+
assertThat(ret.ypoints[i], is(expectedY[i]));
125+
}
121126
assertArrayEquals(expectedVal, val, 1e-2);
122127
}
123128

0 commit comments

Comments
 (0)