Extracting texture feature source by gray-scale symbiosis matrix

Source: Internet
Author: User

Extracting texture feature source by gray-scale symbiosis matrix
%**************************************************************************
% image retrieval--texture features
% based on Symbiosis matrix texture feature extraction, d=1,θ=0°,45°,90°,135° a total of four matrices
% image grayscale level is 256
% reference "image retrieval based on color space and texture features"
%function:t=texture (Image)
%image: Input image data
%T: Returns a eight-dimensional texture feature line vector
%**************************************************************************
function T = Vtex (Gray)

Gray = Imread (' indentation. bmp ');
M=size (gray,1);
N=size (gray,2);
%M = 256;
%N = 256;

%--------------------------------------------------------------------------
%1. converting each color component to grayscale
%--------------------------------------------------------------------------
%gray = Double (0.3*image (:,:, 1) +0.59*image (:,:, 2) +0.11*image (:,:, 3));

%--------------------------------------------------------------------------
%2. To reduce the amount of computation, gray level compression of the original image, Gray quantization to 16 levels
%--------------------------------------------------------------------------
For i = 1:m
for j = 1:n
For n = 1:256/16
if (n-1) *16<=gray (i,j) &&gray (i,j) <= (n-1) *16+15
Gray (i,j) = n-1;
End
End
End
End

%--------------------------------------------------------------------------
%3. Calculate four symbiosis matrices P, take distance of 1, angle is 0,45,90,135
%--------------------------------------------------------------------------
P = zeros (16,16,4);
for m = 1:16
For n = 1:16
For i = 1:m
for j = 1:n
If Gray (i,j) ==m-1
If J<n&&gray (i,j+1) ==n-1
P (m,n,1) = P (m,n,1) +1;
End
If I>1&&j<n&&gray (i-1,j+1) ==n-1
P (m,n,2) = P (m,n,2) +1;
End
If I<m&&gray (i+1,j) ==n-1
P (m,n,3) = P (m,n,3) +1;
End
If I<m&&j<n&&gray (i+1,j+1) ==n-1
P (m,n,4) = P (m,n,4) +1;
End
End
End
End
P (n,m,1) = P (m,n,1);
P (n,m,2) = P (m,n,2);
P (n,m,3) = P (m,n,3);
P (n,m,4) = P (m,n,4);
If M==n
P (m,n,:) = P (m,n,:));
End
End
End

%%---------------------------------------------------------
% normalization of the symbiosis matrix
%%---------------------------------------------------------
For n = 1:4
P (:,:, N) = P (:,:, N)/sum (SUM (P (:,:, N)));
End

%--------------------------------------------------------------------------
%4. Calculate energy, entropy, moment of inertia and related 4 texture parameters for symbiosis matrix
%--------------------------------------------------------------------------
H = zeros (1,4);
I = H;
Ux = H; Uy = H;
Deltax= H; DeltaY = H;
C =h;
For n = 1:4
E (n) = SUM (SUM (P (:,:, N). ^2)); Percent Energy
For i = 1:16
for j = 1:16
If P (i,j,n) ~=0
H (n) =-P (i,j,n) *log (P (i,j,n)) +h (n); Percent entropy
End
I (n) = (i-j) ^2*p (i,j,n) +i (n); Percent Inertia moment

Ux (n) = I*p (i,j,n) +ux (n); % Correlation in μx
Uy (n) = J*p (i,j,n) +uy (n); % Correlation in Μy
End
End
End
For n = 1:4
For i = 1:16
for j = 1:16
DeltaX (n) = (I-ux (n)) ^2*p (i,j,n) +deltax (n); % correlation in σx due
DeltaY (n) = (J-uy (n)) ^2*p (i,j,n) +deltay (n); % Correlation in Σy
C (n) = I*j*p (i,j,n) +c (n);
End
End
C (N) = (c (n)-ux (n) *uy (n))/deltax (n)/deltay (n); % dependency
End

%--------------------------------------------------------------------------
% energy, entropy, moment of inertia, correlation mean and standard deviation as final 8-dimensional texture characteristics
%--------------------------------------------------------------------------
T (1) = mean (E); T (2) = sqrt (cov (E));
T (3) = mean (H); T (4) = sqrt (cov (H));
T (5) = mean (I); T (6) = sqrt (cov (I));
T (7) = mean (C); T (8) = sqrt (cov (C));

Extracting texture feature source by gray-scale symbiosis matrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.