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 bc77c2d680d4f35daa911600ba03c99b75557d11..d20c59516f97e84c3e068eb05b8dbe368bf5e772 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 @@ -24,15 +24,13 @@ import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.UnsignedShortType; -import java.util.TreeSet; public class SurfacesExtraction { - public static TreeSet<Integer> list; public static < T extends RealType< T > & NativeType< T > > void extract( - Img< T > input, double amplitude,double threshold, int sigmas, + Img< T > input, double amplitude, double threshold, int sigmas, boolean zMapDisplay, int delta, boolean extractedStackDisplay, boolean heightMapDisplay, @@ -40,20 +38,20 @@ public class SurfacesExtraction String projectionType ) { /* First step : Pixel selection */ - Pixels[][] maximums = SurfacePixelSelection.run(input, amplitude,threshold, sigmas); - int X = (int) input.dimension( 0 ); - int Y = (int) input.dimension( 1 ); + Pixels[][] maximums = SurfacePixelSelection.run( input, amplitude, threshold, sigmas ); + int width = ( int ) input.dimension( 0 ); + int heigth = ( int ) input.dimension( 1 ); try { /* First round construction*/ - ArrayList< Surface > surfaces = firstRoundConstruction( maximums , X, Y); + ArrayList< Surface > surfaces = firstRoundConstruction( maximums, width, heigth ); System.out.println( "first round surfaces = " + surfaces.size() ); // // for (Surface surface : surfaces) { // displaySurface(surface); // } // Second round construction - ArrayList< Surface > finalSurfaces = secondRoundConstruction( surfaces, X, Y ); + ArrayList< Surface > finalSurfaces = secondRoundConstruction( surfaces, width, heigth ); // if ( !finalSurfaces.isEmpty() ) // { int index = 0; @@ -78,7 +76,6 @@ public class SurfacesExtraction } - //TODO Bad documentation /** @@ -93,7 +90,7 @@ public class SurfacesExtraction ImageJFunctions.show( maximums, "maximums" ); /* Grid of local maximums*/ - Img< BitType > threshold = LocalOtsuClassification.find( input , percent); + Img< BitType > threshold = LocalOtsuClassification.find( input, percent ); //ImageJFunctions.show( threshold, "Local threshold " ); /* Maxima selection according to threshold*/ @@ -129,24 +126,24 @@ public class SurfacesExtraction for ( int i = 0; i <= maximums.length - 1; i++ ) { - osListsArray[ i ] = OSConstruction.findOS( maximums[ i ], dimension , startingStatus); + osListsArray[ i ] = OSConstruction.findOS( maximums[ i ], dimension, startingStatus ); } - startingStatus.setStartingStatus( ); + startingStatus.setStartingStatus(); } /* ----- First and second round construction methods. ----- */ - private static ArrayList< Surface > firstRoundConstruction( Pixels[][] maximums, int X, int Y ) throws NoSurfaceFoundException + private static ArrayList< Surface > firstRoundConstruction( Pixels[][] maximums, int width, int height ) throws NoSurfaceFoundException { int dimension = 0; // Setting and storage of the OS build in the X dimension according to the user thresholds settings. OSEStartingStatus startingStatus = new OSEStartingStatus( dimension ); - OSList[] osListsArrayX = new OSList[ Y ]; - set( maximums, osListsArrayX, dimension, startingStatus ); + OSList[] osListsArrayX = new OSList[ height ]; + set( maximums, osListsArrayX, dimension, startingStatus ); // displayOS(osListsArrayX); System.out.println( "OS.count = " + OSE.getCount() ); /* Construction of the tempSurfaces*/ ArrayList< Surface > surfaces = - SurfacesReconstruction.buildSurfaces( 0, osListsArrayX, X, Y ); + SurfacesReconstruction.buildSurfaces( 0, osListsArrayX, width, height ); if ( ! surfaces.isEmpty() ) { mergeReferenceSurface( surfaces ); @@ -161,17 +158,17 @@ public class SurfacesExtraction /** * Rebuilds the double pixel array from the {@link SurfaceLine} array - * of a {@link Surface} for a construction in the Y dimension. + * of a {@link Surface} for a construction in the height dimension. * * @param surface - the {@link SurfaceLine} array of a {@link Surface} * @return a {@link Surface} specific double pixel array. */ - private static Pixels[][] rebuildPixelsArray( Surface surface, int X, int Y ) + private static Pixels[][] rebuildPixelsArray( Surface surface, int width, int height ) { - Pixels[][] tempCoordinates = new Pixels[ X ][ Y ]; // Transposed array - for ( int i = 0; i <= Y - 1; i++ ) + Pixels[][] tempCoordinates = new Pixels[ width ][ height ]; // Transposed array + for ( int i = 0; i <= height - 1; i++ ) { - for ( int j = 0; j <= X - 1; j++ ) + for ( int j = 0; j <= width - 1; j++ ) { if ( surface.get( i ) != null ) { @@ -188,11 +185,11 @@ public class SurfacesExtraction * @param surface - the Surface object to process * @param osListsArrayY -the output OSList array */ - private static void transposeSurfaceLines( Surface surface, OSList[] osListsArrayY, int X, int Y ) + private static void transposeSurfaceLines( Surface surface, OSList[] osListsArrayY, int width, int height ) { int dimension = 1; - Pixels[][] pixels = rebuildPixelsArray( surface, X, Y ); - /* OS construction in dimension Y.*/ + Pixels[][] pixels = rebuildPixelsArray( surface, width, height ); + /* OS construction in dimension height.*/ OSEStartingStatus startingStatus = new OSEStartingStatus( dimension ); set( pixels, osListsArrayY, dimension, startingStatus ); } @@ -201,12 +198,12 @@ public class SurfacesExtraction /* ----- Other displaying methods -----*/ /** - * Reconstructs the TempSurface objects of the specified list in dimension X. + * Reconstructs the TempSurface objects of the specified list in dimension width. * * @param surfaces - the list of TempSurface objects. * @return a list of reconstructed Tempsurface objects */ - private static ArrayList< Surface > secondRoundConstruction( ArrayList< Surface > surfaces, int X, int Y ) throws NoSurfaceFoundException + private static ArrayList< Surface > secondRoundConstruction( ArrayList< Surface > surfaces, int width, int height ) throws NoSurfaceFoundException { System.out.println( "========================================" ); ArrayList< Surface > finalSurfaces = new ArrayList<>(); @@ -215,14 +212,14 @@ public class SurfacesExtraction { if ( surface.hasDuplicate() )// CoordinateList instead of Coordinate { - OSList[] osListsArrayY = new OSList[ X ]; + OSList[] osListsArrayY = new OSList[ width ]; - transposeSurfaceLines( surface, osListsArrayY, X, Y ); + transposeSurfaceLines( surface, osListsArrayY, width, height ); OSE.setStartingStatus( 1 ); System.out.println( "OS.count = " + OSE.getCount() ); // displayOS( osListsArrayY ); - ArrayList< Surface > temps = SurfacesReconstruction.buildSurfaces( 1, osListsArrayY, X, Y ); + ArrayList< Surface > temps = SurfacesReconstruction.buildSurfaces( 1, osListsArrayY, width, height ); if ( temps.isEmpty() ) { System.out.println( "small surface in second round" ); @@ -329,22 +326,22 @@ public class SurfacesExtraction // public static int getX() // { -// return X; +// return width; // } // // public static void setX( int x ) // { -// X = x; +// width = x; // } // // public static int getY() // { -// return Y; +// return height; // } // // public static void setY( int y ) // { -// Y = y; +// height = y; // } // // public static int getZ() diff --git a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesReconstruction.java b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesReconstruction.java index ba1082294d0c738485f3182e08988866718cbb83..b8a4d0a109bbe6111cfe00a3f3e36728f26a83d0 100644 --- a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesReconstruction.java +++ b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/construction/SurfacesReconstruction.java @@ -25,12 +25,12 @@ public class SurfacesReconstruction * @param osLists - the array of OSList * @return a list of TempSurface */ - public static ArrayList< Surface > buildSurfaces( int dimension, OSList[] osLists, int X, int Y ) + public static ArrayList< Surface > buildSurfaces( int dimension, OSList[] osLists, int width, int height ) { // Construction of the list of output TempSurface. ArrayList< Surface > surfaces = new ArrayList<>(); smallSurfaceCount = 0; - int finalIndex = findIndexValue( osLists, 0, dimension, X, Y ); + int finalIndex = findIndexValue( osLists, 0, dimension, width, height ); do { // All the OSLists are set to "not visited". @@ -40,10 +40,10 @@ public class SurfacesReconstruction // osLists[finalIndex].remove( firstOS );//TODO remove or not if ( firstOSE != null ) { - Surface surface = createSurface( firstOSE, dimension, X, Y); - buildSurface( osLists, surface, finalIndex, X, Y ); + Surface surface = createSurface( firstOSE, dimension, width, height); + buildSurface( osLists, surface, finalIndex, width, height ); //it is really a reference surface ? - if ( surface.getSize() >= X * Y * 0.01 ) + if ( surface.getSize() >= width * height * 0.01 ) { surfaces.add( surface ); } @@ -52,7 +52,7 @@ public class SurfacesReconstruction smallSurfaceCount++; System.out.println( "searching.....from " ); } - finalIndex = findIndexValue( osLists, startingIndex, dimension, X, Y ); + finalIndex = findIndexValue( osLists, startingIndex, dimension, width, height ); } } while ( finalIndex <= osLists.length - 2 @@ -71,14 +71,14 @@ public class SurfacesReconstruction * @param surface - the TempSurface to construct * @param index - the position in the TempSurface */ - private static void buildSurface( OSList[] osLists, Surface surface, int index, int X, int Y ) + private static void buildSurface( OSList[] osLists, Surface surface, int index, int width, int height ) { /* First round of the construction -> top to bottom in the dimension.*/ SurfaceLine current = surface.get( index ); SurfaceLine next; while ( current != null ) { - next = searchForward( osLists, current, X, Y ); + next = searchForward( osLists, current, width, height ); if ( next != null ) { surface.set( next.getLine(), next ); @@ -113,7 +113,7 @@ public class SurfacesReconstruction { if ( surface.get( i ) != null ) { - next = searchForward( osLists, surface.get( i ), X, Y ); + next = searchForward( osLists, surface.get( i ), width, height ); if ( next != null ) { if ( surface.get( i + 1 ) != null ) @@ -136,20 +136,20 @@ public class SurfacesReconstruction * @param dimension - the construction dimension * @return a surface as a {@link Surface} */ - private static Surface createSurface( OSE firstOSE, int dimension, int X, int Y) + private static Surface createSurface( OSE firstOSE, int dimension, int width, int height) { - Surface surface = new Surface( dimension, X, Y ); + Surface surface = new Surface( dimension, width, height ); int i; if ( dimension == 0 ) { i = firstOSE.get( 0 ).getY(); - surface.set( i, new SurfaceLineX( X, firstOSE ) ); + surface.set( i, new SurfaceLineX( width, firstOSE ) ); } else { i = firstOSE.get( 0 ).getX(); - surface.set( i, new SurfaceLineY(Y, firstOSE ) ); + surface.set( i, new SurfaceLineY(height, firstOSE ) ); } return surface; } @@ -162,17 +162,17 @@ public class SurfacesReconstruction * @param dimension - the dimension in which the construction has to occur * @return the value of the first OSList containing a starting OS */ - private static int findIndexValue( OSList[] osLists, int index, int dimension, int X, int Y ) + private static int findIndexValue( OSList[] osLists, int index, int dimension, int width, int height ) { int i = index; int limitValue; if ( dimension == 0 ) { - limitValue = Y - 1; + limitValue = height - 1; } else { - limitValue = X - 1; + limitValue = width - 1; } while ( i <= limitValue - 2 ) { @@ -261,16 +261,16 @@ public class SurfacesReconstruction * @param current - the {@link SurfaceLine } to match * @return the SurfaceLine generated from the specified OSList array matching the current SurfaceLine */ - private static SurfaceLine searchForward( OSList[] osLists, SurfaceLine current , int X, int Y) + private static SurfaceLine searchForward( OSList[] osLists, SurfaceLine current , int width, int height) { int length; if ( current instanceof SurfaceLineX ) { - length = Y; + length = height; } else { - length = X; + length = width; } if ( current.getLine() + 1 <= length - 1 ) diff --git a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/Surface.java b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/Surface.java index 5b3d3020ce65c995e99a33cf4716a919f1935878..2d10930542fc34b74ab16339f7f6d3b604a364e4 100644 --- a/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/Surface.java +++ b/src/main/java/fr/pasteur/ida/zellige/surfaceConstruction/element/Surface.java @@ -19,22 +19,22 @@ public class Surface private final SurfaceLine[] surfaceLines; private final int dimension; - private final int X; - private final int Y; + private final int width; + private final int height; - public Surface( int dimension, int X, int Y ) + public Surface( int dimension, int width, int height ) { - this.X = X; - this.Y = Y; + this.width = width; + this.height = height; int length; if ( dimension == 0 ) { - length = Y; + length = height; } else { - length = X; + length = width; } this.dimension = dimension; this.surfaceLines = new SurfaceLine[ length ]; @@ -155,13 +155,13 @@ public class Surface } /** - * Transpose the instance : length equals dimension Y instead of X. + * Transpose the instance : length equals dimension height instead of width. * * @return the identical transposed {@link Surface} */ public Surface transpose() { - Surface surface = new Surface( Math.abs( this.dimension - 1 ), X, Y ); + Surface surface = new Surface( Math.abs( this.dimension - 1 ), width, height ); Class< ? > theClass; if ( this.dimension == 0 ) { @@ -240,7 +240,7 @@ public class Surface public Img< UnsignedShortType > getZMap() { - Dimensions dim = FinalDimensions.wrap( new long[]{X,Y }); + Dimensions dim = FinalDimensions.wrap( new long[]{width,height }); ImgFactory< UnsignedShortType > factory = Util.getArrayOrCellImgFactory(dim, new UnsignedShortType()); Img< UnsignedShortType > zMap = factory.create(dim); RandomAccess< UnsignedShortType > randomAccess = zMap.randomAccess(); diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/LocalOtsuClassification.java b/src/main/java/fr/pasteur/ida/zellige/utils/LocalOtsuClassification.java index 7d9cb60c7a48288b39f40e85dc743b4ed84b75d6..65243e2ef15eaa654c5b2542a93c3b721847d115 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/LocalOtsuClassification.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/LocalOtsuClassification.java @@ -93,10 +93,10 @@ public class LocalOtsuClassification public static < T extends RealType< T > & NativeType< T > > void computeLocalThreshold( Img< T > input, Img< T > grid ) { - long X = input.dimension( 0 ); - long Y = input.dimension( 1 ); - long Z = input.dimension( 2 ); - List< Interval > intervals = Grids.collectAllContainedIntervals( new long[]{ X, Y, Z }, + long width = input.dimension( 0 ); + long height = input.dimension( 1 ); + long depth = input.dimension( 2 ); + List< Interval > intervals = Grids.collectAllContainedIntervals( new long[]{ width, height, depth }, new int[]{ 50, 50, 3 } );//TODO Size of a grid cube ? for ( Interval interval : intervals ) diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/MaximumAmplitudeClassification.java b/src/main/java/fr/pasteur/ida/zellige/utils/MaximumAmplitudeClassification.java index 02f4131066f150ab5b4e28f9f088fbd532e40d30..3cf8992d79ccdd458d12023ccef04a18ee17d0c2 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/MaximumAmplitudeClassification.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/MaximumAmplitudeClassification.java @@ -112,10 +112,10 @@ public class MaximumAmplitudeClassification * @param <T> the type of the {@link RandomAccess} * @return the chosen amplitude value of the local maximum positioned at minAccess location */ - private static < T extends RealType< T > & NativeType< T > > double getAmplitude( float maxValue, RandomAccess< T > minAccess , int Z) + private static < T extends RealType< T > & NativeType< T > > double getAmplitude( float maxValue, RandomAccess< T > minAccess , int depth) { double up = findValueUp( minAccess, maxValue ); - double down = findValueDown( minAccess, maxValue , Z); + double down = findValueDown( minAccess, maxValue , depth); double result = Math.max( Math.abs( maxValue - up ), Math.abs( maxValue - down ) ); if ( result == 0 ) { @@ -156,10 +156,10 @@ public class MaximumAmplitudeClassification * @return the amplitude value below the local maximum location in the Z dimension */ private static < T extends RealType< T > & NativeType< T > > double findValueDown( - RandomAccess< T > minAccess, float maxValue, int Z ) + RandomAccess< T > minAccess, float maxValue, int depth ) { int start = minAccess.getIntPosition( 2 ); - for ( int z = start + 1; z <= Z - 1; z++ ) + for ( int z = start + 1; z <= depth - 1; z++ ) { minAccess.setPosition( z, 2 ); double value = minAccess.get().getRealDouble(); @@ -239,10 +239,10 @@ public class MaximumAmplitudeClassification */ public void run() { - long X = source.dimension( 0 ); - long Y = source.dimension( 1 ); - long Z = source.dimension( 2 ); - List< Interval > intervals = Grids.collectAllContainedIntervals( new long[]{ X, Y, Z }, + long width = source.dimension( 0 ); + long height = source.dimension( 1 ); + long depth = source.dimension( 2 ); + List< Interval > intervals = Grids.collectAllContainedIntervals( new long[]{ width, height, depth }, new int[]{ 15, 15, 1 } ); for ( Interval interval : intervals ) diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/StackProjection.java b/src/main/java/fr/pasteur/ida/zellige/utils/StackProjection.java index 53b92ddeff1224c2af48d0382693557e622f2b5e..ed9343d324f7aedf68e2be71653a230d889711e6 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/StackProjection.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/StackProjection.java @@ -61,8 +61,8 @@ public class StackProjection zMapAccess.setPosition( y, 1 ); // We suppose here that the z values start at 1 , 0 is for unassigned values. int z = zMapAccess.get().getInteger(); - IntType Z = new IntType( z ); - lutConverter.convert( Z, argbTypeRandomAccess.get() ); + IntType depth = new IntType( z ); + lutConverter.convert( depth, argbTypeRandomAccess.get() ); } } return argb;