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

    %% Segment Image into Three Levels Using Two Thresholds
%
%%
% Read image and display it.

% Copyright 2015 The MathWorks, Inc.

I = imread('circlesBrightDark.png');
imshow(I)
axis off
title('Original Image')
%%
% Calculate two threshold levels.
thresh = multithresh(I,2);
%%
% Segment the image into three levels using |imquantize| .
seg_I = imquantize(I,thresh);
%%
% Convert segmented image into color image using |label2rgb| and display
% it.
RGB = label2rgb(seg_I); 	 
figure;
imshow(RGB)
axis off
title('RGB Segmented Image')