-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge origin/tuananh into new-feature
Conflicts: src/main/java/ijfx/plugins/ImageJ1PluginAdapter.java src/main/java/ijfx/service/preview/PreviewService.java src/main/resources/ijfx/ui/main/flatterfx.css src/main/resources/ijfx/ui/menutoolbar/toolbarSettings.json
- Loading branch information
Showing
33 changed files
with
8,907 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ log-*.txt.lck | |
*.log | ||
*.gz | ||
package.sh | ||
target/* | ||
target/* | ||
/nbproject/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
src/main/java/ijfx/plugins/AbstractImageJ1PluginAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
/* | ||
* /* | ||
* This file is part of ImageJ FX. | ||
* | ||
* ImageJ FX is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* ImageJ FX is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with ImageJ FX. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright 2015,2016 Cyril MONGIS, Michael Knop | ||
* | ||
*/ | ||
package ijfx.plugins; | ||
|
||
import ij.ImagePlus; | ||
import static java.lang.Math.toIntExact; | ||
import java.util.stream.IntStream; | ||
import net.imagej.Dataset; | ||
import net.imagej.DatasetService; | ||
import net.imagej.axis.Axes; | ||
import net.imagej.axis.AxisType; | ||
import net.imagej.axis.CalibratedAxis; | ||
import net.imagej.display.ImageDisplay; | ||
import net.imagej.display.ImageDisplayService; | ||
import net.imglib2.RandomAccessibleInterval; | ||
import net.imglib2.img.Img; | ||
import net.imglib2.img.display.imagej.ImageJFunctions; | ||
|
||
import net.imglib2.type.numeric.integer.UnsignedShortType; | ||
import org.scijava.ItemIO; | ||
import org.scijava.command.Command; | ||
import org.scijava.event.EventService; | ||
import org.scijava.plugin.Parameter; | ||
|
||
/** | ||
* | ||
* @author Cyril MONGIS, 2015 | ||
* @author Tuan anh TRINH | ||
*/ | ||
public abstract class AbstractImageJ1PluginAdapter implements Command { | ||
|
||
@Parameter | ||
DatasetService service; | ||
|
||
@Parameter | ||
ImageDisplayService imageDisplayService; | ||
|
||
@Parameter | ||
EventService eventService; | ||
|
||
@Parameter | ||
boolean createCopy; | ||
|
||
boolean wholeWrap = false; | ||
|
||
public abstract ImagePlus processImagePlus(ImagePlus input); | ||
|
||
public ImagePlus getInput(Dataset dataset) { | ||
return unwrapDataset(dataset); | ||
} | ||
|
||
public Dataset setOutput(ImagePlus imp, Dataset dataset) { | ||
if (!wholeWrap) { | ||
dataset = wrapDataset(imp); | ||
} else { | ||
ImagePlus resultCopy = imp.duplicate(); | ||
if (createCopy) { | ||
dataset = emptyDataset(dataset, dataset.numDimensions()); | ||
} | ||
Dataset dataset2 = wrapDataset(resultCopy); | ||
for (int i = 0; i < getNumberOfSlices(dataset); i++) { | ||
dataset.setPlane(i, dataset2.getPlane(i)); | ||
} | ||
|
||
} | ||
return dataset; | ||
} | ||
|
||
public static ImagePlus unwrapDataset(Dataset dataset) { | ||
RandomAccessibleInterval<UnsignedShortType> r = (RandomAccessibleInterval<UnsignedShortType>) dataset.getImgPlus(); | ||
ImagePlus wrapImage = ImageJFunctions.wrap(r, ""); | ||
return wrapImage; | ||
} | ||
|
||
public Dataset wrapDataset(ImagePlus imp) { | ||
Img img = ImageJFunctions.wrap(imp.duplicate()); | ||
return service.create(img); | ||
} | ||
|
||
public static void configureImagePlus(ImagePlus imp, ImageDisplay imageDisplay) { | ||
|
||
imp.setC(imageDisplay.getIntPosition(Axes.CHANNEL)); | ||
imp.setZ(imageDisplay.getIntPosition(Axes.Z)); | ||
imp.setT(imageDisplay.getIntPosition(Axes.TIME)); | ||
|
||
} | ||
|
||
private Dataset emptyDataset(Dataset input, int sizeDims) { | ||
AxisType[] axisType = new AxisType[input.numDimensions()]; | ||
CalibratedAxis[] axeArray = new CalibratedAxis[input.numDimensions()]; | ||
input.axes(axeArray); | ||
|
||
long[] dims = new long[sizeDims]; | ||
for (int i = 0; i < sizeDims; i++) { | ||
axisType[i] = axeArray[i].type(); | ||
dims[i] = toIntExact(input.max(i) + 1); | ||
} | ||
return service.create(dims, input.getName(), axisType, input.getValidBits(), input.isSigned(), false); | ||
} | ||
|
||
private Dataset chooseDataset(Dataset dataset) { | ||
if (createCopy) { | ||
return dataset.duplicateBlank(); | ||
} | ||
return dataset; | ||
} | ||
|
||
public int getNumberOfSlices(Dataset dataset) { | ||
|
||
return (int) (dataset.getImgPlus().size() / (dataset.dimension(0) * dataset.dimension(1))); | ||
|
||
} | ||
|
||
public Dataset processDataset(Dataset dataset) { | ||
Dataset datasetToModify = chooseDataset(dataset); | ||
|
||
for (int i = 0; i < getNumberOfSlices(dataset); i++) { | ||
Dataset datasetOnePlane = emptyDataset(dataset, 2); | ||
datasetOnePlane.setPlane(0, dataset.getPlane(i)); | ||
ImagePlus result = processImagePlus(getInput(datasetOnePlane)); | ||
setOutput(result.duplicate(), datasetOnePlane); | ||
datasetToModify.setPlane(i, datasetOnePlane.getPlane(0)); | ||
} | ||
dataset = datasetToModify; | ||
return dataset; | ||
} | ||
// | ||
// /** | ||
// * Wrap the whole Dataset. Use more memory | ||
// * | ||
// * @param dataset | ||
// * @return | ||
// */ | ||
// public Dataset processDatasetWholeWrap(Dataset dataset) { | ||
// ImagePlus result = processImagePlus(getInput(dataset)); | ||
// ImagePlus resultCopy = result.duplicate(); | ||
// if (createCopy) { | ||
// dataset = emptyDataset(dataset, dataset.numDimensions()); | ||
// } | ||
// Dataset dataset2 = wrapDataset(resultCopy); | ||
// for (int i = 0; i < getNumberOfSlices(dataset); i++) { | ||
// dataset.setPlane(i, dataset2.getPlane(i)); | ||
// } | ||
// return dataset; | ||
// } | ||
|
||
public boolean isWholeWrap() { | ||
return wholeWrap; | ||
} | ||
|
||
public void setWholeWrap(boolean wholeWrap) { | ||
this.wholeWrap = wholeWrap; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/ijfx/plugins/DefaultImageJ1PluginAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
This file is part of ImageJ FX. | ||
ImageJ FX is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
ImageJ FX is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with ImageJ FX. If not, see <http://www.gnu.org/licenses/>. | ||
Copyright 2015,2016 Cyril MONGIS, Michael Knop | ||
*/ | ||
package ijfx.plugins; | ||
|
||
import ij.ImagePlus; | ||
import net.imagej.Dataset; | ||
import org.scijava.ItemIO; | ||
import org.scijava.command.Command; | ||
import org.scijava.plugin.Attr; | ||
import org.scijava.plugin.Parameter; | ||
import org.scijava.plugin.Plugin; | ||
/** | ||
* | ||
* @author Tuan anh TRINH | ||
*/ | ||
@Plugin(type = Command.class, menuPath = "Plugins>DefaultAdapter") | ||
public class DefaultImageJ1PluginAdapter extends AbstractImageJ1PluginAdapter { | ||
@Parameter(type = ItemIO.BOTH) | ||
protected Dataset dataset; | ||
@Override | ||
public ImagePlus processImagePlus(ImagePlus input) { | ||
return input; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
dataset = processDataset(dataset); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
This file is part of ImageJ FX. | ||
ImageJ FX is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
ImageJ FX is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with ImageJ FX. If not, see <http://www.gnu.org/licenses/>. | ||
Copyright 2015,2016 Cyril MONGIS, Michael Knop | ||
*/ | ||
package ijfx.plugins; | ||
|
||
import ij.ImagePlus; | ||
import java.io.File; | ||
import net.imagej.Dataset; | ||
import org.scijava.ItemIO; | ||
import org.scijava.command.Command; | ||
import org.scijava.plugin.Attr; | ||
import org.scijava.plugin.Parameter; | ||
import org.scijava.plugin.Plugin; | ||
/** | ||
* | ||
* @author Tuan anh TRINH | ||
*/ | ||
@Plugin(type = Command.class, menuPath = "Plugins>DefaultWholeAdapter") | ||
public class DefaultWholeWrapper extends AbstractImageJ1PluginAdapter { | ||
@Parameter(type = ItemIO.BOTH) | ||
protected Dataset dataset; | ||
@Parameter | ||
File f; | ||
@Override | ||
public ImagePlus processImagePlus(ImagePlus input) { | ||
return input; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
setWholeWrap(true); | ||
dataset = setOutput(getInput(dataset), dataset); | ||
} | ||
|
||
} |
Oops, something went wrong.