I think imbinarize() and graythresh() work on 1-D images. So if you want to determine the a threshold only considering the gray levels of the gray ring and not considering the black background, extract the ring pixels into a list and pass them to graythresh():
ringPixels = originalImage(originalImage > theThreshold);
newThreshold = graythresh(ringPixels);
Since you've already masked the image by doing something like
maskedImage = originalImage;
maskedImage(mask) = 0;
you could also do the first line like this
ringPixels = maskedImage(maskedImage > 0);
and then call graythresh();
Best Answer