function [des,loc]=zoo_sift(im)
% This function reads SIFT keypoints of an image.
% Input parameters:
% pic: gray image.
%
% Returned:
% des: a K-by-128 matrix, where each row gives an invariant
% descriptor for one of the K keypoints. The descriptor is a vector
% of 128 values normalized to unit length.
% loc: K-by-4 matrix, in which each row has the 4 values for a
% keypoint location (row, column, scale, orientation). The
% orientation is in the range [-PI, PI] radians.
[row,col]=size(im);
% Convert into PGM imagefile, readable by "keypoints" executable
f=fopen('tmp.pgm','w');
if f==-1
error('Could not create file tmp.pgm.');
end
fprintf(f, 'P5\n%d\n%d\n255\n', col, row);
fwrite(f,im','uint8');
fclose(f);
% Call keypoints executable
if isunix
command = '!./sift ';
else
command = '!siftWin32 ';
end
command = [command ' <tmp.pgm >tmp.key'];
eval(command);
% Open tmp.key and check its header
g=fopen('tmp.key','r');
if g==-1
error('Could not open file tmp.key.');
end
[header,cnt]=fscanf(g,'%d %d',[1 2]);
if cnt~=2
error('Invalid keypoint file beginning.');
end
num=header(1);
len=header(2);
if len~=128
error('Keypoint descriptor length invalid (should be 128).');
end
% Creates the two output matrices (use known size for efficiency)
loc=double(zeros(num,4));
des=double(zeros(num,128));
for k=1:num
[vector,cnt]=fscanf(g, '%f %f %f %f', [1 4]);
if cnt~=4
error('Invalid keypoint file format');
end
loc(k,:)=vector(1,:);
[descrip, count] = fscanf(g, '%d', [1 len]);
if (count ~= 128)
error('Invalid keypoint file value.');
end
descrip = descrip / sqrt(sum(descrip.^2));
des(k, :) = descrip(1, :);
end
fclose(g);
for k=1:size(des,1)
des(k,:)=des(k,:)/sum(des(k,:));
end
delete tmp.key tmp.pgm
基于SIFT特征的图像配准(Matlab源代码)
3星 · 超过75%的资源 需积分: 42 133 浏览量
2015-10-22
23:48:18
上传
评论 50
收藏 50KB RAR 举报
destiny0321
- 粉丝: 852
- 资源: 15
最新资源
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
- 6
前往页