All,
My latest confusion is over how to get the ImagePlus object created by the ImageCalculator. That is, say I do something like that shown below, but want to change the title of the result, then I need to have the ImagePlus object created by iC.calculate(). How can I get it? ImageCalculator iC = new ImageCalculator(); iC.calculate("divide create 32-bit stack", imIn, imL5L5); David Webster |
David,
How about WindowManager.getCurrentImage()? Bob On Oct 10, 2009, at 1:19 PM, David William Webster wrote: > All, > > My latest confusion is over how to get the ImagePlus object created > by the > ImageCalculator. That is, say I do something like that shown below, > but > want to change the title of the result, then I need to have the > ImagePlus > object created by iC.calculate(). How can I get it? > > ImageCalculator iC = new ImageCalculator(); > iC.calculate("divide create 32-bit stack", imIn, imL5L5); > > David Webster Robert Dougherty, Ph.D. President, OptiNav, Inc. 4176 148th Ave. NE Redmond, WA 98052 Tel. (425)891-4883 FAX (425)467-1119 www.optinav.com [hidden email] |
On Saturday 10 October 2009 21:33:38 Robert Dougherty wrote:
> How about WindowManager.getCurrentImage()? The following is not clear to me: in a macro, the result of the calculator is the currently selected image. Yet this is not thread-safe (is this the right name?) because one could click another image while the macro runs and that image becomes the current one, rather than the result image. Is this also a problem when writing a plugin and using the above? If so, then one can use the fact that the calculator returns an image called "Result of "+<image name> to make sure one is using the right image. Cheers, G. |
Gabriel,
This is why the instructions for my plugins sometime include "please refrain from clicking on anything until it is finished." I like your "Result of" suggestion. What happens if that name is not unique? Bob On Oct 10, 2009, at 2:15 PM, Gabriel Landini wrote: > On Saturday 10 October 2009 21:33:38 Robert Dougherty wrote: >> How about WindowManager.getCurrentImage()? > > The following is not clear to me: in a macro, the result of the > calculator is > the currently selected image. Yet this is not thread-safe (is this > the right > name?) because one could click another image while the macro runs > and that > image becomes the current one, rather than the result image. > > Is this also a problem when writing a plugin and using the above? > > If so, then one can use the fact that the calculator returns an > image called > "Result of "+<image name> to make sure one is using the right image. > > Cheers, > G. |
On Saturday 10 October 2009 22:30:11 Robert Dougherty wrote:
> This is why the instructions for my plugins sometime include "please > refrain from clicking on anything until it is finished." I like your > "Result of" suggestion. What happens if that name is not unique? Hi Bob, Right, so this is a problem in plugins too... If images are duplicated they have a "-1", "-2", but one can indeed create an image with the same name of an existing one by repeatedly applying the same calculation operation. I noted that a <2>, <3> is shown in the title bar if one renames an image with an already existing name, yet the window list makes no differences and so it is impossible to know which one is which within a macro or plugin. newImage("a", "8-bit Black", 128, 128, 1); newImage("b", "8-bit Black", 128, 128, 1); imageCalculator("Add create", "a","b"); imageCalculator("Add create", "a","b"); So I do not know how to resolve it in this case. ImageID is different for each image, but lots of commands (including the ImageCalculator) do not accept IDs, only names. This is a bit like the Monty Python sketch where everybody is called Bruce. :-) Cheers Gabriel |
In reply to this post by David Webster
On Oct 10, 2009, at 4:19 PM, David William Webster wrote:
> All, > > My latest confusion is over how to get the ImagePlus object created > by the ImageCalculator. That is, say I do something like that shown > below, but I want to change the title of the result, then I need to > have > the ImagePlus object created by iC.calculate(). How can I get it? > > ImageCalculator iC = new ImageCalculator(); > iC.calculate("divide create 32-bit stack", imIn, imL5L5); Upgrade to the v1.43i daily build and use ImageCalculator iC = new ImageCalculator(); ImagePlus result = iC.run("divide create 32-bit stack", imIn, imL5L5); -wayne |
I tried this and it works fine. I assume though that the run() method is no
longer void. Is this option going to mbe extended to other classes? David Webster On Sat, Oct 10, 2009 at 5:55 PM, Wayne Rasband <[hidden email]> wrote: > On Oct 10, 2009, at 4:19 PM, David William Webster wrote: > > All, >> >> My latest confusion is over how to get the ImagePlus object created >> by the ImageCalculator. That is, say I do something like that shown >> below, but I want to change the title of the result, then I need to have >> the ImagePlus object created by iC.calculate(). How can I get it? >> >> ImageCalculator iC = new ImageCalculator(); >> iC.calculate("divide create 32-bit stack", imIn, imL5L5); >> > > Upgrade to the v1.43i daily build and use > > ImageCalculator iC = new ImageCalculator(); > ImagePlus result = iC.run("divide create 32-bit stack", imIn, imL5L5); > > -wayne > |
On Oct 10, 2009, at 10:17 PM, David Webster wrote:
> I tried this and it works fine. I assume though that the run() > method is no > longer void. Is this option going to mbe extended to other classes? The two run() methods are different because they have different argument signatures. The new method is (String, ImagePlus, ImagePlus) and the one required by the PlugIn interface is (String). I plan to add similar thread-safe calling methods to other internal plugins as needed. I also plan to add a "Record JavaScript" option to the recorder that will record these methods so they can be discovered without searching the ImageJ API or source code. For example, the "Duplicate..." command will record something like: IJ.run("Duplicate...", "title=blobs-1.gif"); // img2 = new Duplicator().duplicate(img1); -wayne > On Sat, Oct 10, 2009 at 5:55 PM, Wayne Rasband <[hidden email]> wrote: > >> On Oct 10, 2009, at 4:19 PM, David William Webster wrote: >> >> All, >>> >>> My latest confusion is over how to get the ImagePlus object created >>> by the ImageCalculator. That is, say I do something like that shown >>> below, but I want to change the title of the result, then I need >>> to have >>> the ImagePlus object created by iC.calculate(). How can I get it? >>> >>> ImageCalculator iC = new IrmageCalculato(); >>> iC.calculate("divide create 32-bit stack", imIn, imL5L5); >>> >> >> Upgrade to the v1.43i daily build and use >> >> ImageCalculator iC = new ImageCalculator(); >> ImagePlus result = iC.run("divide create 32-bit stack", imIn, >> imL5L5); >> >> -wayne >> |
On Oct 11, 2009, at 11:21 AM, Wayne Rasband wrote:
> On Oct 10, 2009, at 10:17 PM, David Webster wrote: > >> I tried this and it works fine. I assume though that the run() >> method is no >> longer void. Is this option going to mbe extended to other classes? > > The two run() methods are different because they have different > argument signatures. The new method is (String, ImagePlus, > ImagePlus) and the one required by the PlugIn interface is (String). > I plan to add similar thread-safe calling methods to other internal > plugins as needed. I also plan to add a "Record JavaScript" option > to the recorder that will record these methods so they can be > discovered without searching the ImageJ API or source code. For > example, the "Duplicate..." command will record something like: > > IJ.run("Duplicate...", "title=blobs-1.gif"); > // img2 = new Duplicator().duplicate(img1); > Hi Wayne, This is why you deserve and have the respect, admiration and gratitude of all of us. Thank you! Ben > -wayne > >> On Sat, Oct 10, 2009 at 5:55 PM, Wayne Rasband <[hidden email]> wrote: >> >>> On Oct 10, 2009, at 4:19 PM, David William Webster wrote: >>> >>> All, >>>> >>>> My latest confusion is over how to get the ImagePlus object created >>>> by the ImageCalculator. That is, say I do something like that shown >>>> below, but I want to change the title of the result, then I need >>>> to have >>>> the ImagePlus object created by iC.calculate(). How can I get it? >>>> >>>> ImageCalculator iC = new IrmageCalculato(); >>>> iC.calculate("divide create 32-bit stack", imIn, imL5L5); >>>> >>> >>> Upgrade to the v1.43i daily build and use >>> >>> ImageCalculator iC = new ImageCalculator(); >>> ImagePlus result = iC.run("divide create 32-bit stack", imIn, >>> imL5L5); >>> >>> -wayne >>> Cheers, Ben |
Free forum by Nabble | Edit this page |