Thesholding in a plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Thesholding in a plugin

Gib Bogle
I have written a plugin for extracting particle trajectories from a
sequence of frames.  Currently I supply the threshold parameters that
get applied to each frame, and do the thresholding thus:

                IJ.setThreshold(minThreshold, maxThreshold);
                IJ.run("Threshold", "thresholded remaining black");

Now I want to add the capability to interactively determine the optimal
threshold settings when the program executes (instead of using supplied
values).  I think I need to be able to do two things.  First, I need the
execution to pause while I'm manually adjusting the slider in the
Threshold pop-up (currently it carries on, not giving me a chance to do
the adjustment).  Second, I need to be able to retrieve the values for
minThreshold and maxThreshold.

Can these things be done?

Thanks
Gib

--
Dr. Gib Bogle
Research Scientist
Bioengineering Institute
University of Auckland
New Zealand

http://www.bioeng.auckland.ac.nz

[hidden email]
(64-9) 373-7599 Ext. 87030
Reply | Threaded
Open this post in threaded view
|

Re: Thesholding in a plugin

Leon Espinosa
I have previously posted plugin to modifiy the behavior of "adjust
threshold" command. Just you have to install the "Threshold_2" plugin
bellow and then use IJ.run("Threshold 2"); instead. The program will
wait until the user close the threshold adjuster window, exemple:

//--------- exemple-------------
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;

public class ex_threshold2 implements PlugIn {

    public void run(String arg) {
        IJ.run("Blobs (25K)");
        IJ.showMessage("Adjust threshold TO CONTINUE please close the
window");
        IJ.run("Threshold 2");
        IJ.run("Unlock Image");
        IJ.run("Threshold", "thresholded remaining black");
        IJ.showMessage("Done");
    }

}
//----------- end -------------------

And the code to install Threshold_2 plugin is:

//  ----------- Threshold_2.java --------------

import ij.*;
import ij.process.*;
import ij.gui.*;
import ij.plugin.*;
import ij.plugin.frame.*;
import ij.plugin.frame.ThresholdAdjuster.*;


import java.lang.*;
import java.lang.Object.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.WindowEvent.*;


public class Threshold_2 implements PlugIn {

    int wclose = 202;

    public void run(String arg)    {
        CustomThresholdAdjuster2 seuil = new CustomThresholdAdjuster2();

        while(!(seuil.getWclose==wclose)) {}
//        IJ.showMessage(" la suite...");


    }


}

class CustomThresholdAdjuster2 extends ThresholdAdjuster {

    public int getWclose;
    boolean fin = false;

    public void windowClosing(WindowEvent w) {  
    super.windowClosing(w);
    String Waction = w.paramString();
    getWclose = w.WINDOW_CLOSED;

    }  

}

//--------- end ----------------------





Good look, Leon



Gib Bogle wrote:

> I have written a plugin for extracting particle trajectories from a
> sequence of frames.  Currently I supply the threshold parameters that
> get applied to each frame, and do the thresholding thus:
>
>                IJ.setThreshold(minThreshold, maxThreshold);
>                IJ.run("Threshold", "thresholded remaining black");
>
> Now I want to add the capability to interactively determine the
> optimal threshold settings when the program executes (instead of using
> supplied values).  I think I need to be able to do two things.  First,
> I need the execution to pause while I'm manually adjusting the slider
> in the Threshold pop-up (currently it carries on, not giving me a
> chance to do the adjustment).  Second, I need to be able to retrieve
> the values for minThreshold and maxThreshold.
>
> Can these things be done?
>
> Thanks
> Gib
>