Differential statistical characteristic gradation (contrast average entropy) of texture characterization to calculate and compare two differential statistical texture image gradation characteristic matlab code implemented

Gray differential statistical features are:

Average:

Contrast:

Entropy:

i denotes a gradation value, p (i) represents the gray value of the image capture probability

close all;clear all;clc;
% 纹理图像的灰度差分统计特征
J = imread('qiang1.jpg');
A = double(J);
[m,n] = size(A);
B = A;
C = zeros(m,n);
for i=1:m-1
    for j=1:n-1
        B(i,j) = A(i+1,j+1);
        C(i,j) = abs(round(A(i,j)-B(i,j)));
    end
end
h = imhist(mat2gray(C))/(m*n);
mean = 0;con=0;ent=0;  %均值mean,对比度con,熵ent
for i=1:256
    mean = mean + (i*h(i))/256;
    con = con+i*i*h(i);
    if(h(i)>0)
        ent = ent-h(i)*log2(h(i));
    end
end
mean,con,ent

qiang1.jpg                                                                                       qiang2.jpg

​                                                                             

Can see the higher qiang1.jpg contrast; entropy higher value, more chaotic image; mean bigger, the image looks a little darker color.

Guess you like

Origin www.cnblogs.com/wojianxin/p/11425052.html