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

    %% Segment Image Into Two Regions
% 
%% 
% Read image and display it.

% Copyright 2015 The MathWorks, Inc.

I = imread('coins.png');
imshow(I)
%%
% Calculate a single threshold value for the image.
level = multithresh(I);
%%
% Segment the image into two regions using |imquantize| , specifying the
% threshold level returned by |multithresh| .
seg_I = imquantize(I,level);
figure
imshow(seg_I,[])