sift算法的MATLAB程序
更新时间:2024-01-31 07:43:01 阅读量: 教育文库 文档下载
- 丝芙兰推荐度:
- 相关推荐
% [image, descriptors, locs] = sift(imageFile) %
% This function reads an image and returns its SIFT keypoints. % Input parameters:
% imageFile: the file name for the image. %
% Returned:
% image: the image array in double format
% descriptors: 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.
% locs: 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. %
% Credits: Thanks for initial version of this program to D. Alvaro and % J.J. Guerrero, Universidad de Zaragoza (modified by D. Lowe)
function [image, descriptors, locs] = sift(imageFile)
% Load image
image = imread(imageFile);
% If you have the Image Processing Toolbox, you can uncomment the following
% lines to allow input of color images, which will be converted to grayscale.
% if isrgb(image)
% image = rgb2gray(image); % end
[rows, cols] = size(image);
% Convert into PGM imagefile, readable by \ 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', cols, rows); fwrite(f, image', 'uint8'); fclose(f);
% Call keypoints executable if isunix
command = '!./sift '; else
command = '!siftWin32 '; end
command = [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, count] = fscanf(g, '%d %d', [1 2]); if count ~= 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) locs = double(zeros(num, 4));
descriptors = double(zeros(num, 128));
% Parse tmp.key for i = 1:num
[vector, count] = fscanf(g, '%f %f %f %f', [1 4]); %row col scale ori
if count ~= 4
error('Invalid keypoint file format'); end
locs(i, :) = vector(1, :);
[descrip, count] = fscanf(g, '%d', [1 len]); if (count ~= 128)
error('Invalid keypoint file value.'); end
% Normalize each input vector to unit length descrip = descrip / sqrt(sum(descrip.^2)); descriptors(i, :) = descrip(1, :); end
fclose(g);
正在阅读:
sift算法的MATLAB程序01-31
DIY 业余卫星自动追踪云台 - 图文09-09
长方体、正方体应用题专项训练03-18
GMAT语法练习套装题(一)12-07
人教版英语选修六课文原文07-26
care about, care for和care to的区别08-14
2022-2025年中国航空货运行业调研及全域营销战略研究报告04-08
回首2016,展望201602-10
机关党建工作要点2021年度08-17
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 算法
- 程序
- MATLAB
- sift
- 财经系关于2010级毕业(论文)设计的通知
- 永安镇卫生院预防艾滋病实施细则
- 运用马克思主义的价值观,分析你对人生价值观的理解
- 小学六年级质量监测分析报告
- 体育英语艺术节开闭幕式新闻稿(1) - 图文
- 冀教版一年级数学上册第二单元测试卷及答案小学数学试题 - 图文
- 中级财务会计复习题
- 小学语文沪教版四年级上册第四单元第19课《观潮》教师招聘面试试讲教案资格证面试试讲教案模板
- 北京电网继电保护及故障信息系统主-子站通信规范1
- 北京市绿化条例
- 信息技术科《刷子工具》教学设计
- 2017年度行政事业单位内部控制报告 - 图文
- 人教版高中数学必修三 第二章 统计“直线的回归方程”教学设计
- PJ3系统医院端门诊选点业务操作指引 - 图文
- 体检中心突发医疗纠纷应急预案
- 数控车技能测试题库
- 2016郑州专业技术人员继续教育考试试题和答案可查找和复制
- 供电公司领导在春节慰问座谈会上的讲话
- 实验一 三坐标测量仪数据测量实验1 - 图文
- 2018年高考英语江苏专用考前三个月文档:专题四 任务型阅读 第三步 模拟演练(二) Word版含答案