Posted by
Michael Schmid on
URL: http://imagej.273.s1.nabble.com/activeImage-how-to-set-it-tp3701057p5002649.html
Hi SombreroDuck,
maybe you have solved it already (I've been out of town for a week), but anyhow:
WindowManager.getCurrentImage() points to the image shown as active (having a hook) in the 'Window' menu of ImageJ. BatchMode macros are the only exception.
You need to determine the current image before running the first FFT.
ImagePlus imp = WindowManager.getCurrentImage();
Then run the FFT, filter it (or modify it however you like), and do the back transform.
If imp points to the wrong image (the FFT), it's a bug (race condition) in ImageJ: You should be able to fix it by inserting some delay, e.g. 100 milliseconds,
IJ.wait(100);
before running the FFT. If there *is* a race condition, please post your code (ideally, stripped down to the essence) to let us examine the problem.
--
By the way, if you have a plugin, for some operations you don't need to display the FFT:
You can get the ImageProcessor of the current image and get the FHT from it, see the ij.process.FHT class. Then work on the resulting FloatProcessor, use the FHT's inverse transform and crop it to the original size.
Michael
________________________________________________________________
On Apr 7, 2013, at 15:48, sombreroduck wrote:
> Hi Michael,
> Thanks for the help!. In fact, I had tried the commands you suggested (with
> "WindowManager" in front since it's a plugin, not a macro) but it was
> either throwing errors, ignoring the command, or picking the FFT image
> instead. This latter happened now when I tried again, but I found that if I
> closed the FFT window first it would work. Do you know why it was always
> picking the title, id or imp of the FFT (middle image) and not the
> InverseFFT? (front image)
> Thanks again!
>
>
> On 5 April 2013 18:03, Michael Schmid-3 [via ImageJ] <
>
[hidden email]> wrote:
>
>> Hi Sombreroduck,
>>
>> assuming you are writing a macro (your commands don't look like java code
>> of a plugin):
>>
>> Before using selectImage(id) or selectImage(title), you have to define the
>> variable 'id' (or 'title') while the image is still in the foreground:
>> id = getImageID();
>> or
>> title = getTitle();
>>
>>
>> When really writing a plugin, however, use
>> ImagePlus imp = WindowManager.getCurrentImage();
>> Later on, you can use
>> WindowManager.setTempCurrentImage(imp);
>>
>>
>> Michael
>> _________________________________________________________________
>>
>>
>> On Fri, April 5, 2013 17:10, sombreroduck wrote:
>>
>>> Hi,
>>> I'm writing a plugin which runs an FFT and then an Inverse FFT on (part
>>> of)
>>> an image. I then want to overlay this new inverse back onto the original
>>> image, and had thought to do this with IJ.run("Add Image...", "etc...);
>>> but
>>> to do this the original image would have to be active.
>>>
>>> I've tried selectImage(id) and selectImage(title) but it just throws
>>> errors
>>> "cannot find symbol". Does anyone know how I can convince it to make the
>>> original image active again?
>>>
>>> (alternatively if you know another way to pop the inverse FFT back onto
>>> the
>>> original img?)
>>>
>>>
>>> Cheers!
>>> R
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>
>>
http://imagej.1557.n6.nabble.com/activeImage-how-to-set-it-tp3701057p5002556.html>>> Sent from the ImageJ mailing list archive at Nabble.com.
>>>
>>> --
>>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>>>
>>
>> --
>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>>
http://imagej.1557.n6.nabble.com/activeImage-how-to-set-it-tp3701057p5002560.html>> To unsubscribe from activeImage- how to set it?, click here<
>> .
>> NAML<http://imagej.1557.n6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context:
http://imagej.1557.n6.nabble.com/activeImage-how-to-set-it-tp3701057p5002572.html> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html