diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3d47f986c41db29ec6dc0d5036bf760b3a1cf366 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.idea/ +target/ +.settings/ +*.iml +.project +.classpath \ No newline at end of file diff --git a/StackRotation.jar b/StackRotation.jar new file mode 100644 index 0000000000000000000000000000000000000000..a18d426e7d854c66773851fa79c5c553782d1ead Binary files /dev/null and b/StackRotation.jar differ diff --git a/export.jardesc b/export.jardesc new file mode 100644 index 0000000000000000000000000000000000000000..7f140a23fb28e5f402edc80ac0380620c06e9cd3 --- /dev/null +++ b/export.jardesc @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?> +<jardesc> + <jar path="Stack Rotation/StackRotation.jar"/> + <options buildIfNeeded="true" compress="true" descriptionLocation="/Stack Rotation/export.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="true" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/> + <storedRefactorings deprecationInfo="true" structuralOnly="false"/> + <selectedProjects/> + <manifest generateManifest="true" manifestLocation="/Icy-Updater/META-INF/MANIFEST.MF" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true"> + <sealing sealJar="false"> + <packagesToSeal/> + <packagesToUnSeal/> + </sealing> + </manifest> + <selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false"> + <javaElement handleIdentifier="=Stack Rotation/src"/> + </selectedElements> +</jardesc> diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f96c1eccb92e0022eaffc4c304264442d750334 --- /dev/null +++ b/pom.xml @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <!-- Inherited Icy Parent POM --> + <parent> + <groupId>org.bioimageanalysis.icy</groupId> + <artifactId>parent-pom-plugin</artifactId> + <version>1.0.3</version> + </parent> + + <!-- Project Information --> + <artifactId>stack-rotation</artifactId> + <version>1.2.1</version> + + <packaging>jar</packaging> + + <name>Stack Rotation</name> + <description>Rotate the 3D stack from Front view to Right view or from Front view to Top view. </description> + <url></url> + <inceptionYear>2020</inceptionYear> + + <organization> + <name>Institut Pasteur</name> + <url>https://pasteur.fr</url> + </organization> + + <licenses> + <license> + <name>GNU GPLv3</name> + <url>https://www.gnu.org/licenses/gpl-3.0.en.html</url> + <distribution>repo</distribution> + </license> + </licenses> + + <developers> + <developer> + <id>sdallongeville</id> + <name>Stéphane Dallongeville</name> + <url>https://research.pasteur.fr/fr/member/stephane-dallongeville/</url> + <roles> + <role>founder</role> + <role>lead</role> + <role>architect</role> + <role>developer</role> + <role>debugger</role> + <role>tester</role> + <role>maintainer</role> + <role>support</role> + </roles> + </developer> + </developers> + + <!-- Project properties --> + <properties> + + </properties> + + <!-- Project build configuration --> + <build> + + </build> + + <!-- List of project's dependencies --> + <dependencies> + <!-- The core of Icy --> + <dependency> + <groupId>org.bioimageanalysis.icy</groupId> + <artifactId>icy-kernel</artifactId> + </dependency> + + <!-- The EzPlug library, simplifies writing UI for Icy plugins. --> + <dependency> + <groupId>org.bioimageanalysis.icy</groupId> + <artifactId>ezplug</artifactId> + </dependency> + </dependencies> + + <!-- Icy Maven repository (to find parent POM) --> + <repositories> + <repository> + <id>icy</id> + <name>Icy's Nexus</name> + <url>https://icy-nexus.pasteur.fr/repository/Icy/</url> + </repository> + </repositories> +</project> \ No newline at end of file diff --git a/src/main/java/plugins/spop/rotation3D/StackRotation.class b/src/main/java/plugins/spop/rotation3D/StackRotation.class new file mode 100644 index 0000000000000000000000000000000000000000..68074344ee33ae06c785a18f06198858479a547b Binary files /dev/null and b/src/main/java/plugins/spop/rotation3D/StackRotation.class differ diff --git a/src/main/java/plugins/spop/rotation3D/StackRotation.java b/src/main/java/plugins/spop/rotation3D/StackRotation.java new file mode 100644 index 0000000000000000000000000000000000000000..95aa8064365f2fa21d3ccddc415653465b824ab8 --- /dev/null +++ b/src/main/java/plugins/spop/rotation3D/StackRotation.java @@ -0,0 +1,168 @@ +package plugins.spop.rotation3D; + +import icy.image.IcyBufferedImage; +import icy.sequence.Sequence; +import icy.type.collection.array.Array1DUtil; +import icy.util.OMEUtil; +import plugins.adufour.blocks.lang.Block; +import plugins.adufour.blocks.util.VarList; +import plugins.adufour.ezplug.EzPlug; +import plugins.adufour.ezplug.EzVarSequence; +import plugins.adufour.ezplug.EzVarText; + +public class StackRotation extends EzPlug implements Block +{ + + EzVarSequence input = new EzVarSequence("Input"); + EzVarText type = new EzVarText("Type", new String[] { "FrontToRight", "FrontToTop" }, false); + // VarSequence output = new VarSequence("Output", false); + + EzVarSequence output = new EzVarSequence("Output"); + + @Override + public void initialize() + { + // TODO Auto-generated method stub + super.addEzComponent(input); + super.addEzComponent(type); + // super.addOutput(output); + super.setTimeDisplay(true); + + } + + @Override + public void execute() + { + + Sequence sequence = input.getValue(true); + Sequence seq_out = new Sequence(OMEUtil.createOMEXMLMetadata(sequence.getOMEXMLMetadata())); + if (type.getValue().equalsIgnoreCase("FrontToRight")) + { + seq_out = FrontToRight(sequence); + seq_out.setName("FrontToRight"); + } + if (type.getValue().equalsIgnoreCase("FrontToTop")) + { + seq_out = FrontToTop(sequence); + seq_out.setName("FrontToTop"); + + } + + if (getUI() != null) addSequence(seq_out); + output.setValue(seq_out); + + } + + public static Sequence FrontToRight(Sequence sequence) + { + + int z = 0; + + Sequence seq = new Sequence(); + + int dim_x = sequence.getSizeX(); + int dim_y = sequence.getSizeY(); + int dim_z = sequence.getSizeZ(); + int dim_t = sequence.getSizeT(); + int dim_c = sequence.getSizeC(); + double[][] tab = new double[dim_z][dim_x * dim_y]; + double[][][] tab_r = new double[dim_c][dim_x][dim_y * dim_z]; + + for (int t = 0; t < dim_t; t++) + { + for (int c = 0; c < dim_c; c++) + { + for (z = 0; z < dim_z; z++) + { + tab[z] = Array1DUtil.arrayToDoubleArray(sequence.getDataXY(t, z, c), false); + } + for (z = 0; z < dim_z; z++) + for (int y = 0; y < dim_y; y++) + for (int x = 0; x < dim_x; x++) + { + tab_r[c][x][y * dim_z + z] = tab[z][y * dim_x + x]; + } + } + + for (z = 0; z < dim_x; z++) + { + IcyBufferedImage Icy = new IcyBufferedImage(dim_z, dim_y, dim_c, sequence.getDataType()); + for (int c = 0; c < dim_c; c++) + Icy.setDataXY(c, tab_r[c][z]); + seq.setImage(t, z, Icy); + } + } + + System.gc(); + return seq; + + } + + public static Sequence FrontToTop(Sequence sequence) + { + + int z = 0; + + Sequence seq = new Sequence(); + + int dim_x = sequence.getSizeX(); + int dim_y = sequence.getSizeY(); + int dim_z = sequence.getSizeZ(); + int dim_t = sequence.getSizeT(); + int dim_c = sequence.getSizeC(); + double[][] tab = new double[dim_z][dim_x * dim_y]; + double[][][] tab_r = new double[dim_c][dim_y][dim_x * dim_z]; + + for (int t = 0; t < dim_t; t++) + { + for (int c = 0; c < dim_c; c++) + { + for (z = 0; z < dim_z; z++) + { + tab[z] = Array1DUtil.arrayToDoubleArray(sequence.getDataXY(t, z, c), false); + } + for (z = 0; z < dim_z; z++) + for (int y = 0; y < dim_y; y++) + for (int x = 0; x < dim_x; x++) + { + tab_r[c][y][z * dim_x + x] = tab[z][y * dim_x + x]; + } + } + + for (z = 0; z < dim_y; z++) + { + IcyBufferedImage Icy = new IcyBufferedImage(dim_x, dim_z, dim_c, sequence.getDataType()); + for (int c = 0; c < dim_c; c++) + Icy.setDataXY(c, tab_r[c][z]); + seq.setImage(t, z, Icy); + } + } + + System.gc(); + + return seq; + + } + + public void clean() + { + } + + @Override + public void declareInput(VarList inputMap) + { + // TODO Auto-generated method stub + inputMap.add(input.getVariable()); + inputMap.add(type.getVariable()); + + } + + @Override + public void declareOutput(VarList outputMap) + { + // TODO Auto-generated method stub + outputMap.add(output.getVariable()); + + } + +}