www.gusucode.com > vision 源码程序 matlab案例代码 > vision/ConvertAnRGBImageToABinaryImageExample.m

    %% Convert an Image to a Binary Image

% Copyright 2015 The MathWorks, Inc.

 %%
 img = im2single(rgb2gray(imread('peppers.png')));
 imshow(img);
 hautoth = vision.Autothresholder;
 bin = step(hautoth,img);
 pause(2);
 figure;imshow(bin);