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

New class for maximums (Pixels[][]) selection

For clarification and modularity purposes the method uses for maximums selection are regrouped in one class which produces a 2D pixels array. This array is afterwards used to reconstructed the OS then the surfaces.
parent 2d907558
No related branches found
No related tags found
1 merge request!10Surface reconstruction Refactoring
......@@ -15,51 +15,55 @@ import org.jzy3d.analysis.AnalysisLauncher;
public class LocalMaximumSelection
{
public static int zCount;
public static double processTime;
public static < T extends RealType< T > & NativeType< T > > Pixels[][] run( Img<T > source, double percent, int sigmas)
public static < T extends RealType< T > & NativeType< T > > Pixels[][] run( Img< T > source, double amplitude, double threshold, int sigmas )
{
final long start = System.currentTimeMillis();
/* 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
Utils.gaussConvolution( converted.copy(), converted, new double[]{ 1, 1, 0 } );
// Normalization for to simplify thresholding
Img< FloatType > normalized = Utils.normalizeImage( converted );
Img< FloatType > normalized = pretreatment( source );
ImageJFunctions.show( normalized.copy(), "converted, blurred and normalized " );
/* Local maximum search and selection */
Img< FloatType > maxIntensity = maximumSearch( normalized, percent, sigmas );
Pixels[][] maximums = buildPixelArray( maxIntensity );
Pixels[][] maximums = maximumSearch( normalized, amplitude,threshold, sigmas );
/* Output and process time */
displayMaximums(maximums);
processTime = System.currentTimeMillis() - start;
/* Output */
displayMaximums( maximums );
return maximums;
}
private static < T extends RealType< T > & NativeType< T > > Img< T > maximumSearch( Img< T > input, double percent, int sigma )
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
Utils.gaussConvolution( converted.copy(), converted, new double[]{1, 1, 0 } );
// Normalization
return Utils.normalizeImage( converted );
}
private static < T extends RealType< T > & NativeType< T > > Pixels[][] maximumSearch( Img< T > input, double amplitude, double threshold, int sigma )
{
/* Local maximum detection using partial derivative */
Img< T > maximums = LocalMaximumDetection.findMaximums( input, input.factory() );
ImageJFunctions.show( maximums, "maximums" );
/* Grid of amplitude thresholds */
Img< FloatType > amplitudeImg = AmplitudeBackgroundForeGroundClassification.find(input,amplitude, 0.10);
ImageJFunctions.show( amplitudeImg," amplitude" );
/* Grid of local maximums*/
Img< BitType > threshold = LocalOtsu.find( input , percent);
//ImageJFunctions.show( threshold, "Local threshold " );
/* Grid of local thresholds*/
Img< BitType > thresholds = LocalOtsu.find( input, threshold );
/* Maxima selection according to threshold*/
maximums = Threshold.classification( maximums.copy(), maximums.factory(), threshold );
/* Pixel selection */
Img<FloatType> finalList = Threshold.classification( amplitudeImg, amplitudeImg.factory(), thresholds );
/* Dilatation of the resulting image*/
Utils.gaussConvolution( maximums.copy(), maximums, new double[]{ sigma, sigma } );
// ImageJFunctions.show( maximums, "blurred maximums" );
Utils.gaussConvolution( finalList.copy(), finalList, new double[]{ sigma, sigma } );
ImageJFunctions.show(finalList, "blurred maximums" );
/* New local maximum detection due to previous smoothing*/
maximums = LocalMaximumDetection.findMaximums( maximums.copy(), maximums.factory() );
return maximums;
/* Local maximum detection due to previous smoothing*/
finalList = LocalMaximumDetection.findMaximums( finalList.copy(), finalList.factory() );
return buildPixelArray( finalList );
}
......@@ -80,7 +84,6 @@ public class LocalMaximumSelection
if ( pixels[ y ][ x ] == null )
{ // nothing yet
pixels[ y ][ x ] = new Pixels( new Coordinate( x, y, z ) );
zCount++;
}
else // already at least two coordinates
{
......@@ -92,6 +95,7 @@ public class LocalMaximumSelection
}
return pixels;
}
/**
* Displays the local maximums found using jzy3D package.
*/
......@@ -108,10 +112,4 @@ public class LocalMaximumSelection
}
}
public static double getProcessTime()
{
return processTime;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment