Rectangle roi from ImageStack
Posted by Michael Doube on Mar 18, 2009; 1:09pm
URL: http://imagej.273.s1.nabble.com/Rectangle-roi-from-ImageStack-tp3693215.html
Hi all
I want to get the Rectangle ROI from an ImageStack that I have passed to
a method, as in
public void myMethod(ImageStack stack){
Rectangle r = stack.getRoi();
//do something with r
return;
}
This is fine when there is a rectangle drawn, but if there is not an ROI
drawn, I get a null pointer exception.
Interestingly, if I set r to be a class variable
Public Rectangle r;
Then in the run() method set it with
r = ip.getRoi();
All the 'r's in my other methods behave sensibly and I don't get a null
pointer exception when I haven't drawn an ROI on my stack.
What is going on here?
Mike