I have to segment a region from a monochrome image.
After the application of the command 'graythreshold' in my code, the command 'im2bw' requires a threshold value to expand the binary image containing only the ROI, so that I can take the complement of that binary image and subtract and obtain the ROI.
However, the threshold value I select for one image, isn't applicable to the other images specially if the main region of segmentation is much below the level. For some images, the threshold value of 0.13 works while for lower intensity images it can be around 0.03.
How do I code it in such a way that to expand the binary image, the part of the code should automatically analyze the image and set a threshold level rather than me changing it for each image?