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
Commits on Source (8)
Showing
with 484 additions and 139 deletions
......@@ -64,8 +64,8 @@ public class Main
// Input of the image.
final String imagePath =// "C:\\Users\\ctrebeau\\Desktop\\Zellige analysis\\files\\SNR\\snr_000\\multiSurfaces\\phantoms_snr0.mat.tif";
args[ 0 ]; /* The image path goes here !!!! */
final String imagePath ="C:\\Users\\ctrebeau\\Desktop\\ramp_20_20.tif";
// args[ 0 ]; /* The image path goes here !!!! */
LOGGER.debug( imagePath );
/* JY version for opening files. */
final SCIFIOImgPlus< ? > imgPlus = IO.openAll( imagePath ).get( 0 );
......
......@@ -51,6 +51,7 @@ public class Zellige extends ContextCommand
.toAbsolutePath()
.toString();
String imageFilePath = "doc/Mouche.tif";
String imageFilePath2 = "doc/multi-channel-test.tif";
// Launch ImageJ.
ImageJ ij = new ImageJ();
......@@ -61,7 +62,8 @@ public class Zellige extends ContextCommand
// Display it.
ij.ui().show( obj );
/*obj = ij.io().open( new File( currentFolder, imageFilePath2 ).getAbsolutePath() );
ij.ui().show( obj );*/
ij.command().run( Zellige.class, true );
}
......
package fr.pasteur.ida.zellige.gui.controller;
public class ChannelController
{
}
......@@ -42,10 +42,7 @@ import fr.pasteur.ida.zellige.gui.parameter.ConstructionParameter;
import fr.pasteur.ida.zellige.gui.parameter.ProjectionParameter;
import fr.pasteur.ida.zellige.gui.parameter.SelectionParameter;
import fr.pasteur.ida.zellige.gui.parameter.ZelligeParameters;
import fr.pasteur.ida.zellige.gui.task.AbstractTask;
import fr.pasteur.ida.zellige.gui.task.ComputeClassificationImagesTask;
import fr.pasteur.ida.zellige.gui.task.DisplayDatasetChoicesTask;
import fr.pasteur.ida.zellige.gui.task.PretreatmentTask;
import fr.pasteur.ida.zellige.gui.task.*;
import javafx.application.Platform;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
......@@ -53,13 +50,13 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.*;
import javafx.stage.FileChooser;
import javafx.util.StringConverter;
import net.imagej.Dataset;
import net.imagej.ImgPlus;
import net.imagej.display.DefaultDatasetView;
import net.imagej.display.DefaultImageDisplay;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
......@@ -78,25 +75,31 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
{
private final static Logger LOGGER = LoggerFactory.getLogger( MainController.class );
private final SimpleObjectProperty< Dataset > currentDataset = new SimpleObjectProperty<>();
private int targetChannel = 1;
private final SimpleObjectProperty< DefaultDatasetView > currentDataset = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img< T > > referenceImage = new SimpleObjectProperty<>();
private final SimpleObjectProperty< ClassifiedImages< FloatType > > images = new SimpleObjectProperty<>();
private final SimpleObjectProperty< Img< FloatType > > pretreatedImg = new SimpleObjectProperty<>();
private final SimpleBooleanProperty disableGUI = new SimpleBooleanProperty();
private final SimpleBooleanProperty changedParameters = new SimpleBooleanProperty();
AbstractTask< Img< FloatType > > pretreatmentTask = null;
@FXML
Spinner<Integer> channels;
@FXML
ComboBox< Dataset > activeDatasets;
ComboBox< DefaultDatasetView > activeDatasets;
ComboBox< DefaultImageDisplay > x;
@FXML
private Button runButton;
@FXML
private ConstructionController< T > constructionController;
@FXML
private Label logInfo;
private MainAppFrame mainAppFrame;
@FXML
private ProjectionController< T > projectionController;
@FXML
private SelectionController< T > selectionController;
private SelectionController selectionController;
MainModel< T > model;
......@@ -107,7 +110,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
alert.setTitle( "Error alert" );
alert.setHeaderText( exception.getMessage() );
alert.showAndWait();
// throw new RuntimeException(exception);
}
@Override
......@@ -118,13 +120,30 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
activeDatasets.setOnMousePressed( event ->
setAndDisplayDatasetChoices() );// Update of the list of opened Fiji images
activeDatasets.setConverter( new StringConverter< DefaultDatasetView >()
{
@Override
public String toString( DefaultDatasetView defaultDatasetView )
{
if (defaultDatasetView!= null)
return defaultDatasetView.getData().getName();
return "";
}
@Override
public DefaultDatasetView fromString( String s )
{
return null;
}
} );
activeDatasets.getSelectionModel().selectedItemProperty().addListener( ( observableValue, oldValue, newValue ) ->
{
LOGGER.debug( "selectedItemProperty : old value = {}, new value = {} ", oldValue, newValue );
if(newValue!= null && isValid( newValue ))
channels.setDisable( false );
if(newValue!= null && isValid( newValue.getData() ))
{
setCurrentDataset( newValue );
currentDataset.setValue( newValue );
}
else
{
......@@ -132,13 +151,24 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
}
} );
channels.valueProperty().addListener( (observableValue, oldValue, newValue ) ->
{
if(!channels.isDisable() && newValue!= getTargetChannel())
{
setTargetChannel( newValue );
setReferenceImage();
}
} );
currentDataset.addListener( ( observableValue, dataset, t1 ) ->
{
if ( t1 != null )
{
selectionController.disableParameters();
disableGUI.setValue( true );
runPretreatment( currentDataset.getValue() );
SpinnerValueFactory< Integer > valueFactory =
new SpinnerValueFactory.IntegerSpinnerValueFactory( 1, (int) t1.getChannelCount(), 1 );
channels.setValueFactory( valueFactory );
setReferenceImage();
LOGGER.debug( "Current dataset Properties :{}", currentDataset.getValue().getData().getProperties() );
}
else
{
......@@ -147,6 +177,14 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
}
} );
referenceImage.addListener(( observableValue, dataset, t1 ) ->
{
selectionController.disableParameters();
disableGUI.setValue( true );
LOGGER.debug("New reference image selected");
runPretreatment( referenceImage.getValue() );
} );
pretreatedImg.addListener( ( observable, oldValue, newValue ) ->
{
if ( newValue != null )
......@@ -174,11 +212,15 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
/* Binding properties*/
selectionController.getSelectionModel().pretreatedImgProperty().bind( pretreatedImg );
selectionController.getSelectionModel().imagesProperty().bind( images );
constructionController.getConstructionModel().maximumsProperty().bind( selectionController.getSelectionModel().selectedPixelsProperty() );
projectionController.getModel().referenceSurfacesProperty().bind( constructionController.getConstructionModel().referenceSurfacesProperty() );
constructionController.getConstructionModel().maximumsProperty().bind(
selectionController.getSelectionModel().selectedPixelsProperty() );
projectionController.getModel().referenceSurfacesProperty().bind(
constructionController.getConstructionModel().referenceSurfacesProperty() );
changedParameters.bindBidirectional( selectionController.changedParametersProperty() );
selectionController.changedParametersProperty().bindBidirectional( constructionController.changedParametersProperty() );
constructionController.changedParametersProperty().bindBidirectional( projectionController.changedParametersProperty() );
selectionController.changedParametersProperty().bindBidirectional(
constructionController.changedParametersProperty() );
constructionController.changedParametersProperty().bindBidirectional(
projectionController.changedParametersProperty() );
disableGUI.bindBidirectional( selectionController.disableGUIProperty() );
changedParameters.addListener( ( observable, oldValue, newValue ) ->
......@@ -188,7 +230,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
{
LOGGER.debug( "Active button" );
disableGUI.setValue( false );
}
} );
......@@ -201,12 +242,10 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
public void initExtraction()
{
LOGGER.debug( "Init Extraction" );
Dataset dataset = mainAppFrame.getImage().getActiveDataset();
LOGGER.debug( dataset.getImgPlus().firstElement().getClass().toGenericString() );
LOGGER.debug( "Function getFrames() :{}", dataset.getFrames() );
LOGGER.debug( "Properties :{}", dataset.getImgPlus().getProperties() );
DefaultDatasetView dataset = ( DefaultDatasetView ) mainAppFrame.getImage().getActiveDatasetView();
LOGGER.debug( dataset.getData().firstElement().getClass().toGenericString() );
LOGGER.debug( "Function getFrames() :{}", dataset.getData().getFrames() );
if ( dataset == null )
{
showError( new NoInputException() );
......@@ -238,13 +277,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
LOGGER.debug( "###########################################---NEW RUN---###########################################" );
}
private void runPretreatment( Dataset dataset )
{
AbstractTask< Img< FloatType > > task = new PretreatmentTask<>( dataset );
task.setOnSucceeded( workerStateEvent ->
pretreatedImg.setValue( task.getValue() ) );
task.start();
}
public void setAndDisplayDatasetChoices()
{
......@@ -252,10 +285,9 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
displayTask.setOnSucceeded( workerStateEvent ->
{
LOGGER.debug( "Datasets displayed successfully" );
ObservableList< Dataset > list = FXCollections.observableArrayList( displayTask.getValue() );
ObservableList< DefaultDatasetView > list = FXCollections.observableArrayList( displayTask.getValue() );
list.add( null );
activeDatasets.setItems( list );
LOGGER.debug( "item selected : list size = " + list.size() );
if ( list.isEmpty() )
{
......@@ -266,15 +298,65 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
} );
displayTask.start();
}
private boolean isValid(Dataset dataset)
{
setTargetChannel( 1 );
channels.setDisable( false );
int numZ = ( int ) dataset.getDepth();
int numFrames = ( int ) dataset.getFrames();
int numChannels = (int) dataset.getChannels();
LOGGER.debug( "NUmber of dimensions: {}", dataset.numDimensions() );
LOGGER.debug( "NUmber of channels: {}", dataset.getChannels() );
LOGGER.debug( "Number of frames: {}", dataset.getFrames() );
if ( numFrames > 1 )
{
LOGGER.debug( "TimeLapseException" );
showError( new TimeLapseException() );
return false;
}
if ( numZ == 1 )
{
LOGGER.debug( "NoA3DStackException" );
showError( new NoA3DStackException() );
return false;
}
if (numChannels == 1)
{
channels.setDisable( true );
setTargetChannel( 0 );
}
LOGGER.debug( "The dataset is valid." );
return true;
}
@SuppressWarnings( "unchecked" )
public void setCurrentDataset( Dataset dataset )
public void setReferenceImage()
{
currentDataset.setValue( dataset );
Img< T > input = ( ImgPlus< T > ) dataset.getImgPlus();
constructionController.getConstructionModel().setInput( input );
constructionController.getConstructionModel().setFactory( input.factory() );
LOGGER.debug( "Setting reference image" );
Img< T > input = ( Img< T > ) currentDataset.getValue().getData().getImgPlus();
ReferenceImageSettingTask< T > task = new ReferenceImageSettingTask<>( input, getTargetChannel() );
task.setOnSucceeded( workerStateEvent ->
{
referenceImage.set( task.getValue() );
constructionController.getConstructionModel().setInput( referenceImage.getValue() );
constructionController.getConstructionModel().setFactory( referenceImage.get().factory() );
} );
task.start();
LOGGER.debug("Setting is done.");
}
private void runPretreatment( RandomAccessibleInterval<T> input )
{
// ImageJFunctions.show(input , "pretreatment");
if (pretreatmentTask!= null)
{
pretreatmentTask.cancel();
}
pretreatmentTask = new PretreatmentTask<>( input );
pretreatmentTask.setOnSucceeded( workerStateEvent ->
pretreatedImg.setValue( pretreatmentTask.getValue() ) );
pretreatmentTask.start();
}
public void computeClassifiedImages()
......@@ -372,26 +454,15 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
projectionController.setParameters( parameters );
}
private boolean isValid(Dataset dataset)
public int getTargetChannel()
{
int numZ = ( int ) dataset.getDepth();
int numFrames = ( int ) dataset.getFrames();
LOGGER.debug( "NUmber of dimensions: {}", dataset.numDimensions() );
LOGGER.debug( "NUmber of channels: {}", dataset.getChannels() );
LOGGER.debug( "Number of frames: {}", dataset.getFrames() );
if ( numFrames > 1 )
{
LOGGER.debug( "TimeLapseException" );
showError( new TimeLapseException() );
return false;
}
if ( numZ == 1 )
{
LOGGER.debug( "NoA3DStackException" );
showError( new NoA3DStackException() );
return false;
}
return true;
return targetChannel;
}
public void setTargetChannel( int targetChannel )
{
LOGGER.debug( " targetChannel = {}", targetChannel);
this.targetChannel = targetChannel;
}
}
......@@ -41,24 +41,19 @@ import javafx.geometry.Pos;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.RealType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class SelectionController< T extends RealType< T > & NativeType< T > > implements Initializable
public class SelectionController implements Initializable
{
private final static Logger LOGGER = LoggerFactory.getLogger( SelectionController.class );
private final SimpleBooleanProperty changedParameters = new SimpleBooleanProperty();
private final SimpleBooleanProperty disableGUI = new SimpleBooleanProperty();
private SelectionModel selectionModel;
@FXML
private ParameterSliderInteger amplitude;
@FXML
......@@ -301,21 +296,6 @@ public class SelectionController< T extends RealType< T > & NativeType< T > > im
return otsu;
}
public ParameterSliderInteger getXyBlur()
{
return xyBlur;
}
public ParameterSliderInteger getzBlur()
{
return zBlur;
}
public boolean isChangedParameters()
{
return changedParameters.get();
}
public SimpleBooleanProperty changedParametersProperty()
{
return changedParameters;
......
......@@ -32,11 +32,9 @@ import fr.pasteur.ida.zellige.element.Projection;
import fr.pasteur.ida.zellige.element.ReferenceSurface;
import fr.pasteur.ida.zellige.steps.projection.ReferenceSurfaceProjection;
import javafx.beans.property.*;
import net.imglib2.img.Img;
import net.imglib2.img.display.imagej.ImageJFunctions;
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;
......@@ -157,6 +155,9 @@ public class ProjectionModel< T extends RealType< T > & NativeType< T > >
showOutput();
}
public void showOutput()
{
if ( rawHM.get() && rawHMDisplay.getValue() )
......@@ -199,13 +200,18 @@ public class ProjectionModel< T extends RealType< T > & NativeType< T > >
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() ) );
if ( referenceSurface.getInput().numDimensions() == 3 )
// 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() ) );
//Projection2.project(referenceSurface.getInput(), referenceSurface.getFactory(), )
{
System.out.println();
}
}
delta1Functions.setValue( true );
}
......
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.steps.ChannelImageSelection;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ChannelImageSelectionTask < T extends RealType< T > & NativeType< T > >extends AbstractTask< Img< T > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( ChannelImageSelectionTask.class );
private final Img<T> input;
private final int targetChannel;
public ChannelImageSelectionTask( Img<T> input, int targetChannel )
{
this.input = input;
this.targetChannel = targetChannel;
}
@Override
protected Img<T > call()
{
LOGGER.info( "Channel selection" );
return ChannelImageSelection.run( input, targetChannel );
}
}
......@@ -28,7 +28,7 @@
*/
package fr.pasteur.ida.zellige.gui.task;
import net.imagej.Dataset;
import net.imagej.display.DefaultDatasetView;
import net.imagej.display.ImageDisplay;
import net.imagej.display.ImageDisplayService;
import org.slf4j.Logger;
......@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
public class DisplayDatasetChoicesTask extends AbstractTask< ArrayList< Dataset > >
public class DisplayDatasetChoicesTask extends AbstractTask< ArrayList< DefaultDatasetView > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( DisplayDatasetChoicesTask.class );
private final ImageDisplayService imageDisplayService;
......@@ -47,13 +47,13 @@ public class DisplayDatasetChoicesTask extends AbstractTask< ArrayList< Dataset
}
@Override
protected ArrayList< Dataset > call()
protected ArrayList< DefaultDatasetView > call()
{
ArrayList< ImageDisplay > imageDisplays = ( ArrayList< ImageDisplay > ) imageDisplayService.getImageDisplays();
ArrayList< Dataset > tempDatasets = new ArrayList<>( imageDisplays.size() );
ArrayList< DefaultDatasetView > tempDatasets = new ArrayList<>( imageDisplays.size() );
for ( ImageDisplay imageDisplay : imageDisplays )
{
tempDatasets.add( imageDisplayService.getActiveDataset( imageDisplay ) );
tempDatasets.add( ( DefaultDatasetView ) imageDisplayService.getActiveDatasetView( imageDisplay ) );
}
LOGGER.debug( "Available datasets updated." );
return tempDatasets;
......
......@@ -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;
......@@ -40,21 +39,18 @@ import org.slf4j.LoggerFactory;
public class PretreatmentTask< 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 RandomAccessibleInterval<T> input;
public PretreatmentTask( Dataset dataset )
public PretreatmentTask( RandomAccessibleInterval<T> input )
{
this.dataset = dataset;
this.input = input;
}
@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." );
return pretreatedImg;
......
package fr.pasteur.ida.zellige.gui.task;
import fr.pasteur.ida.zellige.steps.ChannelImageSelection;
import net.imglib2.img.Img;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReferenceImageSettingTask < T extends RealType< T > & NativeType< T > > extends AbstractTask< Img<T> >
{
private final static Logger LOGGER = LoggerFactory.getLogger( ReferenceImageSettingTask.class );
private final Img<T> input;
private final int targetChannel;
public ReferenceImageSettingTask( Img< T > input, int targetChannel )
{
this.input = input;
this.targetChannel = targetChannel;
}
@Override
protected Img<T> call()
{
return ChannelImageSelection.run( input, targetChannel );
}
}
package fr.pasteur.ida.zellige.steps;
import net.imagej.display.DefaultDatasetView;
import net.imglib2.RandomAccess;
import net.imglib2.display.ColorTable;
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 java.util.List;
public class ChannelImageSelection< T extends RealType< T > & NativeType< T > >
{
private final static Logger LOGGER = LoggerFactory.getLogger( ChannelImageSelection.class );
private final static int GRAYS = 0;
private final static int RED = 1;
private final static int BLUE = 2;
private final static int GREEN = 3;
private final static int CYAN = 4;
private final static int MAGENTA = 5;
private final static int YELLOW = 6;
private final int targetChannel;
private final Img<T> input;
public static < T extends RealType< T > & NativeType< T > > Img< T > run( Img<T> input, int targetChannel )
{
ChannelImageSelection< T > channelImageSelection = new ChannelImageSelection<>( input, targetChannel);
return channelImageSelection.run();
}
/**
*
* @param input
* @param targetChannel
*/
public ChannelImageSelection( Img<T> input, int targetChannel )
{
this.targetChannel = targetChannel;
this.input = input;
LOGGER.debug( " running...." );
}
public Img< T > run()
{
if ( getTargetChannel() == 0 )
{
return input;
}
else
{
Img< T > output = input.factory().create( input.dimension( 0 ), input.dimension( 1 ), input.dimension( 3 ) );
RandomAccess< T > randomAccess = input.randomAccess();
RandomAccess< T > randomAccess1 = output.randomAccess();
for ( int x = 0; x < ( int ) input.dimension( 0 ); x++ )
{
for ( int y = 0; y < ( int ) input.dimension( 1 ); y++ )
{
for ( int z = 0; z < ( int ) input.dimension( 3 ); z++ )
{
randomAccess.setPositionAndGet( x, y, getTargetChannel() - 1, z );
randomAccess1.setPosition( new int[]{ x, y, z } );
randomAccess1.get().set( randomAccess.get() );
}
}
}
return output;
}
}
public int getTargetChannel()
{
return targetChannel;
}
/**
*
* @param defaultDatasetView the input image
* @return an int array of colors
*/
private static int[] getColors( DefaultDatasetView defaultDatasetView )
{
return getColors( defaultDatasetView.getColorTables() );
}
private static int [] getColors( List<ColorTable> colorTables)
{
int[] colors = new int[ colorTables.size() ];
if (colors.length == 1)
{
colors[0] = GRAYS;
return colors;
}
for ( int i = 0; i <colorTables.size(); i++ )
{
colors[i]= getColor( colorTables.get( i ));
}
return colors;
}
private static int getColor( ColorTable colorTable )
{
int R = colorTable.get( 0, 255 );
int G = colorTable.get( 1, 255 );
int B = colorTable.get( 2, 255 );
if ( R== 0)
{
if (G == 0)
{
return BLUE; // BLUE
}
else
{
if (B == 0)
{
return GREEN; // GREEN
}
return CYAN ; // CYAN
}
}
else
{
if (G == 0)
{
if (B == 0)
{
return RED; // RED
}
return MAGENTA ; // MAGENTA
}
else
{
if (B == 0)
{
return YELLOW; // YELLOW
}
return GRAYS ; // GRAYS
}
}
}
}
......@@ -74,6 +74,12 @@ public class Utils
setPosition( randomAccess, u, v );
randomAccess.setPosition( z, 2 );
}
public static < T extends RealType< T > & NativeType< T > > T setPosition( RandomAccess< T > randomAccess, int u, int v, int channel, int z)
{
setPosition( randomAccess, u, v, channel );
randomAccess.setPosition( z, 3 );
return randomAccess.get();
}
public static < T extends RealType< T > & NativeType< T > > T setPositionAndGet( RandomAccess< T > randomAccess, int u, int v )
......@@ -87,4 +93,6 @@ public class Utils
setPosition( randomAccess, u, v, z );
return randomAccess.get();
}
}
......@@ -6,13 +6,13 @@
* %%
* 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
......@@ -85,6 +85,67 @@ public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T
}
public static < T extends RealType< T > & NativeType< T > > Img< T > getReducedStack( ReferenceSurface< T > referenceSurface,
int offset, int deltaZ, int channel )
{
RandomAccessibleInterval< T > input = referenceSurface.getInput();
RandomAccessibleInterval< UnsignedShortType > zMap = referenceSurface.getzMap();
//The stack slice number depends on the user "deltaZ" parameter.
Img< T > reducedStack = referenceSurface.getFactory().create( input.dimension( 0 ), input.dimension( 1 ), deltaZ * 2L + 1 );
RandomAccess< T > inputAccess = input.randomAccess();
RandomAccess< UnsignedShortType > zMapAccess = zMap.randomAccess();
RandomAccess< T > outputAccess = reducedStack.randomAccess();
for ( int x = 0; x <= input.dimension( 0 ) - 1; x++ )
{
zMapAccess.setPosition( x, 0 );
for ( int y = 0; y <= input.dimension( 1 ) - 1; y++ )
{
zMapAccess.setPosition( y, 1 );
int zMapValue = zMapAccess.get().getInteger() - 1;// ImageJ can not display negative values.
if ( zMapValue != - 1 ) // a surface pixel has been found at that position
{
int startIndex = Math.max( zMapValue + offset - deltaZ, 0 );
int stopIndex = Math.min( ( zMapValue + offset + deltaZ ), ( int ) input.dimension( 2 ) - 1 );
int Z = deltaZ;
for ( int z = zMapValue; z >= startIndex; z-- )
{
setPosition( outputAccess, x, y, Z );
setPosition( inputAccess, x, y, channel, z );
outputAccess.get().set( inputAccess.get() );
Z--;
}
//second loop for plus delta
Z = deltaZ + 1;
for ( int z = zMapValue + 1; z <= stopIndex; z++ )
{
setPosition( outputAccess, x, y, Z );
setPosition( inputAccess, x, y, z );
outputAccess.get().set( inputAccess.get() );
Z++;
}
}
else
{
for ( int z = 0; z <= reducedStack.dimension( 2 ) - 1; z++ )
{
setPosition( outputAccess, x, y, z );
outputAccess.get().setReal( 0 );
}
}
}
}
return reducedStack;
}
public static < T extends RealType< T > & NativeType< T > > Img< T > projection( RandomAccessibleInterval< T > reducedStack, ImgFactory< T > factory, String method )
{
Img< T > projection = factory.create( reducedStack.dimension( 0 ), reducedStack.dimension( 1 ), 1 );
return projection;
}
/**
* @param referenceSurface the considered referenceSurface
* @param method the desired user projection method
......@@ -221,7 +282,7 @@ public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T
public static < T extends RealType< T > & NativeType< T > > Img< T > getSegmentedSurface
( Img< UnsignedShortType > extractedHeightMap, RandomAccessibleInterval< T > originalInput, ImgFactory< T > factory )
( Img< UnsignedShortType > extractedHeightMap, RandomAccessibleInterval< T > originalInput, ImgFactory< T > factory )
{
Img< T > segmentedSurface = factory.create( originalInput );
RandomAccess< T > surfaceAccess = segmentedSurface.randomAccess();
......@@ -629,6 +690,15 @@ public class ReferenceSurfaceProjection< T extends RealType< T > & NativeType< T
}
}
public static < T extends RealType< T > & NativeType< T > > void channelProjection(
final RandomAccessibleInterval<T> inputChannel,
final RandomAccessibleInterval< T > outputChannel,
final RandomAccessibleInterval< UnsignedShortType > referenceSurface,
final int offset, final int deltaZ )
{
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress JavaFxDefaultTag, JavaFxUnresolvedFxIdReference -->
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<VBox xmlns:fx="http://javafx.com/fxml" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
minHeight="-Infinity" minWidth="-Infinity" prefHeight="786.0" prefWidth="866.0" spacing="5.0"
stylesheets="@theme2.css" xmlns="http://javafx.com/javafx"
fx:controller="fr.pasteur.ida.zellige.gui.controller.MainController">
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="786.0" prefWidth="866.0" spacing="5.0" stylesheets="@theme2.css" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.pasteur.ida.zellige.gui.controller.MainController">
<padding>
<Insets left="10.0" right="10.0" top="5.0"/>
<Insets left="10.0" right="10.0" top="5.0" />
</padding>
<HBox alignment="CENTER_LEFT" prefHeight="26.0" prefWidth="774.0" spacing="5.0" VBox.vgrow="ALWAYS">
<HBox alignment="CENTER_LEFT" prefHeight="26.0" prefWidth="759.0" spacing="5.0" VBox.vgrow="ALWAYS">
<padding>
<Insets left="10.0"/>
<Insets left="10.0" />
</padding>
<HBox alignment="CENTER_LEFT" prefHeight="45.0" prefWidth="494.0">
<HBox alignment="CENTER_LEFT" prefHeight="26.0" prefWidth="483.0">
<children>
<Label prefHeight="12.0" prefWidth="71.0" text="File : ">
<font>
<Font size="14.0"/>
<Font size="14.0" />
</font>
</Label>
<ComboBox fx:id="activeDatasets" minHeight="-Infinity" minWidth="-Infinity" prefHeight="26.0"
prefWidth="262.0"/>
<ComboBox fx:id="activeDatasets" minHeight="-Infinity" minWidth="-Infinity" prefHeight="26.0" prefWidth="401.0" />
</children>
</HBox>
<HBox alignment="CENTER_RIGHT" prefHeight="45.0" prefWidth="333.0" spacing="10.0">
<HBox prefHeight="26.0" prefWidth="83.0">
<children>
<Label text="Channel" />
<Spinner fx:id="channels" prefHeight="21.0" prefWidth="42.0" />
</children>
</HBox>
<HBox alignment="CENTER_RIGHT" prefHeight="26.0" prefWidth="151.0" spacing="10.0">
<children>
<Button mnemonicParsing="false" onAction="#loadParameters" text="Load parameters">
<Button mnemonicParsing="false" onAction="#loadParameters" text="Load">
<graphic>
<ImageView fitHeight="15.0" fitWidth="22.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@/icons/script_add.png"/>
<Image url="@/icons/script_add.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button mnemonicParsing="false" onAction="#saveParameters" text="Save Parameters">
<Button mnemonicParsing="false" onAction="#saveParameters" text="Save">
<graphic>
<ImageView fitHeight="15.0" fitWidth="26.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/script_save.png"/>
<Image url="@../icons/script_save.png" />
</image>
</ImageView>
</graphic>
......@@ -52,23 +55,18 @@
</children>
</HBox>
</HBox>
<fx:include fx:id="selection" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
minHeight="-Infinity" minWidth="-Infinity" source="Selection.fxml" VBox.vgrow="ALWAYS"/>
<fx:include fx:id="selection" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" source="Selection.fxml" VBox.vgrow="ALWAYS" />
<HBox alignment="CENTER_LEFT" prefHeight="319.0" prefWidth="700.0" spacing="5.0">
<fx:include fx:id="construction" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
minHeight="-Infinity" minWidth="-Infinity" source="Construction.fxml" HBox.hgrow="ALWAYS"/>
<fx:include fx:id="projection" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
minHeight="-Infinity" minWidth="-Infinity" source="Projection.fxml" HBox.hgrow="ALWAYS"/>
<fx:include fx:id="construction" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" source="Construction.fxml" HBox.hgrow="ALWAYS" />
<fx:include fx:id="projection" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" source="Projection.fxml" HBox.hgrow="ALWAYS" />
</HBox>
<StackPane prefHeight="51.0" prefWidth="747.0" VBox.vgrow="ALWAYS">
<BorderPane prefHeight="27.0" prefWidth="846.0">
<left>
<Label fx:id="logInfo" alignment="CENTER" prefHeight="32.0" prefWidth="418.0"
BorderPane.alignment="CENTER"/>
<Label fx:id="logInfo" alignment="CENTER" prefHeight="32.0" prefWidth="418.0" BorderPane.alignment="CENTER" />
</left>
<center>
<Button fx:id="runButton" disable="true" mnemonicParsing="false" text="Run Zellige !"
BorderPane.alignment="TOP_CENTER"/>
<Button fx:id="runButton" disable="true" mnemonicParsing="false" text="Run Zellige !" BorderPane.alignment="TOP_CENTER" />
</center>
</BorderPane>
</StackPane>
......