顏色矩特徵提取Matlab源碼

function cmVec = colorMom(direc) njpgfile = direc; nif length(size(jpgfile))==2 n jpgfile1=zeros(size(jpgfile,1),size(jpgfile,2),3); n jpgfile1(:,:,1)=jpgfile; n jpgfile1(:,:,2)=jpgfile; n jpgfile1(:,:,3)=jpgfile; n jpgfile=jpgfile1; n direc nend n[a b c] = size(jpgfile); nm = floor(a/5); nn = floor(b/5); ncmVec = zeros(1,225);nfor i=1:5 n for j = 1:5 n subimage = jpgfile((i-1)*m+1:i*m,(j-1)*n+1:j*n,:); n tmp = (i-1)*5+j-1; n cmVec(tmp*9+1) = mean(mean(subimage(:,:,1))); n cmVec(tmp*9+2) = mean(mean(subimage(:,:,2))); n cmVec(tmp*9+3) = mean(mean(subimage(:,:,3))); n for p = 1:m n for q = 1:n n cmVec(tmp*9+4) = cmVec(tmp*9+4) + (subimage(p,q,1)-cmVec(tmp*9+1))^2; n cmVec(tmp*9+5) = cmVec(tmp*9+5) + (subimage(p,q,2)-cmVec(tmp*9+2))^2; n cmVec(tmp*9+6) = cmVec(tmp*9+6) + (subimage(p,q,3)-cmVec(tmp*9+3))^2; n cmVec(tmp*9+7) = cmVec(tmp*9+7) + (subimage(p,q,1)-cmVec(tmp*9+1))^3; n cmVec(tmp*9+8) = cmVec(tmp*9+8) + (subimage(p,q,2)-cmVec(tmp*9+2))^3; n cmVec(tmp*9+9) = cmVec(tmp*9+9) + (subimage(p,q,3)-cmVec(tmp*9+3))^3; n end n end n cmVec((tmp*9+4):(tmp*9+9)) = cmVec((tmp*9+4):(tmp*9+9))/(m*n); n cmVec(tmp*9+4) = cmVec(tmp*9+4)^(1/2); n cmVec(tmp*9+5) = cmVec(tmp*9+5)^(1/2); n cmVec(tmp*9+6) = cmVec(tmp*9+6)^(1/2); n n if cmVec(tmp*9+7) >0 n cmVec(tmp*9+7) = cmVec(tmp*9+7)^(1/3); n else n cmVec(tmp*9+7) = -((-cmVec(tmp*9+7))^(1/3)); n end n if cmVec(tmp*9+8) >0 n cmVec(tmp*9+8) = cmVec(tmp*9+8)^(1/3); n else n cmVec(tmp*9+8) = -((-cmVec(tmp*9+8))^(1/3)); n end n if cmVec(tmp*9+9) >0 n cmVec(tmp*9+9) = cmVec(tmp*9+9)^(1/3); n else n cmVec(tmp*9+9) = -((-cmVec(tmp*9+9))^(1/3)); n end n n end nend nif sqrt(sum(cmVec.^2))~=0 n cmVec = cmVec / sqrt(sum(cmVec.^2)); nend n

推薦閱讀:

Controllable Invariance through Adversarial Feature Learning
圖像底層特徵提取--顏色特徵(1)
在機器學習的項目中,特徵是如何被找出來的?
用語音mfcc參數作為特徵,利用SVM來進行分類判斷聲音是否是嬰兒哭聲?
像微博這種短文本的分析,用什麼方法提取特徵比較好呢?

TAG:MATLAB | 特征提取 |