feature 计算机,【计算机视觉领域】常用的 feature 提取方法,feature 提取工具包...

%% Extract Every kind of Features

% the VL_tool box for feature extraction.

clc;

run('/home/wangxiao/Documents/MATLAB/vlfeat-0.9.20-bin/vlfeat-0.9.20/toolbox/vl_setup.m')

imagePath = '/home/wangxiao/Documents/Sun-80-dataset/Sun_80_dataset/train_image_sun_256_256/' ;

Labeled_data = importdata('/home/wangxiao/Documents/Sun-80-dataset/Sun_80_dataset/SUN100_Label_train_0.5_.txt');

Unlabel_data = importdata('/home/wangxiao/Documents/Sun-80-dataset/Sun_80_dataset/SUN100_Unlabel_train_0.5_.txt');

for i = 1:size(Labeled_data.data, 1)

imageName = Labeled_data.textdata{i, 1};

% image = imread([imagePath, imageName]);

image = imread('/home/wangxiao/Pictures/wallhaven-382471.png');

image = imresize(image, [224, 224]);

% change the image into single precision.

figure; imshow(image);

imgs = im2single(rgb2gray(image)) ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% use vl_covdet to compute and visualize co-variant features.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

frames = vl_covdet(imgs, 'verbose') ;

hold on ;

vl_plotframe(frames) ; % visualize the features.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% use vl_hog to extract the hog feature.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cellSize = 8 ;

hog = vl_hog(imgs, cellSize, 'verbose') ;

imhog = vl_hog('render', hog, 'verbose') ;

clf ; imagesc(imhog) ; colormap gray ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% use vl_sift to extract the sift feature.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[f,d] = vl_sift(imgs) ;

perm = randperm(size(f,2)) ;

sel = perm(1:50) ;

h1 = vl_plotframe(f(:,sel)) ;

h2 = vl_plotframe(f(:,sel)) ;

set(h1,'color','k','linewidth',3) ;

set(h2,'color','y','linewidth',2) ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% use vl_mser to extact the mser feature.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I = uint8(rgb2gray(image)) ;

[r,f] = vl_mser(I,'MinDiversity',0.7,...

'MaxVariation',0.2,...

'Delta',10) ;

f = vl_ertr(f) ;

vl_plotframe(f) ;

M = zeros(size(I)) ;

for x=r'

s = vl_erfill(I,x) ;

M(s) = M(s) + 1;

end

figure(2) ;

clf ; imagesc(I) ; hold on ; axis equal off; colormap gray ;

[c,h]=contour(M,(0:max(M(:)))+.5) ;

set(h,'color','y','linewidth',3) ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% use vl_quickseg to execute Quick shift.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I = uint8(rgb2gray(image));

ratio = 0.5;

kernelsize = 2;

maxdist = 50;

ndists = 10;

Iseg = vl_quickseg(I, ratio, kernelsize, maxdist);

Iedge = vl_quickvis(I, ratio, kernelsize, maxdist, ndists) ;

imagesc(Iedge);

axis equal off tight;

colormap gray;

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值