matlab紋理特徵提取代碼

來源:互聯網
上載者:User
[html]  view plain copy function [t]=statxture(f,scale)   if nargin==1       scale(1:6)=1;   else       scale=scale(1:6)';   end   p=imhist(f);                  %p是256*1的列向量   p=p./numel(f);   L=length(p);   [v,mu]=statmoments(p,3);   %計算六個紋理特徵   t(1)=mu(1);                   %平均值   t(2)=mu(2).^0.5;              %標準差    varn=mu(2)/(L-1)^2;        t(3)=1-1/(1+varn);            %平滑度首先為(0~1)區間通過除以(L-1)^2將變數標準化   t(4)=mu(3)/(L-1)^2;           %三階矩(通過除以(L-1)^2將變數標準化)   t(5)=sum(p.^2);               %一致性   t(6)=-sum(p.*(log2(p+eps)));  %熵   T=[t(1) t(2) t(3) t(4) t(5) t(6)]   %縮放值,預設為1   t=t.*scale;   end      function [v,unv]=statmoments(p,n)   Lp=length(p);   if (Lp~=256)&(Lp~=65536)       error('p must be a 256- or 65536-element vector.');   end   G=Lp-1;   p=p/sum(p);p=p(:);   z=0:G;   z=z./G;   m=z*p;   z=z-m;   v=zeros(1,n);   v(1)=m;   for j=2:n       v(j)=(z.^j)*p;   end   if nargout>1       unv=zeros(1,n);       unv(1)=m.*G;       for j=2:n           unv(j)=((z*G).^j)*p       end   end   end  

f為輸入的圖片,必須是灰階映像。

因為紋理特徵提取是灰階的紋理特徵。

matlab中建立一個function的M檔案
拷貝上面的代碼運行就可以了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.