I am having a problem reading out the number of slices in an AVI stack. The following python script in Fiji opens an AVI stack without problems, and allows me to change the slice. From the main menu I can run "Image>Show Info..." or "Image>Properties..." and both show the correct number of slices/depth in the file (183). However, everything I have tried to print out or read the number of slices has failed (like nSlice). I need the number to further process the images.
It doesn't help that i am new to using python, but I have been following Albert Cardona's excellent tutorial. from ij import IJ, ImagePlus from ij import ImageStack as IS import ij.io IJ.run("AVI...", "select=[C:\\Canon\\Projector Leader Tests 102111 .avi] use convert") n = IS.getSize() print n sl = IJ.setSlice(18) #this changes to slice 18 if previous two statments blocked out. The specific error I get with this code is: File "<iostream>", line 5, in <module> TypeError: getSize(): expected 1 args; got 0 |
On Jun 30, 2012, at 5:40 PM, Gary Dyrkacz wrote:
> I am having a problem reading out the number of slices in an AVI stack. In the ImageJ 1.47a daily build, you can use the AVI_Reader.openVirtual(path) method to open an AVI movie and get the number of frames. Here is a JavaScript example: imp = AVI_Reader.openVirtual(path); print("size="+imp.getStackSize()); imp.show(); In earlier versions of ImageJ, you can open a AVI as a virtual stack using reader = new AVI_Reader(); stack = reader.makeStack (path, 1, 0, true, false, false); print("size="+stack.getSize()); new ImagePlus("stack", stack).show(); > The > following python script in Fiji opens an AVI stack without problems, and > allows me to change the slice. Questions about Jython, or other Fiji-specific questions, should be directed to the Fiji-developers' mailing list. -wayne > From the main menu I can run "Image>Show > Info..." or "Image>Properties..." and both show the correct number of > slices/depth in the file (183). However, everything I have tried to print > out or read the number of slices has failed (like nSlice). I need the number > to further process the images. > It doesn't help that i am new to using python, but I have been following > Albert Cardona's excellent tutorial. > > from ij import IJ, ImagePlus > from ij import ImageStack as IS > import ij.io > IJ.run("AVI...", "select=[C:\\Canon\\Projector Leader Tests 102111 .avi] use > convert") > n = IS.getSize() > print n > sl = IJ.setSlice(18) #this changes to slice 18 if previous two statments > blocked out. > > The specific error I get with this code is: > File "<iostream>", line 5, in <module> > TypeError: getSize(): expected 1 args; got 0 > > -- > View this message in context: http://imagej.1557.n6.nabble.com/Problem-getting-number-of-slices-from-AVI-stack-tp4999263.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hello all,
I found something strange when I use the crop function in StackProcessor class. For example, for an image stack (let's name the variable "stack") with 160 slice, I do: StackProcessor stackProc = new StackProcessor(stack, ip); ImageStack roiLeftStack = stackProc.crop(xmin, ymin, width, height); ImageStack roiLeftStack = stackProc.crop(xmin + width, ymin, width, height); then there will be an error message: java.lang.IllegalArgumentException: Argument out of range: 1 at ij.ImageStack.getProcessor(ImageStack.java: 256) at ij.process.StackProcessor.crop(StackProcessor.java:129) It seems if we run once crop, the INITIAL stack will become a stack with only one slice!!!! Anybody know why this happens???? cheers, Xin -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Jul 2, 2012, at 3:16 AM, 周鑫 wrote:
> Hello all, > > I found something strange when I use the crop function in StackProcessor class. > > For example, for an image stack (let's name the variable "stack") with 160 slice, I do: > > StackProcessor stackProc = new StackProcessor(stack, ip); > ImageStack roiLeftStack = stackProc.crop(xmin, ymin, width, height); > ImageStack roiLeftStack = stackProc.crop(xmin + width, ymin, width, height); > > then there will be an error message: > java.lang.IllegalArgumentException: Argument out of range: 1 > at ij.ImageStack.getProcessor(ImageStack.java: 256) > at ij.process.StackProcessor.crop(StackProcessor.java:129) > > It seems if we run once crop, the INITIAL stack will become a stack with only one slice!!!! > > Anybody know why this happens???? To save memory, the StackProcessor deletes slices in the original stack as they are cropped. The Duplicator class does not do this. Here is a JavaScript example, created with the help of the command recorder: width = 250; height = 250; xmin = 0; ymin = 0; imp = IJ.createImage("Untitled", "8-bit Ramp", width*2, height*2, 10); imp.setRoi(xmin, ymin, width, height); imp2 = new Duplicator().run(imp); imp.setRoi(xmin + width, ymin, width, height); imp3 = new Duplicator().run(imp); imp.show(); imp2.show(); imp3.show(); To crop a stack, use IJ.run(imp,"Crop",""). Here is an example: imp = IJ.createImage("Untitled", "8-bit Ramp", 500, 500, 100); imp.setRoi(125, 125, 250, 250); IJ.run(imp, "Crop", ""); imp.show(); -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |