Login  Register

activeImage- how to set it?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

activeImage- how to set it?

jarek-6
9 posts
hello
i write a macro. i work with image which is duplicated lets say 3 times,
each of results called : "original", "normalized", "median", treshold".
in procedure i designed to apply normalization to "normalized", median
to "median" and treshold to "treshold" but in a sequencei can't set an
active image proper for planned operation.

i tried with getImageID() and isActive(id) but it does't work...all
operations are applied to "treshold image. below example of sequence.
any help is very welcome!
thanks.

jarek

the procedure:

run("Duplicate...", "title=nor");
getImageID();
run("Duplicate...", "title=med");
getImageID();
run("Duplicate...", "title=tresz");
getImageID();
isActive(-42);
run("Enhance Contrast", "saturated=0.5 normalize");
isActive(-43);
run("Median...", "radius=5");
isActive(-44);
run("Convert to Mask");
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: activeImage- how to set it?

Gabriel Landini
1783 posts
From http://rsbweb.nih.gov/ij/developer/macro/functions.html

selectImage(id)
 Activates the image with the specified ID (a negative number). If id is
greater than zero, activates the idth image listed in the Window menu. With
ImageJ 1.33n and later, id can be an image title (a string).

selectWindow("name")
 Activates the image window with the title "name". Also activates non-image
windows in v1.30n or later.


G.


On Thursday 09 November 2006 11:58, jarek wrote:

> hello
> i write a macro. i work with image which is duplicated lets say 3 times,
> each of results called : "original", "normalized", "median", treshold".
> in procedure i designed to apply normalization to "normalized", median
> to "median" and treshold to "treshold" but in a sequencei can't set an
> active image proper for planned operation.
>
> i tried with getImageID() and isActive(id) but it does't work...all
> operations are applied to "treshold image. below example of sequence.
> any help is very welcome!
> thanks.
>
> jarek
>
> the procedure:
>
> run("Duplicate...", "title=nor");
> getImageID();
> run("Duplicate...", "title=med");
> getImageID();
> run("Duplicate...", "title=tresz");
> getImageID();
> isActive(-42);
> run("Enhance Contrast", "saturated=0.5 normalize");
> isActive(-43);
> run("Median...", "radius=5");
> isActive(-44);
> run("Convert to Mask");
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: activeImage- how to set it?

jarek-6
9 posts
Gabriel Landini napisał(a):

> >From http://rsbweb.nih.gov/ij/developer/macro/functions.html
>
> selectImage(id)
>  Activates the image with the specified ID (a negative number). If id is
> greater than zero, activates the idth image listed in the Window menu. With
> ImageJ 1.33n and later, id can be an image title (a string).
>
> selectWindow("name")
>  Activates the image window with the title "name". Also activates non-image
> windows in v1.30n or later.
>
>
> G.
>
>
> On Thursday 09 November 2006 11:58, jarek wrote:
>  
>> hello
>> i write a macro. i work with image which is duplicated lets say 3 times,
>> each of results called : "original", "normalized", "median", treshold".
>> in procedure i designed to apply normalization to "normalized", median
>> to "median" and treshold to "treshold" but in a sequencei can't set an
>> active image proper for planned operation.
>>
>> i tried with getImageID() and isActive(id) but it does't work...all
>> operations are applied to "treshold image. below example of sequence.
>> any help is very welcome!
>> thanks.
>>
>> jarek
>>
>> the procedure:
>>
>> run("Duplicate...", "title=nor");
>> getImageID();
>> run("Duplicate...", "title=med");
>> getImageID();
>> run("Duplicate...", "title=tresz");
>> getImageID();
>> isActive(-42);
>> run("Enhance Contrast", "saturated=0.5 normalize");
>> isActive(-43);
>> run("Median...", "radius=5");
>> isActive(-44);
>> run("Convert to Mask");
>>    
>
>
>
>  
thanks Gabriel,

it works fine
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

how active a different img

sombreroduck
13 posts
In reply to this post by Gabriel Landini
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
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how active a different img

Michael Schmid
2136 posts
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
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how active a different img

sombreroduck
13 posts
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

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how active a different img

Michael Schmid
2136 posts
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
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how active a different img

