Posted by
Michael Schmid on
Jun 13, 2014; 4:46pm
URL: http://imagej.273.s1.nabble.com/cannot-save-Image-sequence-of-one-tp5008195p5008204.html
Hi Lars,
if you have single images or Image Sequences to save, why not have a simple 'if' statement in the macro? Roughly like the following:
path = "C:\\Users\\lrd\\"
if (nSlices>1)
run("Image Sequence... ", ... , save="["+ path +"]");
else
saveAs("tiff", path+getTitle());
Michael
________________________________________________________________
On Jun 13, 2014, at 14:04, Lars Damgaard wrote:
> Hi,
>
> I have a large number of sequential images (e.g. C:\Users\lrd\Imaget01z01.jpg, C:\Users\lrd\Imaget01z02.jpg ...) that I want to crop. Some image subsequences should have one cropping area, others another. I try to implement this via a macro, where I repeatedly
> - read an input text file with lines of manually determined start and end picture number along with crop coordinates
> - in subloop do
> - load a fixed number subset of the pictures corresponding to a line via run("Image Sequence...", open=C:\\Users\\lrd\...
> - set the cropping coordinates with run("Specify...", command
> - crop with the run("Crop");
> - save the cropped images in a separate folder using the run("Image Sequence... ", ... , save=C:\\Users\\lrd\... command
> - close the files with the Close() command.
>
> This works OK, EXCEPT when an input line describes only a single image, i.e. this image has different cropping settings from its neighbors. I can still open this single image using the run("Image Sequence...", "open=C:\\Users\\lrd\... function by setting Number of Images to 1, but when I get to saving it, the macro halts with "This command requires a stack". Is it correct that this is how it works?
>
> * If so, I would like to suggest that in a future version it is allowed to do Save As/Image sequence with only one member.
>
> I can make a relatively ugly workarounds, the one I favor right now is to open an extra image, which will then be overwritten. I could also have a test of the number to select SaveAs... instead, which will allow saving the single-member sequence, but this leads to another question: If you use SaveAs on a single-member sequence, the suggested filename in the dialog is the original folder name (e.g. "lrd.jpg") and not the name of the particular image (e.g. Imaget01z01.jpg). Is there a way to get hold of that particular name? I can see it in the graphics window...
>
> * if not, I would like to suggest that the Save As command used on a single-member Image Sequence suggests the filename, not the folder name.
>
> Best, Lars
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html