I have been working on a project in which I am trying to rotate images by ImageJ macros, basically the related part looks like:
IJ.run(sourceImage, "Arbitrarily...", "angle=" + angle + " grid=1 interpolate enlarge");
So when I make, lets say 5 calls with angles 20, 30, 40, 50, 60 to the method which runs the one above, the amount of time to execute this is growing bigger (both for threaded and single thread applications) So approximately the processing durations are:
===========================
290 - 1. execution
656 - 2. execution
649 - 3. execution
1353 - 4. execution
6931 - 5. execution
===========================
so, why macro calls on ImageJ slows down when there are continuous calls to a specific macro?
I don't see where you're using the ImageJ macro language here. The code you show is Javascript or Java, and the command you're calling is running a Java plugin, not a macro.
With each call of IJ.run(sourceImage, "Arbitrarily...", ...)
, you are enlarging your sourceImage
, so with each following call you have to deal with more pixels.
Try leaving out the enlarge
parameter from your function call and see if the slowdown remains.
If you want to start from the original image each time you are rotating, duplicate your sourceImage
using imp = new Duplicator().run(imp);
before rotating.
By the way, the command "Arbitrarily..." is still available for compatibility reasons, but has been replaced a while ago by "Rotate... ", which you'd also get via the ImageJ menu when recording commands using Plugins > Macros > Record... and switching to Record: Javascript or Java.