Login  Register

Re: IPDemo Plugin - calling 'IJ.run(..)' - Image is locked

Posted by Michael Schmid on Oct 09, 2008; 11:37am
URL: http://imagej.273.s1.nabble.com/IPDemo-Plugin-calling-IJ-run-Image-is-locked-tp3694825p3694828.html

Hi Ghislain,

what about File>Revert?
Or do you need something else?

Michael

   http://en.wikipedia.org/wiki/RTFM  :-)

________________________________________________________________

On 9 Oct 2008, at 13:23, Ghislain Bugnicourt wrote:

> 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
>>
>
> --
> View this message in context: http://n2.nabble.com/IPDemo-Plugin--- 
> calling-%27IJ.run%28..%29%27---Image-is-locked-tp1311333p1311733.html
> Sent from the ImageJ mailing list archive at Nabble.com.