2014-7自编数字图像处理实验-参考答案 下载本文

新疆大学信息科学与工程学院

H(i,j) = 3; end

if h(i,j)<=80&&h(i,j)>55 H(i,j) = 4; end

if h(i,j)<=108&&h(i,j)>80 H(i,j) = 5; end

if h(i,j)<=140&&h(i,j)>108 H(i,j) = 6; end

if h(i,j)<=165&&h(i,j)>140 H(i,j) = 7; end

if h(i,j)<=190&&h(i,j)>165 H(i,j) = 8; end

if h(i,j)<=220&&h(i,j)>190 H(i,j) = 9; end

if h(i,j)<=255&&h(i,j)>220 H(i,j) = 10; end

if h(i,j)<=275&&h(i,j)>255 H(i,j) = 11; end

if h(i,j)<=290&&h(i,j)>275 H(i,j) = 12; end

if h(i,j)<=316&&h(i,j)>290 H(i,j) = 13; end

if h(i,j)<=330&&h(i,j)>316 H(i,j) = 14; end

if h(i,j)<=345&&h(i,j)>330 H(i,j) = 15; end end end

for i = 1:M for j = 1:N

if s(i,j)<=0.15&&s(i,j)>0 S(i,j) = 0;

49

新疆大学信息科学与工程学院

end

if s(i,j)<=0.4&&s(i,j)>0.15 S(i,j) = 1; end

if s(i,j)<=0.75&&s(i,j)>0.4 S(i,j) = 2; end

if s(i,j)<=1&&s(i,j)>0.75 S(i,j) = 3; end end end

for i = 1:M for j = 1:N

if v(i,j)<=0.15&&v(i,j)>0 V(i,j) = 0; end

if v(i,j)<=0.4&&v(i,j)>0.15 V(i,j) = 1; end

if v(i,j)<=0.75&&v(i,j)>0.4 V(i,j) = 2; end

if v(i,j)<=1&&v(i,j)>0.75 V(i,j) = 3; end end end

%将三个颜色分量合成为一维特征向量:L = H*Qs*Qv+S*Qv+v;Qs,Qv分别是S和V的量化级数, L取值范围[0,255] %取Qs = 4; Qv = 4 for i = 1:M for j = 1:N

L(i,j) = H(i,j)*16+S(i,j)*4+V(i,j); end end

%计算L的直方图 for i = 0:255

Hist(i+1) = size(find(L==i),1); end

% Hist = Hist/sum(Hist); T=Hist;

stem(hist(:));

50