matlab映像紋理特徵提取

來源:互聯網
上載者:User


clear all;clc;ImagePath='D:\Caffe\Examples\WangYu\C2\WithAugment\Data\train_image\';Images = dir([ImagePath, '*.tif']);PictureNums = length(Images);FitureNums = 8;gray_comatrix=zeros(PictureNums,FitureNums);label_features=zeros(PictureNums,FitureNums+1);for i=1:PictureNums    i    name = Images(i).name;    I=imread([ImagePath,name]);        B=rgb2gray(I);        H=graycomatrix(B,'GrayLimits',[],'NumLevels', FitureNums,'Offset',[0 1;-1 1;0 -1;-1 -1]);%得到灰階共生矩陣    stats=new_graycoprops(H,'all');        Energy = [];    Energy= [Energy,stats.Energy];    Energy=mean(Energy);        Contrast=[];    Contrast=[Contrast,stats.Contrast];    Contrast=mean(Contrast);        Correlation=[];    Correlation=[Correlation,stats.Correlation];    Correlation=mean(Correlation);        Dissimilarity=[];    Dissimilarity=[Dissimilarity,stats.Dissimilarity];    Dissimilarity=mean(Dissimilarity);        Entropy=[];    Entropy=[Entropy,stats.Entropy];    Entropy=mean(Entropy);        Homogeneity=[];    Homogeneity=[Homogeneity,stats.Homogeneity];    Homogeneity=mean(Homogeneity);        Mean=[];    Mean=[Mean,stats.Mean];    Mean=mean(Mean);        Variance=[];    Variance=[Variance,stats.Variance];    Variance=mean(Variance);        %     gray_comatrix(i,1)=Energy;    %     gray_comatrix(i,2)=Contrast;    %     gray_comatrix(i,3)=Correlation;    %     gray_comatrix(i,4)=Dissimilarity;    %     gray_comatrix(i,5)=Entropy;    %     gray_comatrix(i,6)=Homogeneity;    %     gray_comatrix(i,7)=Mean;    %     gray_comatrix(i,8)=Variance;        %類別標籤    if(name(1)=='C')        label = 1;    else        label = 0;    end    label_features(i,1) = label;    label_features(i,2) = Energy;    label_features(i,3) = Contrast;    label_features(i,4) = Correlation;    label_features(i,5) = Dissimilarity;    label_features(i,6) = Entropy;    label_features(i,7) = Homogeneity;    label_features(i,8) = Mean;    label_features(i,9) = Variance;end% save('mat檔案名稱', '變數名') save('label_features', 'label_features');

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.