www.gusucode.com > images 案例代码 matlab源码程序 > images/BinarizeImagesWithDarkerForegroundThanBackgroundExample.m
%% Binarize Images with Darker Foreground Than Background. % %% % Read a grayscale image into the workspace and display it. I = imread('printedtext.png'); figure imshow(I) title('Original Image') %% % Convert the image to a binary image using adaptive thresholding. Use the % |ForegroundPolarity| parameter to indicate that the foreground is darker % than the background. BW = imbinarize(I,'adaptive','ForegroundPolarity','dark','Sensitivity',0.4); %% % Display the binary version of the image. figure imshow(BW) title('Binary Version of Image')