Login  Register

Problem with Threshold/ Possible to threshold only a selection or ROI?

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

Problem with Threshold/ Possible to threshold only a selection or ROI?

Kingpin
5 posts
Hello everyone,

I am writing a programm and need to find a way to detect automatically the central point of each square on this picture.
I was able to threshold most of the pictures and go on:

        getStatistics(area, mean, min, max);
        setThreshold(mean, max);
        doWand(x, y);
        run("To Bounding Box");
        getSelectionBounds(x,y,width, height);
        makePoint(x+width/2, y+height/2);


The problem is, that this method has problems with cognizing the two bright squares in this example.
The position of the squares is not exactly the same on each film.
Are there any "smarter" ways to solve this?
Or is it possible to threshold only inside a selection or ROI?

Thanks in anticipation
Greetings
Moritz




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

Re: Problem with Threshold/ Possible to threshold only a selection or ROI?

Kingpin
5 posts
Found a way.
Not the smartest one, but it works:

for(i=1;i<=number_squares;i++)
        {
        roiManager("Select", i-1);
        getStatistics(area, mean, min, max);
        setThreshold(mean, max);
        getSelectionBounds(x,y,w,h);
        x=x+w/2;
        y=y+h/2;
        doWand(x,y);
        run("To Bounding Box");
        getSelectionBounds(x,y,w,h);
        x=x+w/2;
        y=y+h/2;
        call("ij.Prefs.set", "qa.Re"+i+"x",x);
        call("ij.Prefs.set", "qa.Re"+i+"y",y);
        resetThreshold();
        }



roiManager("Show None");
selectWindow("ROI Manager");
run("Close");





If anyone knows a better way, please comment ^^