比较几种常见的图像特征(demo)

227 阅读1分钟

前言

所有的例图均为下图所示计算得来的,是《比较几种常见的图像特征》( juejin.cn/post/708754… 颜色特征:

clc
clear 
%%
I = imread('1.jpg');
hsv_I = rgb2hsv(I);
%%
I_h = hsv_I(:,:,1);
I_s = hsv_I(:,:,2);
I_v = hsv_I(:,:,3);
%%
mean_hsv_I = [mean(I_h) mean(I_s) mean(I_v)]; % 一阶
%%
std_hsv_I = [std(I_h) std(I_s) std(I_v)];% 二阶
%%
skewness_hsv_I = [skewness(I_h) skewness(I_s) skewness(I_v)];% 三阶

纹理特征:
SIFT:

可参考经典demo:
[Keypoint detector (ubc.ca)](https://www.cs.ubc.ca/~lowe/keypoints/)

HOG:

clear
img = imread('1.jpg');
[featureVector,hogVisualization] = extractHOGFeatures(img);
figure;
imshow(img); 
hold on;
plot(hogVisualization);

LBP:

clc
clear
I = imread('1.jpg');
I = rgb2gray(I);
lbpFeatures = extractLBPFeatures(I,'CellSize',[32 32],'Normalization','None');
numNeighbors = 8;
numBins = numNeighbors*(numNeighbors-1)+3;
lbpCellHists = reshape(lbpFeatures,numBins,[]);
lbpCellHists = bsxfun(@rdivide,lbpCellHists,sum(lbpCellHists));
lbpFeatures = reshape(lbpCellHists,1,[]);