Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 10-multi-channel-image-handling
  • 25-multithreads-heavy-tasks
  • 9-gui-features
  • dev
  • dev-batch-mode
  • dev-display
  • master
  • median-3d
  • Cnam
  • zellige-core-1.0.0
  • zellige-core-1.1.0
  • zellige-core-1.1.1
  • zellige-core-1.1.3
13 results

Target

Select target project
  • ida-public/zellige-core
1 result
Select Git revision
  • 10-multi-channel-image-handling
  • 25-multithreads-heavy-tasks
  • 9-gui-features
  • dev
  • dev-batch-mode
  • dev-display
  • master
  • median-3d
  • Cnam
  • zellige-core-1.0.0
  • zellige-core-1.1.0
  • zellige-core-1.1.1
  • zellige-core-1.1.3
13 results
Show changes
Showing
with 368 additions and 851 deletions
......@@ -33,18 +33,26 @@ import net.imglib2.type.numeric.RealType;
public class MainModel< T extends RealType< T > & NativeType< T > >
{
private final PreprocessingModel< T > preprocessingModel;
private final SelectionModel selectionModel;
private final ConstructionModel< T > constructionModel;
private final ProjectionModel< T > projectionModel;
public MainModel( SelectionModel selectionModel, ConstructionModel< T > constructionModel, ProjectionModel< T > projectionModel )
public MainModel( PreprocessingModel< T > preprocessingModel, SelectionModel selectionModel, ConstructionModel< T > constructionModel, ProjectionModel< T > projectionModel )
{
this.preprocessingModel = preprocessingModel;
this.selectionModel = selectionModel;
this.constructionModel = constructionModel;
this.projectionModel = projectionModel;
}
public PreprocessingModel< T > getPreprocessingModel()
{
return preprocessingModel;
}
public SelectionModel getSelectionModel()
{
return selectionModel;
......
package fr.pasteur.ida.zellige.gui.model;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.display.ColorTable;
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 java.util.ArrayList;
public class PreprocessingModel< T extends RealType< T > & NativeType< T > >
{
private final IntegerProperty bin = new SimpleIntegerProperty();
private final IntegerProperty channel = new SimpleIntegerProperty();
private final IntegerProperty nbOfChannels = new SimpleIntegerProperty();
private final SimpleObjectProperty< RandomAccessibleInterval<T> > input = new SimpleObjectProperty<>();
private final SimpleObjectProperty< RandomAccessibleInterval<T> > input_channel = new SimpleObjectProperty<>();
private final SimpleObjectProperty< ImgFactory< T > > factory = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img< FloatType > > pretreatedImg = new SimpleObjectProperty<>();
private final SimpleBooleanProperty parameterChanged = new SimpleBooleanProperty(false);
private final SimpleObjectProperty< ArrayList< ColorTable > > colors = new SimpleObjectProperty<>(new ArrayList<>());
public IntegerProperty binProperty()
{
return bin;
}
public SimpleObjectProperty< Img< FloatType > > pretreatedImgProperty()
{
return pretreatedImg;
}
public IntegerProperty getChannel()
{
return channel;
}
public SimpleBooleanProperty getParameterChanged()
{
return parameterChanged;
}
public SimpleObjectProperty< ImgFactory< T > > getFactory()
{
return factory;
}
public SimpleObjectProperty< RandomAccessibleInterval< T > > getInput()
{
return input;
}
public IntegerProperty getNbOfChannels()
{
return nbOfChannels;
}
public SimpleObjectProperty< ArrayList<ColorTable > > getColors()
{
return colors;
}
public SimpleObjectProperty< RandomAccessibleInterval< T > > getInput_channel()
{
return input_channel;
}
}
......@@ -28,311 +28,48 @@
*/
package fr.pasteur.ida.zellige.gui.model;
import fr.pasteur.ida.zellige.element.Projection;
import fr.pasteur.ida.zellige.element.ReferenceSurface;
import fr.pasteur.ida.zellige.steps.projection.ReferenceSurfaceProjection;
import fr.pasteur.ida.zellige.gui.ProjectionProperties;
import javafx.beans.property.*;
import net.imglib2.img.Img;
import net.imglib2.img.display.imagej.ImageJFunctions;
import javafx.scene.image.ImageView;
import net.imglib2.display.ColorTable;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
public class ProjectionModel< T extends RealType< T > & NativeType< T > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( ProjectionModel.class );
private final SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > referenceSurfaces;
private final SimpleBooleanProperty delta1Functions;
private final SimpleBooleanProperty delta2Functions;
private final IntegerProperty delta1;
private final IntegerProperty delta2;
private final StringProperty method;
private final SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > referenceSurfaces = new SimpleObjectProperty<>( new ArrayList<>() );
private final SimpleObjectProperty< ArrayList< ProjectionProperties< T > > > projectionProperties = new SimpleObjectProperty<>( new ArrayList<>() );
private final SimpleObjectProperty< ImageView[] > imageViews = new SimpleObjectProperty<>();
private final SimpleIntegerProperty numberOfChannels = new SimpleIntegerProperty();
private final BooleanProperty rawHM;
private final BooleanProperty projection;
private final BooleanProperty extractedHM;
private final BooleanProperty reduced3Dspace;
private final BooleanProperty segmentedSurface;
private final BooleanProperty segmentedSurfaceMask;
private final BooleanProperty rawHMDisplay;
private final BooleanProperty projectionDisplay;
private final BooleanProperty extractedHMDisplay;
private final BooleanProperty reduced3DspaceDisplay;
private final BooleanProperty segmentedSurfaceDisplay;
private final BooleanProperty segmentedSurfaceMaskDisplay;
public ProjectionModel()
{
this.referenceSurfaces = new SimpleObjectProperty<>();
this.delta1Functions = new SimpleBooleanProperty( false );
this.delta2Functions = new SimpleBooleanProperty( false );
this.method = new SimpleStringProperty();
this.delta1 = new SimpleIntegerProperty();
this.delta2 = new SimpleIntegerProperty();
this.rawHM = new SimpleBooleanProperty();
this.projection = new SimpleBooleanProperty();
this.extractedHM = new SimpleBooleanProperty();
this.reduced3Dspace = new SimpleBooleanProperty();
this.segmentedSurface = new SimpleBooleanProperty();
this.segmentedSurfaceMask = new SimpleBooleanProperty();
this.rawHMDisplay = new SimpleBooleanProperty( true );
this.projectionDisplay = new SimpleBooleanProperty( true );
this.extractedHMDisplay = new SimpleBooleanProperty( true );
this.reduced3DspaceDisplay = new SimpleBooleanProperty( true );
this.segmentedSurfaceDisplay = new SimpleBooleanProperty( true );
this.segmentedSurfaceMaskDisplay = new SimpleBooleanProperty( true );
}
public void showSegmentedSurfaceMask()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
ImageJFunctions.show( referenceSurface.getProjection().getSegmentedSurfaceMask(), "Surface_mask_" + referenceSurface.getIndex() );
}
}
public void showSegmentedSurface()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
ImageJFunctions.show( referenceSurface.getProjection().getSegmentedSurface(), "Segmented_surface_" + referenceSurface.getIndex() );
}
}
public void showReduced3DSpace()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
ImageJFunctions.show( referenceSurface.getProjection().getReduced3DSpace(), "Reduced_3D_space_" + referenceSurface.getIndex() );
}
}
public void showExtractedHeightMaps()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
ImageJFunctions.show( referenceSurface.getProjection().getExtractedHeightMap(), "Extracted_HM_" + referenceSurface.getIndex() );
}
}
public void showRawHeightMap()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
ImageJFunctions.show( referenceSurface.getzMap(), "Raw_HM_" + referenceSurface.getIndex() );
}
}
public void showProjections()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
ImageJFunctions.show( referenceSurface.getProjection().get(), "Projection_" + referenceSurface.getIndex() );
}
}
public void runProjection()
{
LOGGER.debug( "Starting projections ! " );
if ( ! delta1Functions.getValue() )
{
LOGGER.debug( "Output with delta1 " );
setOutputDelta1();
}
if ( ! delta2Functions.getValue() )
{
LOGGER.debug( "Output with delta2 " );
setOutputDelta2();
}
showOutput();
}
public void showOutput()
{
if ( rawHM.get() && rawHMDisplay.getValue() )
{
showRawHeightMap();
rawHMDisplay.setValue( false );
}
if ( projection.get() && projectionDisplay.get() )
{
showProjections();
projectionDisplay.setValue( false );
}
if ( extractedHM.get() && extractedHMDisplay.get() )
{
showExtractedHeightMaps();
extractedHMDisplay.setValue( false );
}
if ( segmentedSurface.get() && segmentedSurfaceDisplay.get() )
{
showSegmentedSurface();
segmentedSurface.setValue( false );
}
if ( reduced3Dspace.get() && reduced3DspaceDisplay.get() )
{
showReduced3DSpace();
reduced3DspaceDisplay.setValue( false );
}
if ( segmentedSurfaceMask.get() && segmentedSurfaceMaskDisplay.get() )
{
showSegmentedSurfaceMask();
segmentedSurfaceMask.setValue( false );
}
}
public void setOutputDelta1()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
Projection< T > projection = referenceSurface.getProjection();
Img< UnsignedShortType > extractedHeightMap = ReferenceSurfaceProjection.getProjectionHeightMap( referenceSurface, method.get(), delta1.intValue() );
projection.setExtractedHeightMap( extractedHeightMap );
projection.setProjection( ReferenceSurfaceProjection.projection1( referenceSurface, this.method.get() ) );
projection.setSegmentedSurface( ReferenceSurfaceProjection.getSegmentedSurface( extractedHeightMap, referenceSurface.getInput(), referenceSurface.getFactory() ) );
projection.setReduced3DSpace( ReferenceSurfaceProjection.getExtractedHeightMapSubStack( referenceSurface, delta1.intValue() ) );
}
delta1Functions.setValue( true );
}
public void setOutputDelta2()
{
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces.getValue() )
{
Projection< T > projection = referenceSurface.getProjection();
projection.setSegmentedSurfaceMask( ReferenceSurfaceProjection.getSegmentedSurfaceMask( projection.getSegmentedSurface(), delta2.intValue() ) );
}
delta2Functions.setValue( true );
}
public ArrayList< ReferenceSurface< T > > getReferenceSurfaces()
{
return referenceSurfaces.get();
}
public SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > referenceSurfacesProperty()
private final SimpleObjectProperty<ArrayList< ColorTable >> colors = new SimpleObjectProperty<>();
public SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > getReferenceSurfaces()
{
return referenceSurfaces;
}
public SimpleBooleanProperty delta1FunctionsProperty()
{
return delta1Functions;
}
public SimpleBooleanProperty delta2FunctionsProperty()
{
return delta2Functions;
}
public IntegerProperty delta1Property()
{
return delta1;
}
public IntegerProperty delta2Property()
{
return delta2;
}
public BooleanProperty rawHMProperty()
{
return rawHM;
}
public boolean isProjection()
{
return projection.get();
}
public BooleanProperty projectionProperty()
public SimpleObjectProperty< ImageView[] > getImageViews()
{
return projection;
return imageViews;
}
public BooleanProperty extractedHMProperty()
{
return extractedHM;
}
public BooleanProperty reduced3DspaceProperty()
{
return reduced3Dspace;
}
public BooleanProperty segmentedSurfaceProperty()
{
return segmentedSurface;
}
public BooleanProperty segmentedSurfaceMaskProperty()
{
return segmentedSurfaceMask;
}
public String getMethod()
{
return method.get();
}
public void setMethod( String method )
{
this.method.set( method );
}
public StringProperty methodProperty()
{
return method;
}
public BooleanProperty rawHMDisplayProperty()
{
return rawHMDisplay;
}
public BooleanProperty projectionDisplayProperty()
{
return projectionDisplay;
}
public BooleanProperty extractedHMDisplayProperty()
{
return extractedHMDisplay;
}
public BooleanProperty reduced3DspaceDisplayProperty()
public SimpleIntegerProperty getNumberOfChannels()
{
return reduced3DspaceDisplay;
return numberOfChannels;
}
public BooleanProperty segmentedSurfaceDisplayProperty()
public SimpleObjectProperty< ArrayList< ProjectionProperties< T > > > getProjectionProperties()
{
return segmentedSurfaceDisplay;
return projectionProperties;
}
public BooleanProperty segmentedSurfaceMaskDisplayProperty()
public SimpleObjectProperty< ArrayList< ColorTable > > getColors()
{
return segmentedSurfaceMaskDisplay;
return colors;
}
}
......@@ -28,28 +28,20 @@
*/
package fr.pasteur.ida.zellige.gui.model;
import fr.pasteur.ida.zellige.element.Pixels;
import fr.pasteur.ida.zellige.gui.ClassifiedImages;
import fr.pasteur.ida.zellige.gui.task.*;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.*;
import javafx.scene.image.ImageView;
import net.imglib2.img.Img;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SelectionModel
{
private final static Logger LOGGER = LoggerFactory.getLogger( SelectionModel.class );
private final DoubleProperty amplitude;
private final DoubleProperty otsu;
private final DoubleProperty island;
private final DoubleProperty xyBlur;
private final DoubleProperty zBlur;
private final IntegerProperty amplitude;
private final IntegerProperty otsu;
private final IntegerProperty island;
private final IntegerProperty xyBlur;
private final IntegerProperty zBlur;
private final SimpleBooleanProperty disableGUI = new SimpleBooleanProperty();
private final SimpleObjectProperty< Img< BitType > > islandSearchImage = new SimpleObjectProperty<>();
private final SimpleObjectProperty< ClassifiedImages< FloatType > > images = new SimpleObjectProperty<>();
......@@ -57,80 +49,18 @@ public class SelectionModel
private final SimpleObjectProperty< Img< BitType > > selectedAmplitude = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img< BitType > > selectedOtsu = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img< BitType > > interClassifiedImage = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Pixels[][] > selectedPixels = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img<FloatType> > selectedPixels = new SimpleObjectProperty<>();
private final SimpleObjectProperty< ImageView[] > imageViews = new SimpleObjectProperty<>();
private final SimpleBooleanProperty parameterChanged = new SimpleBooleanProperty(false);
public SelectionModel()
{
amplitude = new SimpleDoubleProperty();
otsu = new SimpleDoubleProperty();
island = new SimpleDoubleProperty();
xyBlur = new SimpleDoubleProperty();
zBlur = new SimpleDoubleProperty();
}
public void runAmplitudeTask()
{
AmplitudeThresholdingTask amplitudeTask = new AmplitudeThresholdingTask( images, amplitude.getValue().intValue() );
amplitudeTask.setOnSucceeded( workerStateEvent ->
{
selectedAmplitude.setValue( amplitudeTask.getValue() );
disableGUI.setValue( false );
} );
amplitudeTask.start();
}
public void runOtsuTask()
{
OtsuThresholdingTask otsuTask = new OtsuThresholdingTask( pretreatedImg, images, otsu.getValue().intValue() );
otsuTask.setOnSucceeded( workerStateEvent ->
{
selectedOtsu.setValue( otsuTask.getValue() );
disableGUI.setValue( false );
} );
otsuTask.start();
}
public void runInterClassification()
{
InterClassificationTask interClassificationTask = new InterClassificationTask( selectedAmplitude, selectedOtsu );
interClassificationTask.setOnSucceeded( event -> interClassifiedImage.setValue( interClassificationTask.getValue() ) );
interClassificationTask.start();
}
public void runIslandSearch()
{
IslandSearchTask islandSearchTask = new IslandSearchTask( interClassifiedImage, island );
islandSearchTask.setOnSucceeded( workerStateEvent ->
islandSearchImage.setValue( islandSearchTask.getValue() ) );
islandSearchTask.setOnFailed( workerStateEvent -> LOGGER.debug( "FAILED" ) );
islandSearchTask.start();
}
public void runSmoothing()
{
SmoothingTask smoothingTask = new SmoothingTask( islandSearchImage, xyBlur, zBlur );
smoothingTask.setOnSucceeded( event ->
{
selectedPixels.setValue( smoothingTask.getValue() );
LOGGER.debug( "max is set" );
} );
smoothingTask.start();
}
public void runPixelSelection()
{
if ( islandSearchImage.getValue() == null )
{
LOGGER.debug( "Island search image is NULL" );
runIslandSearch();
}
else if ( selectedPixelsProperty().getValue() == null )
public SelectionModel()
{
LOGGER.debug( "Island search image is not NULL" );
runSmoothing();
}
amplitude = new SimpleIntegerProperty();
otsu = new SimpleIntegerProperty();
island = new SimpleIntegerProperty();
xyBlur = new SimpleIntegerProperty();
zBlur = new SimpleIntegerProperty();
}
public double getAmplitude()
......@@ -138,12 +68,12 @@ public class SelectionModel
return amplitude.get();
}
public void setAmplitude( double amplitude )
public void setAmplitude( int amplitude )
{
this.amplitude.set( amplitude );
}
public DoubleProperty amplitudeProperty()
public IntegerProperty amplitudeProperty()
{
return amplitude;
}
......@@ -153,12 +83,12 @@ public class SelectionModel
return otsu.get();
}
public void setOtsu( double otsu )
public void setOtsu( int otsu )
{
this.otsu.set( otsu );
}
public DoubleProperty otsuProperty()
public IntegerProperty otsuProperty()
{
return otsu;
}
......@@ -168,161 +98,73 @@ public class SelectionModel
return island.get();
}
public void setIsland( double island )
public void setIsland( int island )
{
this.island.set( island );
}
public DoubleProperty islandProperty()
public IntegerProperty islandProperty()
{
return island;
}
public DoubleProperty xyBlurProperty()
public IntegerProperty xyBlurProperty()
{
return xyBlur;
}
public double getzBlur()
{
return zBlur.get();
}
public DoubleProperty zBlurProperty()
public IntegerProperty zBlurProperty()
{
return zBlur;
}
public boolean isDisableGUI()
{
return disableGUI.get();
}
public void setDisableGUI( boolean disableGUI )
{
this.disableGUI.set( disableGUI );
}
public SimpleBooleanProperty disableGUIProperty()
{
return disableGUI;
}
public Pixels[][] getSelectedPixels()
{
return selectedPixels.get();
}
public void setSelectedPixels( Pixels[][] selectedPixels )
{
this.selectedPixels.set( selectedPixels );
}
public SimpleObjectProperty< Pixels[][] > selectedPixelsProperty()
public SimpleObjectProperty< Img<FloatType> > selectedPixelsProperty()
{
return selectedPixels;
}
public ClassifiedImages< FloatType > getImages()
{
return images.get();
}
public void setImages( ClassifiedImages< FloatType > images )
{
this.images.set( images );
}
public SimpleObjectProperty< ClassifiedImages< FloatType > > imagesProperty()
{
return images;
}
public Img< BitType > getIslandSearchImage()
{
return islandSearchImage.get();
}
public void setIslandSearchImage( Img< BitType > islandSearchImage )
{
this.islandSearchImage.set( islandSearchImage );
}
public SimpleObjectProperty< Img< BitType > > islandSearchImageProperty()
{
return islandSearchImage;
}
public Img< FloatType > getPretreatedImg()
{
return pretreatedImg.get();
}
public void setPretreatedImg( Img< FloatType > pretreatedImg )
{
this.pretreatedImg.set( pretreatedImg );
}
public SimpleObjectProperty< Img< FloatType > > pretreatedImgProperty()
{
return pretreatedImg;
}
public Img< BitType > getSelectedAmplitude()
{
return selectedAmplitude.get();
}
public void setSelectedAmplitude( Img< BitType > selectedAmplitude )
{
this.selectedAmplitude.set( selectedAmplitude );
}
public SimpleObjectProperty< Img< BitType > > selectedAmplitudeProperty()
{
return selectedAmplitude;
}
public Img< BitType > getSelectedOtsu()
{
return selectedOtsu.get();
}
public void setSelectedOtsu( Img< BitType > selectedOtsu )
{
this.selectedOtsu.set( selectedOtsu );
}
public SimpleObjectProperty< Img< BitType > > selectedOtsuProperty()
{
return selectedOtsu;
}
public Img< BitType > getInterClassifiedImage()
{
return interClassifiedImage.get();
}
public void setInterClassifiedImage( Img< BitType > interClassifiedImage )
{
this.interClassifiedImage.set( interClassifiedImage );
}
public SimpleObjectProperty< Img< BitType > > interClassifiedImageProperty()
{
return interClassifiedImage;
}
public ImageView[] getImageViews()
{
return imageViews.get();
}
public SimpleObjectProperty< ImageView[] > imageViewsProperty()
{
return imageViews;
}
public SimpleBooleanProperty getParameterChanged()
{
return parameterChanged;
}
}
/*-
* #%L
* Zellige
* %%
* Copyright (C) 2020 - 2023 Institut Pasteur
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package fr.pasteur.ida.zellige.gui.parameter;
import fr.pasteur.ida.zellige.gui.ZDoubleProperty;
import javafx.beans.property.IntegerProperty;
public class ConstructionParameter
{
private final double c1;
private final int r1;
private final double st1;
private final double c2;
private final int r2;
private final double st2;
private final int surfaceSize;
public ConstructionParameter( ZDoubleProperty c1, IntegerProperty r1, ZDoubleProperty st1, ZDoubleProperty c2, IntegerProperty r2, ZDoubleProperty st2, ZDoubleProperty surfaceSize )
{
this.c1 = c1.value();
this.r1 = r1.intValue();
this.st1 = st1.value();
this.c2 = c2.value();
this.r2 = r2.intValue();
this.st2 = st2.value();
this.surfaceSize = surfaceSize.intValue();
}
public double getC1()
{
return c1;
}
public int getR1()
{
return r1;
}
public double getSt1()
{
return st1;
}
public double getC2()
{
return c2;
}
public int getR2()
{
return r2;
}
public double getSt2()
{
return st2;
}
public int getSurfaceSize()
{
return surfaceSize;
}
}
/*-
* #%L
* Zellige
* %%
* Copyright (C) 2020 - 2023 Institut Pasteur
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package fr.pasteur.ida.zellige.gui.parameter;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.StringProperty;
public class ProjectionParameter
{
private final int delta1;
private final int delta2;
private final String method;
public ProjectionParameter( IntegerProperty delta1, IntegerProperty delta2, StringProperty method )
{
this.delta1 = delta1.intValue();
this.delta2 = delta2.intValue();
this.method = method.get();
}
public int getDelta1()
{
return delta1;
}
public int getDelta2()
{
return delta2;
}
public String getMethod()
{
return method;
}
}
/*-
* #%L
* Zellige
* %%
* Copyright (C) 2020 - 2023 Institut Pasteur
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package fr.pasteur.ida.zellige.gui.parameter;
import javafx.beans.property.DoubleProperty;
public class SelectionParameter
{
private final int amplitude;
private final int otsu;
private final int island;
private final int xyBlur;
private final int zBlur;
public SelectionParameter( DoubleProperty amplitude, DoubleProperty otsu, DoubleProperty island, DoubleProperty xyBlur, DoubleProperty zBlur )
{
this.amplitude = amplitude.intValue();
this.otsu = otsu.intValue();
this.island = island.intValue();
this.xyBlur = xyBlur.intValue();
this.zBlur = zBlur.intValue();
}
public int getAmplitude()
{
return amplitude;
}
public int getOtsu()
{
return otsu;
}
public int getIsland()
{
return island;
}
public int getXyBlur()
{
return xyBlur;
}
public int getzBlur()
{
return zBlur;
}
}
......@@ -30,61 +30,39 @@ package fr.pasteur.ida.zellige.gui.parameter;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import fr.pasteur.ida.zellige.steps.construction.rounds.ConstructionParameters;
import fr.pasteur.ida.zellige.steps.projection.ProjectionParameters;
import fr.pasteur.ida.zellige.steps.selection.SelectionParameters;
import fr.pasteur.ida.zellige.steps.selection.pretreatment.PretreatmentParameters;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ZelligeParameters
{
private final PretreatmentParameters pretreatmentParameters;
//selection
private final int amplitude;
private final int otsu;
private final int island;
private final int xyBlur;
private final int zBlur;
//construction
private final double c1;
private final int r1;
private final double st1;
private final double c2;
private final int r2;
private final double st2;
private final int surfaceSize;
//projection
private final int delta1;
private final int delta2;
private final String method;
private final SelectionParameters selectionParameters;
private final ConstructionParameters[] constructionParameters;
private final ArrayList<ProjectionParameters> projectionParameters;
public ZelligeParameters( SelectionParameter sp, ConstructionParameter cp, ProjectionParameter pp )
public ZelligeParameters( PretreatmentParameters pretreatmentParameters, SelectionParameters selectionParameters, ConstructionParameters[] constructionParameters, ArrayList< ProjectionParameters > projectionParameters )
{
// selection
amplitude = sp.getAmplitude();
otsu = sp.getOtsu();
island = sp.getIsland();
xyBlur = sp.getXyBlur();
zBlur = sp.getzBlur();
// construction
c1 = cp.getC1();
r1 = cp.getR1();
st1 = cp.getSt1();
c2 = cp.getC2();
r2 = cp.getR2();
st2 = cp.getSt2();
surfaceSize = cp.getSurfaceSize();
// projection
delta1 = pp.getDelta1();
delta2 = pp.getDelta2();
method = pp.getMethod();
this.pretreatmentParameters = pretreatmentParameters;
this.selectionParameters = selectionParameters;
this.constructionParameters = constructionParameters;
this.projectionParameters = projectionParameters;
}
public static void serialize( final ZelligeParameters parameters, final File file ) throws IOException
{
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
......@@ -115,78 +93,23 @@ public class ZelligeParameters
}
}
public int getAmplitude()
{
return amplitude;
}
public int getOtsu()
{
return otsu;
}
public int getIsland()
{
return island;
}
public int getXyBlur()
{
return xyBlur;
}
public int getzBlur()
{
return zBlur;
}
public double getC1()
{
return c1;
}
public int getR1()
{
return r1;
}
public double getSt1()
{
return st1;
}
public double getC2()
{
return c2;
}
public int getR2()
{
return r2;
}
public double getSt2()
{
return st2;
}
public double getSurfaceSize()
public PretreatmentParameters getPretreatmentParameters()
{
return surfaceSize;
return pretreatmentParameters;
}
public String getMethod()
public SelectionParameters getSelectionParameters()
{
return method;
return selectionParameters;
}
public int getDelta1()
public ConstructionParameters[] getConstructionParameters()
{
return delta1;
return constructionParameters;
}
public int getDelta2()
public ArrayList< ProjectionParameters > getProjectionParameters()
{
return delta2;
return projectionParameters;
}
}
......@@ -28,33 +28,35 @@
*/
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.gui.ClassifiedImages;
import fr.pasteur.ida.zellige.steps.selection.classification.AmplitudeClassification;
import javafx.beans.property.SimpleObjectProperty;
import net.imglib2.img.Img;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class AmplitudeThresholdingTask extends AbstractTask< Img< BitType > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( AmplitudeThresholdingTask.class );
private final SimpleObjectProperty< ClassifiedImages< FloatType > > images;
private final Img<FloatType> input;
private final int amplitudeThreshold;
public AmplitudeThresholdingTask( SimpleObjectProperty< ClassifiedImages< FloatType > > images, int amplitudeThreshold )
public AmplitudeThresholdingTask( Img<FloatType> input, int amplitudeThreshold )
{
this.images = images;
this.input = input;
this.amplitudeThreshold = amplitudeThreshold;
}
@Override
protected Img< BitType > call()
{
LOGGER.info( "Computing amplitude thresholding..." );
return AmplitudeClassification.applyThreshold( images.getValue().getAmplitudeImg(), amplitudeThreshold );
LOGGER.info(GUI_MARKER, "Computing amplitude thresholding..." );
Img< BitType > output = AmplitudeClassification.applyThreshold( input, amplitudeThreshold );
LOGGER.info( GUI_MARKER,"Amplitude thresholds computed..." );
return output;
}
}
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.steps.selection.util.Binning;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class BinningTask < T extends RealType< T > & NativeType< T > > extends AbstractTask<Img<T>>
{
private final static Logger LOGGER = LoggerFactory.getLogger( BinningTask.class );
private final int bin;
private final RandomAccessibleInterval<T> input;
public BinningTask( int bin, RandomAccessibleInterval< T > input )
{
this.bin = bin;
this.input = input;
}
@Override
protected Img<T> call() {
LOGGER.info( GUI_MARKER,"Binning" );
Img<T> binnedImage = Binning.run( input, bin );
LOGGER.info( GUI_MARKER,"Image binned !" );
return binnedImage;
}
}
......@@ -38,6 +38,8 @@ import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class ComputeClassificationImagesTask extends AbstractTask< ClassifiedImages< FloatType > >
{
......@@ -53,12 +55,12 @@ public class ComputeClassificationImagesTask extends AbstractTask< ClassifiedIma
@Override
protected ClassifiedImages< FloatType > call() throws Exception
{
LOGGER.info( "Computing classified images..." );
LOGGER.info( GUI_MARKER,"Computing classified images..." );
ImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() );
ClassifiedImages< FloatType > images = new ClassifiedImages<>();
images.setAmplitudeImg( AmplitudeClassification.computeAmplitudeImage( pretreatedImg, factory ) );
images.setOtsuImg( OtsuClassification.computeOtsuImage( pretreatedImg, factory ) );
LOGGER.debug( "Classification images computed" );
LOGGER.debug( GUI_MARKER,"Classification images computed" );
return images;
}
}
......@@ -40,26 +40,36 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class ConstructionCompletionTask< T extends RealType< T > & NativeType< T > > extends AbstractTask< ArrayList< ReferenceSurface< T > > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( ConstructionCompletion.class );
private final static Logger LOGGER = LoggerFactory.getLogger( ConstructionCompletionTask.class );
private final RandomAccessibleInterval< T > input;
private final ImgFactory< T > factory;
private final ArrayList< Surface > finalSurfaces;
private final int bin;
public ConstructionCompletionTask( RandomAccessibleInterval< T > input, ImgFactory< T > factory, ArrayList< Surface > finalSurfaces )
public ConstructionCompletionTask( RandomAccessibleInterval< T > input, ImgFactory< T > factory, ArrayList< Surface > finalSurfaces, int bin )
{
this.input = input;
this.factory = factory;
this.finalSurfaces = finalSurfaces;
this.bin = bin;
}
@Override
protected ArrayList< ReferenceSurface< T > > call()
{
LOGGER.info( "Processing construction completion..." );
return ConstructionCompletion.run( input, factory, finalSurfaces );
LOGGER.info( GUI_MARKER,"Processing construction completion..." );
ArrayList< ReferenceSurface< T > > list = ConstructionCompletion.run( input, factory, finalSurfaces , bin);
LOGGER.info(GUI_MARKER, "construction completed..." );
if ( list.isEmpty() )
{
LOGGER.info( GUI_MARKER,"no surfaces..." );
}
return list;
}
}
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.element.ReferenceSurface;
import fr.pasteur.ida.zellige.gui.ImageFXDisplay;
import javafx.scene.image.ImageView;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
public class ConstructionDisplayTask< T extends RealType< T > & NativeType< T > > extends AbstractTask< ImageView[] >
{
private final static Logger LOGGER = LoggerFactory.getLogger( ConstructionDisplayTask.class );
private final ArrayList< ReferenceSurface< T > > referenceSurfaces;
public ConstructionDisplayTask( ArrayList< ReferenceSurface< T > > referenceSurfaces )
{
this.referenceSurfaces = referenceSurfaces;
}
@Override
protected ImageView[] call() throws IOException
{
ImageView[] imageViews = new ImageView[ referenceSurfaces.size() ];
int index = 0;
for ( ReferenceSurface< T > referenceSurface : referenceSurfaces )
{
ImageFXDisplay.setHM( referenceSurface.getzMap(), imageViews, index++ );
}
LOGGER.debug( "Task done. Display of {} height map(s).", referenceSurfaces.size() );
return imageViews;
}
}
......@@ -29,20 +29,21 @@
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.steps.selection.classification.Classification;
import javafx.beans.property.SimpleObjectProperty;
import net.imglib2.img.Img;
import net.imglib2.type.logic.BitType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class InterClassificationTask extends AbstractTask< Img< BitType > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( InterClassificationTask.class );
private final SimpleObjectProperty< Img< BitType > > selectedAmplitude;
private final SimpleObjectProperty< Img< BitType > > selectedOtsu;
private final Img< BitType >selectedAmplitude;
private final Img< BitType >selectedOtsu;
public InterClassificationTask( SimpleObjectProperty< Img< BitType > > selectedAmplitude, SimpleObjectProperty< Img< BitType > > selectedOtsu )
public InterClassificationTask( Img< BitType > selectedAmplitude, Img< BitType > selectedOtsu )
{
this.selectedAmplitude = selectedAmplitude;
this.selectedOtsu = selectedOtsu;
......@@ -53,8 +54,8 @@ public class InterClassificationTask extends AbstractTask< Img< BitType > >
protected Img< BitType > call()
{
LOGGER.info( "Computing inter-classification..." );
return Classification.interClassification( selectedAmplitude.getValue(), selectedAmplitude.getValue().factory(), selectedOtsu.getValue() );
LOGGER.info(GUI_MARKER, "Computing inter-classification..." );
return Classification.interClassification( selectedAmplitude, selectedAmplitude.factory(), selectedOtsu );
}
......
......@@ -29,21 +29,21 @@
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.steps.selection.postTreatment.PostTreatment;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import net.imglib2.img.Img;
import net.imglib2.type.logic.BitType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class IslandSearchTask extends AbstractTask< Img< BitType > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( IslandSearchTask.class );
private final SimpleObjectProperty< Img< BitType > > image;
private final DoubleProperty islandSize;
private final Img< BitType > image;
private final int islandSize;
public IslandSearchTask( SimpleObjectProperty< Img< BitType > > image, DoubleProperty islandSize )
public IslandSearchTask( Img< BitType > image, int islandSize )
{
this.image = image;
this.islandSize = islandSize;
......@@ -52,9 +52,9 @@ public class IslandSearchTask extends AbstractTask< Img< BitType > >
@Override
protected Img< BitType > call()
{
LOGGER.info( "Computing Island Search..." );
Img< BitType > img = PostTreatment.runIslandSearch( image.getValue(), islandSize.intValue() );
LOGGER.debug( "Task's end." );
LOGGER.info( GUI_MARKER,"Computing Island Search..." );
Img< BitType > img = PostTreatment.runIslandSearch( image, islandSize );
LOGGER.info( GUI_MARKER,"Task's end." );
return img;
// return iSImage;
}
......
......@@ -28,35 +28,37 @@
*/
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.gui.ClassifiedImages;
import fr.pasteur.ida.zellige.steps.selection.classification.OtsuClassification;
import javafx.beans.property.SimpleObjectProperty;
import net.imglib2.img.Img;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class OtsuThresholdingTask extends AbstractTask< Img< BitType > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( OtsuThresholdingTask.class );
private final SimpleObjectProperty< Img< FloatType > > pretreatedImage;
private final SimpleObjectProperty< ClassifiedImages< FloatType > > images;
private final Img< FloatType > pretreatedImage;
private final Img<FloatType> input;
private final int otsuThreshold;
public OtsuThresholdingTask( SimpleObjectProperty< Img< FloatType > > pretreatedImage, SimpleObjectProperty< ClassifiedImages< FloatType > > images, int otsuThreshold )
public OtsuThresholdingTask( Img< FloatType > pretreatedImage, Img<FloatType> input, int otsuThreshold )
{
this.pretreatedImage = pretreatedImage;
this.images = images;
this.input = input;
this.otsuThreshold = otsuThreshold;
}
@Override
protected Img< BitType > call()
{
LOGGER.info( "Computing otsu thresholding..." );
return OtsuClassification.applyLocalThreshold( pretreatedImage.getValue(), images.getValue().getOtsuImg(), otsuThreshold );
LOGGER.info( GUI_MARKER,"Computing otsu thresholding..." );
Img< BitType > output = OtsuClassification.applyLocalThreshold( pretreatedImage, input, otsuThreshold );
LOGGER.info( GUI_MARKER,"Amplitude thresholds computed..." );
return output;
}
}
......@@ -29,8 +29,7 @@
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.steps.selection.pretreatment.Pretreatment;
import net.imagej.Dataset;
import net.imagej.ImgPlus;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
......@@ -38,25 +37,30 @@ import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PretreatmentTask< T extends RealType< T > & NativeType< T > > extends AbstractTask< Img< FloatType > >
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class PreprocessingTask< T extends RealType< T > & NativeType< T > > extends AbstractTask< Img< FloatType > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( PretreatmentTask.class );
private final Dataset dataset;
private final static Logger LOGGER = LoggerFactory.getLogger( PreprocessingTask.class );
private final RandomAccessibleInterval<T> input;
private final double radius;
private final int bin;
public PretreatmentTask( Dataset dataset )
public PreprocessingTask( RandomAccessibleInterval<T> input, double radius, int bin)
{
this.dataset = dataset;
this.input = input;
this.radius = radius;
this.bin = bin;
}
@Override
@SuppressWarnings( "unchecked" )
protected Img< FloatType > call()
{
LOGGER.info( "Computing pretreatment..." );
ImgPlus< T > input = ( ImgPlus< T > ) dataset.getImgPlus();
Img< FloatType > pretreatedImg = Pretreatment.run( input );
LOGGER.debug( "Done." );
LOGGER.info(GUI_MARKER, "Computing pretreatment..." );
Img< FloatType > pretreatedImg = Pretreatment.run( input, radius, bin );
LOGGER.info( GUI_MARKER,"Done." );
return pretreatedImg;
}
}
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.element.ReferenceSurface;
import fr.pasteur.ida.zellige.gui.ChannelToolProperty;
import fr.pasteur.ida.zellige.gui.ProjectionProperties;
import fr.pasteur.ida.zellige.steps.projection.ReferenceSurfaceProjection;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.view.Views;
import java.util.ArrayList;
public class ProjectionTask< T extends RealType< T > & NativeType< T > > extends AbstractTask< Img< T > >
{
private final ReferenceSurface< T > referenceSurface;
private final ProjectionProperties< T > properties;
public ProjectionTask( ReferenceSurface< T > referenceSurface, ProjectionProperties< T > properties )
{
this.referenceSurface = referenceSurface;
this.properties = properties;
}
@Override
protected Img< T > call()
{
ArrayList< Img< T > > projections = new ArrayList<>();
for ( int channel = 0; channel < properties.getProperties().get().size(); channel++ )
{
RandomAccessibleInterval< T > input = Views.hyperSlice( referenceSurface.getInput(), 2, channel );
ChannelToolProperty< T > channelToolProperty = properties.getProperties().get().get( channel );
String method = channelToolProperty.getMethod().get();
if ( channelToolProperty.getSubVolume().get() == null )
{
int delta = channelToolProperty.getDeltaZ().get();
int offset = channelToolProperty.getOffset().get();
Img< T > subVolume = ReferenceSurfaceProjection.getSubStack(
input,
referenceSurface.getFactory(),
referenceSurface.getzMap(),
delta,
offset );
channelToolProperty.getSubVolume().set( subVolume );
}
Img< T > projection = ReferenceSurfaceProjection.run( channelToolProperty.getSubVolume().get(), method );
projections.add( projection );
}
return ReferenceSurfaceProjection.regroupChannels( projections );
}
}
......@@ -28,25 +28,28 @@
*/
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.element.Pixels;
import fr.pasteur.ida.zellige.element.Surface;
import fr.pasteur.ida.zellige.steps.construction.exception.NoSurfaceFoundException;
import fr.pasteur.ida.zellige.steps.construction.rounds.FirstRoundConstruction;
import net.imglib2.img.Img;
import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class RunFirstConstructionTask extends AbstractTask< ArrayList< Surface > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( RunFirstConstructionTask.class );
private final Pixels[][] maximums;
private final Img< FloatType > maximums;
private final double startingOsSize1;
private final int overlap1;
private final double connexityRate1;
private final double surfaceMinSizeFactor;
public RunFirstConstructionTask( Pixels[][] maximums, double startingOsSize1, int overlap1, double connexityRate1, double surfaceMinSizeFactor )
public RunFirstConstructionTask(Img<FloatType> maximums, double startingOsSize1, int overlap1, double connexityRate1, double surfaceMinSizeFactor )
{
this.maximums = maximums;
this.startingOsSize1 = startingOsSize1;
......@@ -58,7 +61,7 @@ public class RunFirstConstructionTask extends AbstractTask< ArrayList< Surface >
@Override
protected ArrayList< Surface > call()
{
LOGGER.info( "Computing first round construction..." );
LOGGER.info( GUI_MARKER,"Computing first round construction..." );
FirstRoundConstruction step1 = new FirstRoundConstruction( maximums, startingOsSize1, overlap1, connexityRate1, surfaceMinSizeFactor );
try
{
......@@ -66,7 +69,7 @@ public class RunFirstConstructionTask extends AbstractTask< ArrayList< Surface >
}
catch ( NoSurfaceFoundException e )
{
LOGGER.info( GUI_MARKER,"First round : No surfaces found..." );
return null;
}
return step1.getSurfaces();
......
......@@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import static fr.pasteur.ida.zellige.gui.MainAppFrame.GUI_MARKER;
public class RunSecondConstructionTask extends AbstractTask< ArrayList< Surface > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( RunSecondConstructionTask.class );
......@@ -58,15 +60,16 @@ public class RunSecondConstructionTask extends AbstractTask< ArrayList< Surface
@Override
protected ArrayList< Surface > call()
{
LOGGER.info( "Computing second round construction..." );
LOGGER.info( GUI_MARKER,"Computing second round construction..." );
SecondRoundConstruction step2 = new SecondRoundConstruction( surfaces, startingOsSize2, overlap2, connexityRate2, surfaceMinSizeFactor );
try
{
step2.process();
LOGGER.info(GUI_MARKER, "Second round : {} surface(s) found", step2.getSurfaces().size() );
}
catch ( NoSurfaceFoundException e )
{
LOGGER.info( GUI_MARKER,"No surface found" );
return null;
}
return step2.getSurfaces();
......