clc;
clear all;
I = imread('C:\Users\Administrator\Pictures\Saved Pictures\PC.jpg');
I=rgb2gray(I);
[width,height] = size(I);
T1=150;
for i=1:width
for j=1:height
if(I(i,j)<T1)
BW1(i,j)=0;
else
BW1(i,j)=1;
end
end
end
T0 = 1;%设置门限
T2= 150; %初始阈值T2
%设置G1,G2两个列向量,各自统计<T和>T的值
gl1 = 1;%灰度级1