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

Target

Select target project
  • ida-public/zellige-core
1 result
Show changes
Showing
with 368 additions and 851 deletions
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
* %% * %%
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
...@@ -33,18 +33,26 @@ import net.imglib2.type.numeric.RealType; ...@@ -33,18 +33,26 @@ import net.imglib2.type.numeric.RealType;
public class MainModel< T extends RealType< T > & NativeType< T > > public class MainModel< T extends RealType< T > & NativeType< T > >
{ {
private final PreprocessingModel< T > preprocessingModel;
private final SelectionModel selectionModel; private final SelectionModel selectionModel;
private final ConstructionModel< T > constructionModel; private final ConstructionModel< T > constructionModel;
private final ProjectionModel< T > projectionModel; 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.selectionModel = selectionModel;
this.constructionModel = constructionModel; this.constructionModel = constructionModel;
this.projectionModel = projectionModel; this.projectionModel = projectionModel;
} }
public PreprocessingModel< T > getPreprocessingModel()
{
return preprocessingModel;
}
public SelectionModel getSelectionModel() public SelectionModel getSelectionModel()
{ {
return selectionModel; 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,28 +28,20 @@ ...@@ -28,28 +28,20 @@
*/ */
package fr.pasteur.ida.zellige.gui.model; 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.ClassifiedImages;
import fr.pasteur.ida.zellige.gui.task.*; import javafx.beans.property.*;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import net.imglib2.img.Img; import net.imglib2.img.Img;
import net.imglib2.type.logic.BitType; import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.real.FloatType; import net.imglib2.type.numeric.real.FloatType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SelectionModel public class SelectionModel
{ {
private final static Logger LOGGER = LoggerFactory.getLogger( SelectionModel.class ); private final IntegerProperty amplitude;
private final DoubleProperty amplitude; private final IntegerProperty otsu;
private final DoubleProperty otsu; private final IntegerProperty island;
private final DoubleProperty island; private final IntegerProperty xyBlur;
private final DoubleProperty xyBlur; private final IntegerProperty zBlur;
private final DoubleProperty zBlur;
private final SimpleBooleanProperty disableGUI = new SimpleBooleanProperty(); private final SimpleBooleanProperty disableGUI = new SimpleBooleanProperty();
private final SimpleObjectProperty< Img< BitType > > islandSearchImage = new SimpleObjectProperty<>(); private final SimpleObjectProperty< Img< BitType > > islandSearchImage = new SimpleObjectProperty<>();
private final SimpleObjectProperty< ClassifiedImages< FloatType > > images = new SimpleObjectProperty<>(); private final SimpleObjectProperty< ClassifiedImages< FloatType > > images = new SimpleObjectProperty<>();
...@@ -57,80 +49,18 @@ public class SelectionModel ...@@ -57,80 +49,18 @@ public class SelectionModel
private final SimpleObjectProperty< Img< BitType > > selectedAmplitude = new SimpleObjectProperty<>(); private final SimpleObjectProperty< Img< BitType > > selectedAmplitude = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img< BitType > > selectedOtsu = new SimpleObjectProperty<>(); private final SimpleObjectProperty< Img< BitType > > selectedOtsu = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img< BitType > > interClassifiedImage = 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 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() public SelectionModel()
{
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 ) amplitude = new SimpleIntegerProperty();
{ otsu = new SimpleIntegerProperty();
LOGGER.debug( "Island search image is NULL" ); island = new SimpleIntegerProperty();
runIslandSearch(); xyBlur = new SimpleIntegerProperty();
} zBlur = new SimpleIntegerProperty();
else if ( selectedPixelsProperty().getValue() == null )
{
LOGGER.debug( "Island search image is not NULL" );
runSmoothing();
}
} }
public double getAmplitude() public double getAmplitude()
...@@ -138,12 +68,12 @@ public class SelectionModel ...@@ -138,12 +68,12 @@ public class SelectionModel
return amplitude.get(); return amplitude.get();
} }
public void setAmplitude( double amplitude ) public void setAmplitude( int amplitude )
{ {
this.amplitude.set( amplitude ); this.amplitude.set( amplitude );
} }
public DoubleProperty amplitudeProperty() public IntegerProperty amplitudeProperty()
{ {
return amplitude; return amplitude;
} }
...@@ -153,12 +83,12 @@ public class SelectionModel ...@@ -153,12 +83,12 @@ public class SelectionModel
return otsu.get(); return otsu.get();
} }
public void setOtsu( double otsu ) public void setOtsu( int otsu )
{ {
this.otsu.set( otsu ); this.otsu.set( otsu );
} }
public DoubleProperty otsuProperty() public IntegerProperty otsuProperty()
{ {
return otsu; return otsu;
} }
...@@ -168,161 +98,73 @@ public class SelectionModel ...@@ -168,161 +98,73 @@ public class SelectionModel
return island.get(); return island.get();
} }
public void setIsland( double island ) public void setIsland( int island )
{ {
this.island.set( island ); this.island.set( island );
} }
public DoubleProperty islandProperty() public IntegerProperty islandProperty()
{ {
return island; return island;
} }
public DoubleProperty xyBlurProperty() public IntegerProperty xyBlurProperty()
{ {
return xyBlur; return xyBlur;
} }
public double getzBlur() public IntegerProperty zBlurProperty()
{
return zBlur.get();
}
public DoubleProperty zBlurProperty()
{ {
return zBlur; return zBlur;
} }
public boolean isDisableGUI()
{
return disableGUI.get();
}
public void setDisableGUI( boolean disableGUI )
{
this.disableGUI.set( disableGUI );
}
public SimpleBooleanProperty disableGUIProperty() public SimpleBooleanProperty disableGUIProperty()
{ {
return disableGUI; return disableGUI;
} }
public Pixels[][] getSelectedPixels() public SimpleObjectProperty< Img<FloatType> > selectedPixelsProperty()
{
return selectedPixels.get();
}
public void setSelectedPixels( Pixels[][] selectedPixels )
{
this.selectedPixels.set( selectedPixels );
}
public SimpleObjectProperty< Pixels[][] > selectedPixelsProperty()
{ {
return selectedPixels; return selectedPixels;
} }
public ClassifiedImages< FloatType > getImages()
{
return images.get();
}
public void setImages( ClassifiedImages< FloatType > images )
{
this.images.set( images );
}
public SimpleObjectProperty< ClassifiedImages< FloatType > > imagesProperty() public SimpleObjectProperty< ClassifiedImages< FloatType > > imagesProperty()
{ {
return images; return images;
} }
public Img< BitType > getIslandSearchImage()
{
return islandSearchImage.get();
}
public void setIslandSearchImage( Img< BitType > islandSearchImage )
{
this.islandSearchImage.set( islandSearchImage );
}
public SimpleObjectProperty< Img< BitType > > islandSearchImageProperty() public SimpleObjectProperty< Img< BitType > > islandSearchImageProperty()
{ {
return islandSearchImage; return islandSearchImage;
} }
public Img< FloatType > getPretreatedImg()
{
return pretreatedImg.get();
}
public void setPretreatedImg( Img< FloatType > pretreatedImg )
{
this.pretreatedImg.set( pretreatedImg );
}
public SimpleObjectProperty< Img< FloatType > > pretreatedImgProperty() public SimpleObjectProperty< Img< FloatType > > pretreatedImgProperty()
{ {
return pretreatedImg; return pretreatedImg;
} }
public Img< BitType > getSelectedAmplitude()
{
return selectedAmplitude.get();
}
public void setSelectedAmplitude( Img< BitType > selectedAmplitude )
{
this.selectedAmplitude.set( selectedAmplitude );
}
public SimpleObjectProperty< Img< BitType > > selectedAmplitudeProperty() public SimpleObjectProperty< Img< BitType > > selectedAmplitudeProperty()
{ {
return selectedAmplitude; return selectedAmplitude;
} }
public Img< BitType > getSelectedOtsu()
{
return selectedOtsu.get();
}
public void setSelectedOtsu( Img< BitType > selectedOtsu )
{
this.selectedOtsu.set( selectedOtsu );
}
public SimpleObjectProperty< Img< BitType > > selectedOtsuProperty() public SimpleObjectProperty< Img< BitType > > selectedOtsuProperty()
{ {
return selectedOtsu; return selectedOtsu;
} }
public Img< BitType > getInterClassifiedImage()
{
return interClassifiedImage.get();
}
public void setInterClassifiedImage( Img< BitType > interClassifiedImage )
{
this.interClassifiedImage.set( interClassifiedImage );
}
public SimpleObjectProperty< Img< BitType > > interClassifiedImageProperty() public SimpleObjectProperty< Img< BitType > > interClassifiedImageProperty()
{ {
return interClassifiedImage; return interClassifiedImage;
} }
public ImageView[] getImageViews()
{
return imageViews.get();
}
public SimpleObjectProperty< ImageView[] > imageViewsProperty() public SimpleObjectProperty< ImageView[] > imageViewsProperty()
{ {
return imageViews; return imageViews;
} }
public SimpleBooleanProperty getParameterChanged()
{
return parameterChanged;
}
} }