• 大小: 3.2MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-21
  • 语言: Matlab
  • 标签: 粗糙度  

资源简介

MATLAB的仿真程序,学图像的朋友可以参考一下

资源截图

代码片段和文件信息

%计算Tamura纹理特征
close all
clear all
clc
t0=cputime;
I = imread(‘D1.gif‘);
[NxNy] = size(I);
Ng=256;
G=double(I);
%计算粗糙度(coarseness)
Sbest=zeros(NxNy);
E0h=zeros(NxNy);
E0v=zeros(NxNy);
E1h=zeros(NxNy);
E1v=zeros(NxNy);
E2h=zeros(NxNy);
E2v=zeros(NxNy);
E3h=zeros(NxNy);
E3v=zeros(NxNy);
E4h=zeros(NxNy);
E4v=zeros(NxNy);
E5h=zeros(NxNy);
E5v=zeros(NxNy);
flag=0;

for i=1:Nx
    for j=2:Ny
        E0h(ij)=G(ij)-G(ij-1);
    end
end
E0h=E0h/2;

for i=1:Nx-1
    for j=1:Ny
        E0v(ij)=G(ij)-G(i+1j);
    end
end
E0v=E0v/2;

%图片大小必须大于4*4才能计算E1h、E1v
if (Nx<4||Ny<4)
    flag=1;
end
if(flag==0)
    for i=1:Nx-1
        for j=3:Ny-1
            E1h(ij)=sum(sum(G(i:i+1j:j+1)))-sum(sum(G(i:i+1j-2:j-1)));
        end
    end
    for i=2:Nx-2
        for j=2:Ny
            E1v(ij)=sum(sum(G(i-1:ij-1:j)))-sum(sum(G(i+1:i+2j-1:j)));
        end
    end
    E1h=E1h/4;
    E1v=E1v/4;
end


%图片大小必须大于8*8才能计算E2h、E2v
if (Nx<8||Ny<8)
    flag=1;
end
if(flag==0)
    for i=2:Nx-2
        for j=5:Ny-3
            E2h(ij)=sum(sum(G(i-1:i+2j:j+3)))-sum(sum(G(i-1:i+2j-4:j-1)));
        end
    end
    for i=4:Nx-4
        for j=3:Ny-1
            E2v(ij)=sum(sum(G(i-3:ij-2:j+1)))-sum(sum(G(i+1:i+4j-2:j+1)));
        end
    end
    E2h=E2h/16;
    E2v=E2v/16;
end


%图片大小必须大于16*16才能计算E3h、E3v
if (Nx<16||Ny<16)
    flag=1
end
if(flag==0)
    for i=4:Nx-4
        for j=9:Ny-7
            E3h(ij)=sum(sum(G(i-3:i+4j:j+7)))-sum(sum(G(i-3:i+4j-8:j-1)));
        end
    end
    for i=8:Nx-8
        for j=5:Ny-3
            E3v(ij)=sum(sum(G(i-7:ij-4:j+3)))-sum(sum(G(i+1:i+8j-4:j+3)));
        end
    end
    E3h=E3h/64;
    E3v=E3v/64;
end


%图片大小必须大于32*32才能计算E4h、E4v 
if (Nx<32||Ny<32)
    flag=1;
end
if(flag==0)
    for i=8:Nx-8
        for j=17:Ny-15
            E4h(ij)=sum(sum(G(i-7:i+8j:j+15)))-sum(sum(G(i-7:i+8j-16:j-1)));
        end
    end
    for i=16:Nx-16
        for j=9:Ny-7
            E4v(ij)=sum(sum(G(i-15:ij-8:j+7)))-sum(sum(G(i+1:i+16j-8:j+7)));
        end
    end
    E4h=E4h/256;
    E4v=E4v/256;
end


%图片大小必须大于64*64才能计算E5h、E5v
if (Nx<64||Ny<64)
    flag=1;
end
if(flag==0)
    for i=16:Nx-16
        for j=33:Ny-31
            E5h(ij)=sum(sum(G(i-15:i+16j:j+31)))-sum(sum(G(i-15:i+16j-32:j-31)));
        end
    end
    for i=32:Nx-32
        for j=17:Ny-15
            E5v(ij)=sum(sum(G(i-31:ij-16:j+15)))-sum(sum(G(i+1:i+32j-16:j+15)));
        end
    end
    E5h=E5h/1024;
    E5v=E5v/1024;
end

for i=1:Nx
    for j=1:Ny
        [maxvindex]=max([E0h(ij)E0v(ij)E1h(ij)E1v(ij)E2h(ij)E2v(ij)E3h(ij)E3v(ij)E4h(ij)E4v(ij)E5h(ij)E5v(ij)]);
        k=floor((index+1)/2);
        Sbest(ij)=2.^k;
    end
end
Fcoarseness=sum(sum(Sbest))/(Nx*Ny);
%计算对比度
[countsgraylevels]=imhist(I);
PI=counts/(Nx*Ny);
averagevalue=sum(graylevels.*PI);
u4=sum((graylevels-repmat(averagevalue[2561])).^4.*PI);
standarddeviation=sum((graylevels-repmat(averagevalue[2561])).^2.*PI);
alpha4=u4/standarddeviation^2;
Fcontrast=

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1626  2008-10-26 20:50  Roughness\ReadMe.txt

     文件        450  2008-10-26 20:50  Roughness\Resource.h

     文件        246  2008-10-26 20:50  Roughness\Roughness.clw

     文件      12922  2008-10-27 14:56  Roughness\Roughness.cpp

     文件       4394  2008-10-26 20:50  Roughness\Roughness.dsp

     文件        526  2008-10-26 20:50  Roughness\Roughness.dsw

     文件        532  2008-10-27 14:49  Roughness\Roughness.h

     文件      50176  2008-10-27 15:10  Roughness\Roughness.ncb

     文件      49664  2008-10-27 15:10  Roughness\Roughness.opt

     文件       1983  2008-10-27 15:10  Roughness\Roughness.plg

     文件       1457  2008-10-26 20:50  Roughness\Roughness.rc

     文件        892  2008-10-26 19:49  Roughness\Roughness.sln

    ..A..H.     21504  2008-10-27 15:10  Roughness\Roughness.suo

     文件        296  2008-10-26 20:50  Roughness\StdAfx.cpp

     文件       1106  2008-10-26 20:50  Roughness\StdAfx.h

     目录          0  2008-11-07 18:36  Roughness

     文件     282020  2006-11-18 12:14  brodatz纹理库\D1.gif

     文件     275134  2006-11-18 12:25  brodatz纹理库\D10.gif

     文件     372412  2006-11-18 12:17  brodatz纹理库\D2.gif

     文件     335990  2006-11-18 12:17  brodatz纹理库\D3.gif

     文件     415253  2006-11-18 12:21  brodatz纹理库\D4.gif

     文件     351599  2006-11-18 12:20  brodatz纹理库\D5.gif

     文件     325555  2006-11-18 12:22  brodatz纹理库\D6.gif

     文件     305841  2006-11-18 12:23  brodatz纹理库\D7.gif

     文件     242409  2006-11-18 12:23  brodatz纹理库\D8.gif

     文件     429522  2006-11-18 12:25  brodatz纹理库\D9.gif

     文件       4704  2008-12-15 11:19  brodatz纹理库\Tamura.m

    ..A.SH.     59392  2008-11-16 18:18  brodatz纹理库\Thumbs.db

     目录          0  2008-12-16 15:52  brodatz纹理库

----------- ---------  ---------- -----  ----

............此处省略2个文件信息

评论

共有 条评论