sombreroduck
13 posts
Hi Michael,
Sorry I've been even slower in replying, I've also been away, twice...and it's all been a bit crazy. Somewhere in-between though, as you guessed, I did indeed manage to get a couple of versions of the plugin working. I think the relevant bit is this (comments below the lines for readability)

                    doFFT(impFFT, fftroi, noise, countx+antal*county, ResultsTable.getResultsTable());  
// This is a method that will do an FFT and find the maxima

                    impInvFFT=doInvFFT(impFFT, ResultsTable.getResultsTable().getCounter()-1, countx+antal*county); 
// This method will perform an inverse FFT, close the FFT window, and return the imp for the inverse FFT

                    WindowManager.setTempCurrentImage(imp);        
// This, I thought, was what would set the original image as the active window    

                    IJ.run("Add Image...", "x="+roix+" y="+roiy+" opacity=100");  
//overlays the invFFT onto the orig image

                    impInvFFT.changes=false;                             
                    impInvFFT.close();
// closes the invFFT

                   impFFT.close();   
//tries to close the FFT again, just in case (I don't trust my code to do it the first time....)


Do you mean that I should use WindowManager.setTempCurrentImage(imp)   BEFORE  I do any FFT and invFFT?

I've attached the whole .java file, but I'm afraid it's a bit messy. Iit's all been written in a bit of a rush, plus, if you've not already guessed, I'm not a programmer of any kind (and don't know what a race-condition or FloatProcessor is), I normally just live in the lab with my polymers and surfaces...

Thank you for your help!
R





On 15 April 2013 16:20, Michael Schmid-3 [via ImageJ] <[hidden email]> wrote:
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. > 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.x6.nabble.com/activeImage-how-to-set-it-tp3701057p5002649.html
To unsubscribe from activeImage- how to set it?, click here.
NAML


autoSplitSelect_DeFFT.java (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how active a different img

Michael Schmid
2136 posts
Hi R,

sorry, I don't understand what your code should do and also your description does not help.

Your code is not documented and the names are very misleading - e.g. "public void doFFT" does not do any FFT but rather finds the maxima in a Roi. No way to understand code like this.

"Draw" is not an operation that is typically used to filter an FFT. One would use "Fill", or even better, either
run("Set...", "value=0"); for filtering (removing), *or*
run("Set...", "value=255"); for passing (removing everything else).
  You can't have 0 (black) and 255 (white) values at the same time.

Michael
________________________________________________________________
On Apr 27, 2013, at 10:00, sombreroduck wrote:

> Hi Michael,
> Sorry I've been even slower in replying, I've also been away, twice...and
> it's all been a bit crazy. Somewhere in-between though, as you guessed, I
> did indeed manage to get a couple of versions of the plugin working. I
> think the relevant bit is this (comments below the lines for readability)
>
>                    doFFT(impFFT, fftroi, noise, countx+antal*county, ResultsTable.getResultsTable());
> // This is a method that will do an FFT and find the maxima
>
>                    impInvFFT=doInvFFT(impFFT, ResultsTable.getResultsTable().getCounter()-1, countx+antal*county);
> // This method will perform an inverse FFT, close the FFT window, and
> return the imp for the inverse FFT
>
>                    WindowManager.setTempCurrentImage(imp);
> // This, I thought, was what would set the original image as the active
> window
>
>                    IJ.run("Add Image...", "x="+roix+" y="+roiy+"
> opacity=100");
> //overlays the invFFT onto the orig image
>
>                    impInvFFT.changes=false;
>                    impInvFFT.close();
> // closes the invFFT
>
>                   impFFT.close();
> //tries to close the FFT again, just in case (I don't trust my code to do
> it the first time....)
>
>
> Do you mean that I should use WindowManager.setTempCurrentImage(imp)
> BEFORE  I do any FFT and invFFT?
>
> I've attached the whole .java file, but I'm afraid it's a bit messy. Iit's
> all been written in a bit of a rush, plus, if you've not already guessed,
> I'm not a programmer of any kind (and don't know what a race-condition or
> FloatProcessor is), I normally just live in the lab with my polymers and
> surfaces...
>
> Thank you for your help!
> R
>
>
>
>
>
> On 15 April 2013 16:20, Michael Schmid-3 [via ImageJ] <
> [hidden email]> wrote:
>
>> 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] <http://user/SendEmail.jtp?type=node&node=5002649&i=0>>
>> 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:
>>>>
>>>>
>>>> .
>>>> 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
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://imagej.1557.x6.nabble.com/activeImage-how-to-set-it-tp3701057p5002649.html
>> To unsubscribe from activeImage- how to set it?, click here<
>> .
>> NAML<
http://imagej.1557.x6.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>
>>
>
>
> autoSplitSelect_DeFFT.java (6K) <http://imagej.1557.x6.nabble.com/attachment/5002826/0/autoSplitSelect_DeFFT.java>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/activeImage-how-to-set-it-tp3701057p5002826.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
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how active a different img

