diff --git a/src/main/java/fr/pasteur/ida/zellige/utils/AmplitudeBackgroundForeGroundClassification.java b/src/main/java/fr/pasteur/ida/zellige/utils/AmplitudeBackgroundForeGroundClassification.java index 42d92821a709e67c0dfca51b845507f3eea3d8e9..f5662990e8e5dd85e39ea068e7f3cfc5ad2b99cc 100644 --- a/src/main/java/fr/pasteur/ida/zellige/utils/AmplitudeBackgroundForeGroundClassification.java +++ b/src/main/java/fr/pasteur/ida/zellige/utils/AmplitudeBackgroundForeGroundClassification.java @@ -164,6 +164,21 @@ public class AmplitudeBackgroundForeGroundClassification run(); } + public static < T extends RealType< T > & NativeType< T > > boolean isForeground( IntervalView< T > intervalView, double sizePercent ) + { + double sum = 0; + Cursor< T > cursor = intervalView.cursor(); + while ( cursor.hasNext() ) + { + cursor.fwd(); + if ( cursor.get().getRealDouble() != 0 ) + { + sum++; + } + } + return ( sum ) > ( intervalView.dimension( 0 ) * intervalView.dimension( 1 ) * sizePercent ); + } + public void run() { long X = source.dimension( 0 ); @@ -179,22 +194,9 @@ public class AmplitudeBackgroundForeGroundClassification int foreground = isForeground( viewSource, sizePercent ) ? 1 : 0; viewOutput.forEach( pixel -> pixel.setReal( foreground ) ); } + // Slight dilatation in z dimension + Utils.gaussConvolution( output.copy(), output, new double[]{ 0, 0, 1 } ); } - public static < T extends RealType< T > & NativeType< T > > boolean isForeground( IntervalView< T > intervalView, double sizePercent ) - { - double sum = 0; - Cursor< T > cursor = intervalView.cursor(); - while ( cursor.hasNext() ) - { - cursor.fwd(); - if ( cursor.get().getRealDouble() != 0 ) - { - sum++; - } - } - return ( sum ) > ( intervalView.dimension( 0 ) * intervalView.dimension( 1 ) * sizePercent ); - } - public Img< FloatType > getOutput() {