Posted by
Lars Damgaard on
Jun 16, 2014; 6:55am
URL: http://imagej.273.s1.nabble.com/cannot-save-Image-sequence-of-one-tp5008195p5008228.html
Hi Michael,
The problem for me with the workaround you suggest is that ImageJ does not automatically give me the desired filename to save in. In contrast to run("Image Sequence... ", ... ), which allows you to retain the original filename, Savs As() on a sequence suggests name of the source folder by default, and I have not found a way to tease out the name of the (single) sequence member - is there such a way?
Best Lars
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Michael Schmid
Sent: 13. juni 2014 18:47
To:
[hidden email]
Subject: Re: cannot save Image sequence of one
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--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html