sombreroduck
13 posts
Hello Michael,
I'm sorry my code is unreadable, the code was cobbled together to do a job (sort through large-scale images and mark areas of potential interest), it wasn't meant to be shared. I would remove it from this pulic board if I could, but it throws an error when I try to edit that post. (but I did use English-language names, on the off-chance someone else would have to read it)

About using "Draw" rather than "set" in the FFT, do you mean that "Draw" will not serve the same function of passing those values in the InverseFFT? I used it since the points were already marked (from "find maxima") and it was easier to draw a blob than to start setting circular ROIs around them, then filling or setting them with white. Does using Draw rather than the others effect how the inverse FFT turns out? when I run it, the overlaid img looks like a fuzzy version of the originall area, with the regularly-spaced lines of polymer standing out.

Thank you for having taken time to help me out
R





On 29 April 2013 15:01, Michael Schmid-3 [via ImageJ] <[hidden email]> wrote:
Hi R,

sorry, I don't understand what your code should do and also your description does not help.

Your code is not documented and the names are very misleading - e.g. "public void doFFT" does not do any FFT but rather finds the maxima in a Roi. No way to understand code like this.

"Draw" is not an operation that is typically used to filter an FFT. One would use "Fill", or even better, either
run("Set...", "value=0"); for filtering (removing), *or*
run("Set...", "value=255"); for passing (removing everything else).
  You can't have 0 (black) and 255 (white) values at the same time.

Michael
________________________________________________________________
On Apr 27, 2013, at 10:00, sombreroduck wrote:

> Hi Michael,
> Sorry I've been even slower in replying, I've also been away, twice...and
> it's all been a bit crazy. Somewhere in-between though, as you guessed, I
> did indeed manage to get a couple of versions of the plugin working. I
> think the relevant bit is this (comments below the lines for readability)
>
>                    doFFT(impFFT, fftroi, noise, countx+antal*county, ResultsTable.getResultsTable());
> // This is a method that will do an FFT and find the maxima
>
>                    impInvFFT=doInvFFT(impFFT, ResultsTable.getResultsTable().getCounter()-1, countx+antal*county);
> // This method will perform an inverse FFT, close the FFT window, and
> return the imp for the inverse FFT
>
>                    WindowManager.setTempCurrentImage(imp);
> // This, I thought, was what would set the original image as the active
> window
>
>                    IJ.run("Add Image...", "x="+roix+" y="+roiy+"
> opacity=100");
> //overlays the invFFT onto the orig image
>
>                    impInvFFT.changes=false;
>                    impInvFFT.close();
> // closes the invFFT
>
>                   impFFT.close();
> //tries to close the FFT again, just in case (I don't trust my code to do
> it the first time....)
>
>
> Do you mean that I should use WindowManager.setTempCurrentImage(imp)
> BEFORE  I do any FFT and invFFT?
>
> I've attached the whole .java file, but I'm afraid it's a bit messy. Iit's
> all been written in a bit of a rush, plus, if you've not already guessed,
> I'm not a programmer of any kind (and don't know what a race-condition or
> FloatProcessor is), I normally just live in the lab with my polymers and
> surfaces...
>
> Thank you for your help!
> R
>
>
>
>
>
> On 15 April 2013 16:20, Michael Schmid-3 [via ImageJ] <
> [hidden email]> wrote:
>
>> 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] <http://user/SendEmail.jtp?type=node&node=5002649&i=0>>
>> 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. >>> Sent from the ImageJ mailing list archive at Nabble.com. > 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.x6.nabble.com/activeImage-how-to-set-it-tp3701057p5002854.html
To unsubscribe from activeImage- how to set it?, click here.
NAML