读取siftgeo格式文件的matlab程序

% This function reads a siftgeo binary file %读取siftgeo格式的二进制文件
%
% Usage: [v, meta] = siftgeo_read (filename, maxdes)
%   filename    the input filename
%   maxdes      maximum number of descriptors to be loaded 要加载的描述子最大数量
%   (default=unlimited)%默认无限制
%
% Returned values %返回值
%   v           the sift descriptors (1 descriptor per line) %每行一个sift描述子
%   meta        meta data for each descriptor, i.e., per line: %每个描述子的元数据
%               x, y, scale, angle, mi11, mi12, mi21, mi22, cornerness
function [v, meta] = siftgeo_read (filename, maxdes) 

if nargin < 2 %nargin:number of arguments input %nargout:number of arguments ouput
  maxdes = 100000000; %1亿
end
  
% open the file and count the number of descriptors
fid = fopen (filename, 'r');
 
fseek (fid, 0, 1); %fseek(fid, 0, 'eof'); 跳到文件末尾 %'bof' or -1   Beginning of file;  'cof' or  0   Current position in file;  'eof' or  1   End of file
n = ftell (fid) / (9 * 4 + 1 * 4 + 128); %n是descriptors的数量 %return the current position (number of bytes from the file beginning)
fseek (fid, 0, -1); %fseek(fid, 0, 'bof') 跳到文件开头


if n > maxdes
  n = maxdes;
end;

% first read the meta information associated with the descriptor
meta = zeros (n, 9, 'single'); %n*9矩阵
v = zeros (n, 128, 'single'); %n*128矩阵

% read the elements
for i = 1:n %n是要读区的descriptors数量
  meta(i,:) = fread (fid, 9, 'float'); %(float)*9 元数据信息
  d = fread (fid, 1, 'int'); %(int)*1
  v(i,:) = fread (fid, d, 'uint8=>single'); %(uint8=>single)*d 描述子
end

fclose (fid);
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值