【CBIR】【Color】颜色矩(Color Moment)2

时间:2023-02-04 18:24:42

颜色矩(Color Moment)2

function colorMoments = colorMoments(image)
% input: image to be analyzed and extract 3 first moments from each R,G,B
% output: 1x9 vector containing the 3 first color momenst from each R,G,B
% channel

% extract color channels
R = double(image(:, :, 1));
G = double(image(:, :, 2));
B = double(image(:, :, 3));

% compute 2 first color moments from each channel
meanR = mean( R(:) );
stdR  = std( R(:) );
SkewR =  mean((R(:)-meanR).^3)^(1/3);

meanG = mean( G(:) );
stdG  = std( G(:) );
SkewG = mean((G(:)-meanG).^3)^(1/3);

meanB = mean( B(:) );
stdB  = std( B(:) );
SkewB = mean((B(:)-meanB).^3)^(1/3);

% construct output vector
colorMoments = zeros(1, 9);
colorMoments(1, :) = [meanR,stdR,SkewR,meanG,stdG,SkewG,meanB,stdB,SkewB];

% clear workspace
clear('R', 'G', 'B', 'meanR', 'stdR', 'SkewR' ,'meanG', 'stdG', 'SkewG' ,'meanB', 'stdB','SkewRB');

end
【CBIR】【Color】颜色矩(Color Moment)2