cannot save Image sequence of one

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

cannot save Image sequence of one

Lars Damgaard
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
Reply | Threaded
Open this post in threaded view
|

Re: cannot save Image sequence of one

Michael Schmid
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
Reply | Threaded
Open this post in threaded view
|

Re: cannot save Image sequence of one

Lars Damgaard
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
Reply | Threaded
Open this post in threaded view
|

Re: cannot save Image sequence of one

Lars Damgaard
In reply to this post by Lars Damgaard
Thanks to Wayne, the Sequence Save now handles one-member sequences.
Lars

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: cannot save Image sequence of one

Lars Damgaard
In reply to this post by Lars Damgaard
I am very confused: Wayne fixed it so that I could save single-member sequences with the the
run("Image Sequence... ", ... save=...) command, and I tested it to work.
But now it doesn't work AGAIN, stating "This command requires a stack"... I don't think I updated in the meantime (but now I have). Any suggestions?

Lars

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: cannot save Image sequence of one

ctrueden
Hi Lars,

> Wayne fixed it so that I could save single-member sequences with the
> the run("Image Sequence... ", ... save=...) command, and I tested it
> to work. But now it doesn't work AGAIN, stating "This command requires
> a stack"...

ImageJ now allows single-plane images to work with the File>Save As>Image
Sequence... command _only_ when running as a macro:


https://github.com/imagej/imagej1/commit/07ffb01eadeb037b3e73cf4532664b773b1ba86c#diff-9096fd4f8afcbbab38246fb6d4f18d8eL31

Wayne did this as part of the 1.49c12 daily build, so you'll need to use
Help > Update ImageJ and select "Daily build" from the menu to receive that
version. The ImageJ Updater only ships final letter versions -- i.e., when
Wayne uploads 1.49c, it will automatically become available from the Help >
Update command.

Regards,
Curtis


On Thu, Jun 19, 2014 at 4:21 AM, Lars Damgaard <[hidden email]> wrote:

> I am very confused: Wayne fixed it so that I could save single-member
> sequences with the the
> run("Image Sequence... ", ... save=...) command, and I tested it to work.
> But now it doesn't work AGAIN, stating "This command requires a stack"...
> I don't think I updated in the meantime (but now I have). Any suggestions?
>
> Lars
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html