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

Refactor : addition of Construction class

parent 48baae18
No related branches found
No related tags found
2 merge requests!47Feature : Multi-channel and Binning,!41Resolve "Consider rescaling (binning) large images"
package fr.pasteur.ida.zellige.steps.construction;
import fr.pasteur.ida.zellige.ReferenceSurfaceExtraction;
import fr.pasteur.ida.zellige.element.ReferenceSurface;
import fr.pasteur.ida.zellige.element.Surface;
import fr.pasteur.ida.zellige.steps.construction.exception.NoSurfaceFoundException;
import fr.pasteur.ida.zellige.steps.construction.rounds.ConstructionParameters;
import fr.pasteur.ida.zellige.steps.construction.rounds.FirstRoundConstruction;
import fr.pasteur.ida.zellige.steps.construction.rounds.SecondRoundConstruction;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.img.ImgFactory;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
public class Construction< T extends RealType< T > & NativeType< T > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( Construction.class );
private final ArrayList< ReferenceSurface< T > > referenceSurfaces = new ArrayList<>();
private int FS_startingOS_count;
private int FS_OS_count;
private int FS_smallSurfaces;
private int FS_goodSurfaces;
private int FS_finalizedSurfaces;
private int SS_startingOS_count;
private int SS_OS_count;
private int SS_smallSurfaces;
private int SS_goodSurfaces;
private long FS_OSConstructionProcessingTime;
private long FS_SurfaceConstructionProcessingTime;
private long SS_OSConstructionProcessingTime;
private long SS_SurfaceConstructionProcessingTime;
public static < T extends RealType< T > & NativeType< T > > ArrayList< ReferenceSurface< T > >
run( ConstructionParameters[] constructionParameters,
RandomAccessibleInterval< T > input,
ImgFactory< T > factory,
Img< FloatType > selectedPixels, int bin ) throws NoSurfaceFoundException
{
Construction< T > construction = new Construction<>();
construction.run( constructionParameters, selectedPixels, input, factory, bin );
return construction.referenceSurfaces;
}
private void run( ConstructionParameters[] constructionParameters, Img< FloatType > selectedPixels, RandomAccessibleInterval< T > input, ImgFactory< T > factory, int bin ) throws NoSurfaceFoundException
{
LOGGER.debug( "Running construction..." );
/* First round construction*/
FirstRoundConstruction step1 = new FirstRoundConstruction( selectedPixels, constructionParameters[ 0 ] );
step1.process();
ArrayList< Surface > tempSurfaces = step1.getSurfaces();
FS_startingOS_count = step1.getStartingOSCount();
FS_OS_count = step1.getOSCount();
FS_goodSurfaces = step1.getGoodSurfacesCount();
FS_smallSurfaces = step1.getSmallSurfacesCount();
FS_finalizedSurfaces = tempSurfaces.size();
FS_OSConstructionProcessingTime = step1.getOSConstructionProcessingTime();
FS_SurfaceConstructionProcessingTime = step1.getConstructionProcessingTime();
LOGGER.debug( "first round surfaces = {}", tempSurfaces.size() );
/* Second round construction */
SecondRoundConstruction step2 =
new SecondRoundConstruction( tempSurfaces, constructionParameters[ 1 ] );
step2.process();
ArrayList< Surface > finalSurfaces = step2.getSurfaces();
SS_startingOS_count = step2.getStartingOSCount();
SS_OS_count = step2.getOSCount();
SS_goodSurfaces = step2.getGoodSurfacesCount();
SS_smallSurfaces = step2.getSmallSurfacesCount();
SS_OSConstructionProcessingTime = step2.getOSConstructionProcessingTime();
SS_SurfaceConstructionProcessingTime = step2.getConstructionProcessingTime();
/* Building reference surfaces */
referenceSurfaces.addAll( ConstructionCompletion.run( input, factory, finalSurfaces, bin ) );
LOGGER.debug( " Constructions of {} surfaces.", referenceSurfaces.size() );
}
public ArrayList< ReferenceSurface< T > > getReferenceSurfaces()
{
return referenceSurfaces;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment