First, the color moment formula
First-order color moment-mean value, reflecting the intensity of the image
Second-order color moment-standard deviation, reflecting image color distribution range
Third-order color moment-variance, reflecting the symmetry of image color distribution
Second, method one:
Firstmoment = mean (mean (tmpimage)); % first-order color moment
difference = Tmpimage (:,:, M)-firstmoment (1,1,M); % Differential Color moment
Secondmoment = sqrt (mean (mean (difference.*difference))); % second-order color moment
Thirdmoment = Nthroot (mean (mean (difference.*difference.*difference)), 3); % third-order color moment
To interpret
tmpimage–>101 (rows) *101 (columns) (layers) Matrix
First seek mean (mean (tmpimage)): 1*101*3
% mean mean function, precedence for column averaging
firstmoment–> second seek mean: 1*1*3
Difference–> 101*101*1
% point multiplication (matrix multiplication):[3*3*1].*[3*3*1]–> [3*3*1]
Difference.*difference–> 101*101*1
% two times the mean is because a matrix that requires a two-dimensional matrix
Secondmoment–> principle Ibid.
Thirdmoment–> principle Ibid.
Third, method two
Firstmoment = mean (mean (tmpimage)); % first-order color moment
difference = Tmpimage (:,:, M)-firstmoment (1,1,M); % Differential Color moment
secondmoment = sqrt (sum (difference (:). *difference (:))/101/101));% second-order color moment
thirdmoment = Nthroot (sum (Difference (:). *difference (:). *difference (:))/101*101,3);% third-order color moment
To interpret
Difference (:) –>10201*1 (Columns) * * (layer)
% converts its matrix to N*1 's column matrix
Difference (:). *difference (:) –> 10201*1*1
SUM ((Difference (:). *difference (:))/101/101)) –> 1 (sum value) *1*1
Sum value/101/101–> mean value
RGB Color moment extraction algorithm--matlab