Exporting image stack to obj via script
Posted by Simon W on Jan 14, 2015; 6:45pm
URL: http://imagej.273.s1.nabble.com/Exporting-image-stack-to-obj-via-script-tp5011216.html
I'm using Fiji to process some image stacks that I need to export to OBJ format. I have over 2000 stacks and need to script this.
The image stacks are all stored in the following directory format
slices/specimen_number/16 bit/specimen_number00000x.tif
where specimen_number varies and there will be multiple .tif files in the directory numbered from 0000 to n.
I want to be able to choose the slices directory, read the images in turn in each directory as a stack and then convert each stack to an obj file and write it out in the corresponding directory.
I ran each step on a single directory and recorded as a macro which i then attempted to automate.
The script so far is below. The commented lines at the bottom of the script are what the macro recorder saved.
I'm also trying to save the image stack.
The script obviously doesn't work as 1. It doesn't write out the stack 2. The 3D viewer opens but doesn't read in the file
I havent tried to finish off the rest of it i.e. the export as until I can get the rest to work.
As you've probably gathered I'm not a programmer and I'm sure there's a much easier way of doing this!
Any help gratefully received.
Simon
dir = getDirectory("Choose a Directory");
list = getFileList(dir);
print(list.length, 'files in this folder');
setBatchMode(true);
for (i=0; i<list.length; i++) {
inputPath = dir+list[i];
outputFile = inputPath+"Processed";
run("Image Sequence...", "open=[*.tif] sort");
run("8-bit");
saveAs("Tiff", inputPath+"Processed");
run("3D Viewer");
call("ij3d.ImageJ3DViewer.setCoordinateSystem", "false");
call("ij3d.ImageJ3DViewer.add", outputfile, "None", "16 bit", "150", "true", "true", "true", "2", "2");
}
//run("Image Sequence...", "open=[G:\\SW_Teethstack [2014-12-03 10.42.23]\\slices\\JR3\\16 bit\\JR30000000.tif] sort");
//run("8-bit");
//run("3D Viewer");
//call("ij3d.ImageJ3DViewer.setCoordinateSystem", "false");
//call("ij3d.ImageJ3DViewer.add", "16 bit", "None", "16 bit", "150", "true", "true", "true", "2", "2");
//call("ij3d.ImageJ3DViewer.select", "16 bit");
//call("ij3d.ImageJ3DViewer.select", "16 bit");
//call("ij3d.ImageJ3DViewer.select", "16 bit");
//call("ij3d.ImageJ3DViewer.exportContent", "WaveFront", "G:\SW_Teethstack [2014-12-03 10.42.23]\slices\JR3\16 bit\mesh.obj");