www.gusucode.com > images 案例代码 matlab源码程序 > images/BinarizeImageUsingGlobalThresholdExample.m

    %% Binarize Image Using Global Threshold
%  
%%
% Read grayscale image into the workspace.
I = imread('coins.png');
%%
% Convert the image into a binary image.
BW = imbinarize(I);
%%
% Display the original image next to the binary version.
figure
imshowpair(I,BW,'montage')