makefeatures.m

来自「图像 里面常用到的矩阵运算」· M 代码 · 共 30 行

M
30
字号
function features = makeFeatures( corners, img, mws )
% features = makeFeatures( corners, img, mws )
% create features structure for an image
%   corners - feature locations, calculated if = []
%   img     - the image
%   mws     - match window size

if corners == []
    corners = corner_detector( img );
end
imgg = rgb2gray( img );

features.count = size(corners,1);   % number of features
features.pos = corners;             % feature positions (matrix coords)
features.rmw = {};                  % relative match window
features.pixels = {};               % window pixels
features.npixels = {};              % normalized window pixels
features.matches = {};              % matches (index correlation)
for i = 1:features.count
    c = features.pos(i,:);
	mw = [max(c + 0.5 - mws / 2, [1 1]); min(c + 0.5 + mws / 2, size(imgg))];
	rmw = mw - [c;c];
	pixels = double(imgg(mw(1,1):mw(2,1), mw(1,2):mw(2,2)));
	npixels = pixels - mean( pixels(:) );   % zero mean
    npixels = npixels / norm( npixels(:));  % normalize

    features.rmw{i} = rmw;
    features.pixels{i} = pixels;
    features.npixels{i} = npixels;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?