📄 one_d_wfcm.m
字号:
A=imread('test.jpg');
B=rgb2gray(A);
%B=A(:,:,2);
B=medfilt2(B);
subplot(2,2,1),imshow(B,[])
record_hist=imhist(B);
threshold_hist=10;
record_hist(1:threshold_hist)=zeros(threshold_hist,1);
record_hist=record_hist/sum(record_hist);
U=[0:255]';
V=[min(U) max(U)];
epsilon=1e-2;
class_num=length(V);
R=zeros(class_num,256);
flag=1;
while flag==1
for j=1:256
temp_distant=[];
for i=1:class_num
if abs(U(j)-V(i))<1e-6
temp_distant=[temp_distant 1e-6];
else
temp_distant=[temp_distant abs(U(j)-V(i))];
end
end
for i=1:class_num
R(i,j)=1/sum(temp_distant(i)^2./(temp_distant).^2);
end
end
V1=zeros(size(V));
for i=1:class_num
V1(i)=record_hist'.*(R(i,:).^2)*U/sum(record_hist'.*(R(i,:).^2));
end
if max(abs(V-V1))<epsilon
flag=0;
else
V=V1;
end
% V
end
[a1 a2]=size(B);
C=zeros(a1,a2);
for i=1:a1
for j=1:a2
if B(i,j)>=10
temp=abs(double(B(i,j))-V);
a=find(temp==min(temp));
C(i,j)=0.5*a(1);
end
end
end
subplot(2,2,2),imshow(C,[])
for i=1:a1
for j=1:a2
if C(i,j)~=1
B(i,j)=0;
end
end
end
subplot(2,2,3),imshow(B)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -