Re: IPDemo Plugin - calling 'IJ.run(..)' - Image is locked
Posted by
Ghislain Bugnicourt on
Oct 09, 2008; 11:23am
URL: http://imagej.273.s1.nabble.com/IPDemo-Plugin-calling-IJ-run-Image-is-locked-tp3694825p3694827.html
Hi, and thanks for your response Michael.
I should have understood that myself, anyway you made me save time...
I inserted "imp.unlock()" to be able to use IJ.run(..). It works.
Now, I am facing the other problem I mentioned in the first post : after a Thresholding and other actions, I would like to be able to reload the image completely, which is not the same as 'resetting' (that is to say just a 'undo').
I didn't find such a 'simple' function anywhere : should I write it myself ( for the moment I don't know how to do) ? For myself at least, it would be useful to have a 'reload current image without saving' tool in ImageJ's 'file' menu (just a suggestion :) ).
Ghislain Bugnicourt - PhD
Institut Néel - CNRS - France
Michael Schmid-3 wrote
Hi Ghislain,
In the IP_Demo.java PlugInFrame the image is locked before doing any
operation to make sure that there is no other operation running on
the image at the same time:
public void actionPerformed(ActionEvent e) {
...
if (!imp.lock()) //this locks the image
{previousID = 0; return;}
The corresponding imp.unlock(); command is near the end of
void runCommand(String command, ImagePlus imp, ImageProcessor ip)
Most of the IJ.run(...) commands lock the image themselves; the
ImageProcessor methods don't.
So you have an image that is already locked and then you use IJ.run.
That's why you get the error message.
You can either remove the lock and unlock commands from your
PluginFrame or avoid using IJ.run commands.
Two more remarks:
- If you write a PlugInFilter or ExtendedPlugInFilter (in contrast
to a PlugInFrame or PlugIn) the image will be locked by ImageJ before
running the (Extended)PlugInFilter.
- When using IJ.run, the version
run(ImagePlus imp, String command, String options)
is preferrable because it is always clear which Image to use. Thus it
won't cause problems due to multithreading (e.g. if the user clicks
on another image while the plugin is still working).
Michael