imagematlabimage-processingvideomathematical-morphology

Mask image with static threshold in matlab


I need to Binarize an image in matlab with a static threshold of 10% of mean intensity. I find mean intensity using mean2(Image) and this returns a mean let say 15.10 in one of the image. Thus my mean threshold is 1.51.im2bw(image,level) takes threshold between 0 to 1. How to binarize my image in this case in matlab?


Solution

  • You can binarize the image with a simple logical statement. For completeness, I've added the threshold determination as well.

    threshold = mean(Image(:));
    
    binaryMask = Image > 0.1 * threshold;