Skip to content
Snippets Groups Projects
Commit 6c18d45c authored by Céline  TREBEAU's avatar Céline TREBEAU
Browse files

bug fix: possibility to compute a thresholding on N dimensional images

parent dc7fd393
No related branches found
No related tags found
1 merge request!10Surface reconstruction Refactoring
...@@ -2,11 +2,11 @@ package fr.pasteur.ida.zellige.utils; ...@@ -2,11 +2,11 @@ package fr.pasteur.ida.zellige.utils;
import net.imglib2.Cursor; import net.imglib2.Cursor;
import net.imglib2.IterableInterval; import net.imglib2.IterableInterval;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType; import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.RealType;
import java.util.*; import java.util.Map;
import java.util.TreeMap;
public class Otsu public class Otsu
{ {
...@@ -133,7 +133,7 @@ public class Otsu ...@@ -133,7 +133,7 @@ public class Otsu
while ( cursor.hasNext() ) while ( cursor.hasNext() )
{ {
cursor.fwd(); cursor.fwd();
final Double value = cursor.get().getRealDouble(); final double value = cursor.get().getRealDouble();
Integer j = hm.get(value ); Integer j = hm.get(value );
hm.put( value, ( j == null ) ? 1 : j + 1 ); hm.put( value, ( j == null ) ? 1 : j + 1 );
...@@ -157,7 +157,12 @@ public class Otsu ...@@ -157,7 +157,12 @@ public class Otsu
} }
// Setting of mean and number of pixels // Setting of mean and number of pixels
int N = ( int ) ( source.dimension( 0 ) * source.dimension( 1 ) * source.dimension( 2 ) );
int N = 1;
for(int d = 0 ; d<= source.numDimensions() - 1; d ++)
{
N = N* (int) source.dimension( d );
}
double mTot = sum / N; double mTot = sum / N;
// Cumulative arrays // Cumulative arrays
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment