From 3e5b2c0db26cf8fad803ef66e55505858e308d5d Mon Sep 17 00:00:00 2001 From: ctrebeau <ctrebeau@pasteur.fr> Date: Tue, 6 Oct 2020 16:28:10 +0200 Subject: [PATCH] method to display the real maximums intensity value instead of binary display --- .../zellige/utils/LocalMaximumDetection.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumDetection.java b/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumDetection.java index 641bfcf6..c1b79b49 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumDetection.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumDetection.java @@ -6,6 +6,7 @@ import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; +import net.imglib2.img.display.imagej.ImageJFunctions; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; import net.imglib2.view.IntervalView; @@ -79,7 +80,8 @@ public class LocalMaximumDetection YZProjection.dimension( 1 ) + 1 ); // Partial derivative computation */ Utils.derivative( YZProjection, partialDerivative ); - getListOfLocalMaximum( maximums, partialDerivative, x ); +// getListOfLocalMaximum( maximums, partialDerivative, x ); + getListOfLocalMaximum( maximums, partialDerivative,YZProjection, x ); } @@ -113,6 +115,34 @@ public class LocalMaximumDetection } } + private static < T extends RealType< T > & NativeType< T > > void + getListOfLocalMaximum + ( RandomAccessibleInterval< T > notMax, + RandomAccessibleInterval< T > partialDerivative, + RandomAccessibleInterval <T> original, + int x + ) + { + RandomAccess< T > derivativeAccess = partialDerivative.randomAccess(); + RandomAccess< T > maxAccess = notMax.randomAccess(); + RandomAccess< T > oriAccess = original.randomAccess(); + + for ( int y = 0; y <= notMax.dimension( 1 ) - 1; y++ ) + { + derivativeAccess.setPosition( y, 0 ); + for ( int z = 0; z <= notMax.dimension( 2 ) - 1; z++ ) + { + if ( isALocalMaximum( derivativeAccess, z ) ) + { + Utils.setPosition( oriAccess, y, z ); + Utils.setPosition( maxAccess, x, y, z ); + maxAccess.get().set( oriAccess.get() ); +// maxAccess.get().setOne(); + } + } + } + } + /** * Method to find if a pixel of a given stack is a local maximum. * <p> -- GitLab