From f077b4e473e826741eecda57a31a534aadd64651 Mon Sep 17 00:00:00 2001 From: ctrebeau <ctrebeau@pasteur.fr> Date: Wed, 14 Oct 2020 11:35:12 +0200 Subject: [PATCH] Addition of slight dilation in z dimension to the amplitude mask --- ...udeBackgroundForeGroundClassification.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) 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 42d92821..f5662990 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() { -- GitLab