/
Surface_Plot.java
54 lines (44 loc) · 1.21 KB
/
Surface_Plot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package examples;
import ij.IJ;
import ij.ImagePlus;
import ij.plugin.PlugIn;
import ij.process.StackConverter;
import ij3d.Content;
import ij3d.Image3DUniverse;
import surfaceplot.SurfacePlotGroup;
public class Surface_Plot implements PlugIn {
public static void main(String[] args) {
new ij.ImageJ();
IJ.runPlugIn("ij3d.examples.Surface_Plot", "");
}
@Override
public void run(String arg) {
// Open an image
String path = "/home/bene/PhD/brains/template.tif";
ImagePlus imp = IJ.openImage(path);
new StackConverter(imp).convertToGray8();
// Create a universe and show it
Image3DUniverse univ = new Image3DUniverse();
univ.show();
double a = -40 * Math.PI / 180;
univ.getViewPlatformTransformer().rotateY(-a);
univ.getViewPlatformTransformer().rotateX(a);
// Add the image as a volume
Content c = univ.addSurfacePlot(imp);
sleep(5);
// Retrieve the VoltexGroup
SurfacePlotGroup splot = (SurfacePlotGroup)c.getContent();
// Scroll through the slices
for(int i = 0; i < 15; i++) {
splot.setSlice(i + 1);
sleep(1);
}
}
private static void sleep(int sec) {
try {
Thread.sleep(sec * 1000);
} catch(InterruptedException e) {
System.out.println(e.getMessage());
}
}
}