diff --git a/src/main/java/fr/pasteur/ida/zellige/jzy3D/SurfaceDisplay.java b/src/main/java/fr/pasteur/ida/zellige/jzy3D/SurfaceDisplay.java index 1120e9b630ff05d393ab1c91be53e9ee0d515fb9..5f253df7a5717a10d9c41ad0ed47467d3d45050d 100644 --- a/src/main/java/fr/pasteur/ida/zellige/jzy3D/SurfaceDisplay.java +++ b/src/main/java/fr/pasteur/ida/zellige/jzy3D/SurfaceDisplay.java @@ -59,8 +59,8 @@ public class SurfaceDisplay extends AbstractAnalysis float G = 100f + (z *2); float R = 100f + z + 10 ; float B = 100f + z + 10; - colors[ index ] = Color.RED; -// colors[index] = new Color( R, G, B ); +// colors[ index ] = Color.RED; + colors[index] = new Color( R, G, B ); index++; } } @@ -72,7 +72,7 @@ public class SurfaceDisplay extends AbstractAnalysis System.out.println( System.lineSeparator() ); System.out.println( "Number of duplicate = " + size ); Scatter scatter = new Scatter( points, colors ); - scatter.setWidth( 2 ); + scatter.setWidth( 1 ); chart = AWTChartComponentFactory.chart( Quality.Advanced, "newt" ); chart.getScene().add( scatter ); diff --git a/src/main/java/fr/pasteur/ida/zellige/main/Main.java b/src/main/java/fr/pasteur/ida/zellige/main/Main.java index 86274dd2c8e67ffb4dc98a42b16c69e1d32cf27d..029a897b1000209c76bdf4b81ce13a7ed9dc1d34 100644 --- a/src/main/java/fr/pasteur/ida/zellige/main/Main.java +++ b/src/main/java/fr/pasteur/ida/zellige/main/Main.java @@ -63,10 +63,10 @@ public class Main // Input of the image. final String imagePath = -// "doc/STK_060.tif"; + "doc/STK_060.tif"; // "C:\\Users\\ctrebeau\\Desktop\\MoucheAile\\STK\\STK_Mouche_c01_f0001_p005.tif"; -// "C:\\Users\\ctrebeau\\Downloads\\phantom2b_combined.tif"; - "C:\\Users\\ctrebeau\\Desktop\\HighRes\\STK_170706_Vangl2-Lp-wt_E14.5_Phall_cochlea_01bHighRes_c01_f0001_p002.tif"; +// "C:\\Users\\ctrebeau\\Downloads\\phantom3_combined.tif"; +// "C:\\Users\\ctrebeau\\Desktop\\HighRes\\STK_170706_Vangl2-Lp-wt_E14.5_Phall_cochlea_01bHighRes_c01_f0001_p005.tif"; System.out.println(imagePath); // Creation of the image : version with unsigned type. */ /* JY version for opening files. */ @@ -77,7 +77,7 @@ public class Main /* User Parameters AKA arguments to run the program*/ double amplitude = Double.parseDouble( args[ 0 ] ); - double threshold = Double.parseDouble( args[ 1 ] ); + double otsu = Double.parseDouble( args[ 1 ] ); int sigmas = Integer.parseInt( args[ 2 ] ); int delta = Integer.parseInt( args[ 3 ] ); /* End of parameters. */ @@ -85,7 +85,7 @@ public class Main /* Print parameters.*/ System.out.println( " amplitude : " + amplitude ); - System.out.println( " threshold : " + threshold ); + System.out.println( " threshold : " + otsu ); System.out.println( " Blur size : " + sigmas ); System.out.println( " Delta : " + delta ); System.out.println( System.lineSeparator() ); @@ -101,7 +101,7 @@ public class Main SurfacesExtraction.setX( ( int ) stackImage.dimension( 0 ));// dimension X SurfacesExtraction.setY(( int ) stackImage.dimension( 1 ));// dimension Y SurfacesExtraction.setZ(( int ) stackImage.dimension( 2 ));// dimension Z - SurfacesExtraction.extract(stackImage,amplitude,threshold, sigmas, false, delta, false, + SurfacesExtraction.extract(stackImage,amplitude,otsu, sigmas, false, delta, false, false, true, "MIP"); } else diff --git a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesExtraction.java b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesExtraction.java index 666ba47e75185aba9e760f95a395bdde47585438..3f00fd1fe183795a6ab207543bbe4286bc8027c7 100644 --- a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesExtraction.java +++ b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesExtraction.java @@ -10,24 +10,18 @@ import fr.pasteur.ida.zellige.exception.NoSurfaceFoundException; import fr.pasteur.ida.zellige.jzy3D.LocalMaximumsDisplay; import fr.pasteur.ida.zellige.jzy3D.OSDisplay; import fr.pasteur.ida.zellige.jzy3D.SurfaceDisplay; -import fr.pasteur.ida.zellige.surfaceConstruction.element.Coordinate; import fr.pasteur.ida.zellige.surfaceConstruction.element.Pixels; import fr.pasteur.ida.zellige.surfaceConstruction.element.Surface; import fr.pasteur.ida.zellige.surfaceConstruction.element.os.OS; import fr.pasteur.ida.zellige.surfaceConstruction.element.os.OSList; import fr.pasteur.ida.zellige.surfaceConstruction.element.surfaceLine.SurfaceLine; -import net.imglib2.RandomAccess; -import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; import net.imglib2.img.display.imagej.ImageJFunctions; import net.imglib2.type.NativeType; import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.FloatType; -import org.jzy3d.analysis.AnalysisLauncher; -import java.util.ArrayList; import java.util.TreeSet; public class SurfacesExtraction @@ -47,7 +41,7 @@ public class SurfacesExtraction String projectionType ) { /* First step : Pixel selection */ - Pixels[][] maximums = LocalMaximumSelection.run(input, amplitude,threshold, sigmas); + Pixels[][] maximums = SurfacePixelSelection.run(input, amplitude,threshold, sigmas); try { @@ -99,7 +93,7 @@ public class SurfacesExtraction ImageJFunctions.show( maximums, "maximums" ); /* Grid of local maximums*/ - Img< BitType > threshold = LocalOtsu.find( input , percent); + Img< BitType > threshold = LocalOtsuClassification.find( input , percent); // Img< BitType > threshold = LocalOtsu.find( maximums , percent); //ImageJFunctions.show( threshold, "Local threshold " ); @@ -119,43 +113,6 @@ public class SurfacesExtraction } - public static < T extends RealType< T > & NativeType< T > > Pixels[][] buildPixelArray( - final RandomAccessibleInterval< T > stack ) - { - - RandomAccess< T > access = stack.randomAccess(); - - Pixels[][] pixels = new Pixels[ ( int ) stack.dimension( 1 ) ][ ( int ) stack.dimension( 0 ) ]; - - - for ( int x = 0; x <= stack.dimension( 0 ) - 1; x++ ) - { - for ( int y = 0; y <= stack.dimension( 1 ) - 1; y++ ) - { - - for ( int z = 0; z <= stack.dimension( 2 ) - 1; z++ ) - { - float value = Utils.setPositionAndGet( access, x, y, z ).getRealFloat(); - if ( value > 0 ) - { - if ( pixels[ y ][ x ] == null ) - { // nothing yet - pixels[ y ][ x ] = new Pixels( new Coordinate( x, y, z ) ); - zCount++; - } - else // already at least two coordinates - { - pixels[ y ][ x ].add( new Coordinate( x, y, z ) ); - } -// list.add() - } - } - } - } - return pixels; - } - - /** * Setting of the unfiltered local maximums : first the original stack is filtered with an anisotropic * gaussian convolution, the pixel values are normalized between 0 and 255 then the local maximums diff --git a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/os/OS.java b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/os/OS.java index f7cd7594e40d6b0b7eb93906c91bc869efaaca08..6f0a4c154523f3e99d4110b2f76ac51982cc4c2d 100644 --- a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/os/OS.java +++ b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/os/OS.java @@ -172,7 +172,7 @@ public static void setStartingStatus(int dimension) startingSize = 0; if ( dimension == 0 ) { - for ( int i = 0; list.size() > 20 && i <= list.size()/2 ;i++ ) + for ( int i = 0; list.size() > 20 && i <= list.size()* 0.75 ;i++ ) { list.remove( list.last() ); } diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/Interpolation.java b/src/main/java/fr/pasteur/ida/zellige/utils/Interpolation.java index 29b46aae64ad3a57e35eb7b02d6548f3d61b440d..034e03afb3d10854259420db77eb3317e1db4b77 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/Interpolation.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/Interpolation.java @@ -147,7 +147,7 @@ public class Interpolation */ public static Img< UnsignedShortType > execute( Img< UnsignedShortType > zMap ) { -// ImageJFunctions.show( zMap, "zMap" ); + ImageJFunctions.show( zMap, "zMap" ); Img< UnsignedShortType > interpolated0 = execute( zMap, 0 ); // ImageJFunctions.show( interpolated0, "interpolated 0" ); Img< UnsignedShortType > interpolated1 = execute( zMap, 1 ); 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 c1b79b498d908c799e316618f122a47b9b25dfa6..b40c774a40377c2fb20776500641c127b5bd8fdf 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumDetection.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumDetection.java @@ -80,7 +80,6 @@ public class LocalMaximumDetection YZProjection.dimension( 1 ) + 1 ); // Partial derivative computation */ Utils.derivative( YZProjection, partialDerivative ); -// getListOfLocalMaximum( maximums, partialDerivative, x ); getListOfLocalMaximum( maximums, partialDerivative,YZProjection, x ); } @@ -163,5 +162,13 @@ public class LocalMaximumDetection final double tOne = derivative.get().getRealDouble(); return ( tZero >= 0 && tOne < 0 ); } - + private static < T extends RealType< T > & NativeType< T > > boolean isALocalMinimum + ( RandomAccess< T > derivative, int z ) + { + derivative.setPosition( z, 1 ); + final double tZero = derivative.get().getRealDouble(); + derivative.setPosition( ( z + 1 ), 1 ); + final double tOne = derivative.get().getRealDouble(); + return ( tZero <0 && tOne >= 0 ); + } } diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumSelection.java b/src/main/java/fr/pasteur/ida/zellige/utils/SurfacePixelSelection.java similarity index 86% rename from src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumSelection.java rename to src/main/java/fr/pasteur/ida/zellige/utils/SurfacePixelSelection.java index 052f0dd3e87f574e8a71cac72961f0afe6f75687..f06bc1c863bcd4611c996216f271fa64ea6b7507 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/LocalMaximumSelection.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/SurfacePixelSelection.java @@ -13,11 +13,19 @@ import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.FloatType; import org.jzy3d.analysis.AnalysisLauncher; -public class LocalMaximumSelection +public class SurfacePixelSelection { - + /** + * + * @param source + * @param amplitude + * @param threshold + * @param sigmas + * @param <T> + * @return + */ public static < T extends RealType< T > & NativeType< T > > Pixels[][] run( Img< T > source, double amplitude, double threshold, int sigmas ) { /* Pretreatment of the image.*/ @@ -32,9 +40,14 @@ public class LocalMaximumSelection return maximums; } + /** + * + * @param source + * @param <T> + * @return + */ private static < T extends RealType< T > & NativeType< T > >Img<FloatType> pretreatment(Img< T > source) { - /* Pretreatment of the image.*/ // Conversion into FloatType for the derivative computation (negative values) Img< FloatType > converted = Utils.convertIntoFloatType( source.copy() ); //Image denoising with an anisotropic convolution @@ -44,15 +57,23 @@ public class LocalMaximumSelection } - + /** + * + * @param input + * @param amplitude + * @param threshold + * @param sigma + * @param <T> + * @return + */ private static < T extends RealType< T > & NativeType< T > > Pixels[][] maximumSearch( Img< T > input, double amplitude, double threshold, int sigma ) { /* Grid of amplitude thresholds */ - Img< FloatType > amplitudeImg = AmplitudeBackgroundForeGroundClassification.find(input,amplitude, 0.10); + Img< FloatType > amplitudeImg = MaximumAmplitudeClassification.find(input,amplitude, 0.10); ImageJFunctions.show( amplitudeImg," amplitude" ); /* Grid of local thresholds*/ - Img< BitType > thresholds = LocalOtsu.find( input, threshold ); + Img< BitType > thresholds = LocalOtsuClassification.find( input, threshold ); /* Pixel selection */ Img<FloatType> finalList = Threshold.classification( amplitudeImg, amplitudeImg.factory(), thresholds ); @@ -66,7 +87,12 @@ public class LocalMaximumSelection return buildPixelArray( finalList ); } - + /** + * + * @param stack + * @param <T> + * @return + */ public static < T extends RealType< T > & NativeType< T > > Pixels[][] buildPixelArray( final RandomAccessibleInterval< T > stack ) {