function [numGoodMatches,numBadMatches,precision,accuracy100] = evaluate_correspondence(imgA, imgB, ground_truth_correspondence_file, scale_factor, x1_est, y1_est, x2_est, y2_est, vis)
x1_est = x1_est ./ scale_factor;
y1_est = y1_est ./ scale_factor;
x2_est = x2_est ./ scale_factor;
y2_est = y2_est ./ scale_factor;
good_matches = zeros(length(x1_est),1); %indicator vector
% Loads `ground truth' positions x1, y1, x2, y2
load(ground_truth_correspondence_file)
%%%%%%%%%%%%%%%%%%%%%%
% Uniqueness test
%
x1_est_tmp = x1_est;
y1_est_tmp = y1_est;
x2_est_tmp = x2_est;
y2_est_tmp = y2_est;
uniquenessDist = 5;
% For each ground truth point
numPreMerge = length(x1_est);
for i=1:length(x1)
% Compute distance of each estimated point to
% the ground truth point
x_dists = x1(i) - x1_est_tmp;
y_dists = y1(i) - y1_est_tmp;
dists = sqrt( x_dists.^2 + y_dists.^2 );
toMerge = dists < uniquenessDist;
if sum(toMerge) > 1
avgX1 = mean( x1_est_tmp( toMerge ) );
avgY1 = mean( y1_est_tmp( toMerge ) );
avgX2 = mean( x2_est_tmp( toMerge ) );
avgY2 = mean( y2_est_tmp( toMerge ) );
x1_est_tmp( toMerge ) = [];
y1_est_tmp( toMerge ) = [];
x2_est_tmp( toMerge ) = [];
y2_est_tmp( toMerge ) = [];
% Add back point
x1_est_tmp(end+1) = avgX1;
y1_est_tmp(end+1) = avgY1;
x2_est_tmp(end+1) = avgX2;
y2_est_tmp(end+1) = avgY2;
end
end
x1_est = x1_est_tmp;
y1_est = y1_est_tmp;
x2_est = x2_est_tmp;
y2_est = y2_est_tmp;
numPostMerge = length(x1_est);
%
% Uniqueness test end
%%%%%%%%%%%%%%%%%%%%%%
if vis
figure;
Height = max(size(imgA,1),size(imgB,1));
Width = size(imgA,2)+size(imgB,2);
numColors = size(imgA, 3);
newImg = zeros(Height, Width,numColors);
newImg(1:size(imgA,1),1:size(imgA,2),:) = imgA;
newImg(1:size(imgB,1),1+size(imgA,2):end,:) = imgB;
imshow(newImg, 'Border', 'tight')
shiftX = size(imgA,2);
hold on;
end
% Distance test
for i = 1:length(x1_est)
fprintf('( %4.0f, %4.0f) to ( %4.0f, %4.0f)', x1_est(i), y1_est(i), x2_est(i), y2_est(i));
% For each x1_est, find nearest ground truth point in x1
x_dists = x1_est(i) - x1;
y_dists = y1_est(i) - y1;
dists = sqrt( x_dists.^2 + y_dists.^2 );
[dists, best_matches] = sort(dists);
current_offset = [x1_est(i) - x2_est(i), y1_est(i) - y2_est(i)];
most_similar_offset = [x1(best_matches(1)) - x2(best_matches(1)), y1(best_matches(1)) - y2(best_matches(1))];
match_dist = sqrt( sum((current_offset - most_similar_offset).^2));
fprintf(' g.t. point %4.0f px. Match error %4.0f px.', dists(1), match_dist);
if(dists(1) > 150 || match_dist > 40)
good_matches(i) = 0;
edgeColor = [1 0 0];
fprintf(' incorrect\n');
else
good_matches(i) = 1;
edgeColor = [0 1 0];
fprintf(' correct\n');
end
if vis
cur_color = rand(1,3);
plot(x1_est(i)*scale_factor,y1_est(i)*scale_factor, 'o', 'LineWidth',2, 'MarkerEdgeColor',edgeColor,...
'MarkerFaceColor', cur_color, 'MarkerSize',10)
plot(x2_est(i)*scale_factor+shiftX,y2_est(i)*scale_factor, 'o', 'LineWidth',2, 'MarkerEdgeColor',edgeColor,...
'MarkerFaceColor', cur_color, 'MarkerSize',10)
end
end
if vis
hold off;
end
title("x");
numGoodMatches = sum(good_matches);
numBadMatches = length(x1_est) - sum(good_matches);
precision = (sum(good_matches) / length(x1_est)) * 100;
accuracy100 = min(sum(good_matches),100); % / 100) * 100; % If we were testing more than the top 100, then this would be important.
fprintf('Uniqueness: Pre-merge: %d Post-merge: %d\n', numPreMerge, numPostMerge );
fprintf('%d total good matches, %d total bad matches.\n', numGoodMatches, numBadMatches)
fprintf(' %.2f%% precision\n', precision);
fprintf(' %.2f%% accuracy (top 100)\n', accuracy100);
% Visualize and save the result
if vis
fprintf('Saving visualization to eval.png\n')
saveas( gcf, 'eval.png' );
end
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1.版本:matlab2021a,我录制了仿真操作录像,可以跟着操作出仿真结果 2.领域:图像配准算法 3.内容:基于harris和sift特征提取的图像配准算法matlab仿真+仿真录像 4.适合人群:本,硕等教研学习使用
资源推荐
资源详情
资源评论
收起资源包目录
基于harris和sift特征提取的图像配准算法matlab仿真.rar (27个子文件)
基于harris和sift特征提取的图像配准算法matlab仿真
data
MountRushmore
9021235130_7c2acd9554_o.jpg 1.54MB
9318872612_a255c874fb_o.jpg 1.66MB
9021235130_7c2acd9554_o_to_9318872612_a255c874fb_o.mat 4KB
NotreDame
921919841_a30df938f2_o.jpg 926KB
4191453057_c86028ce1f_o.jpg 692KB
921919841_a30df938f2_o_to_4191453057_c86028ce1f_o.mat 4KB
EpiscopalGaudi
4386465943_8cf9776378_o_to_3743214471_1b5bbfda98_o.mat 4KB
4386465943_8cf9776378_o.jpg 310KB
3743214471_1b5bbfda98_o.jpg 1.65MB
untitled22.jpg 66KB
untitled44.jpg 133KB
matlab
eval.png 1.93MB
func
cheat_interest_points.m 268B
evaluate_correspondence.m 4KB
proj2_averageAccuracy.m 3KB
get_interest_points.m 2KB
collect_ground_truth_corr.m 1KB
show_ground_truth_corr.m 939B
show_correspondence.m 1KB
get_features.m 2KB
compute_correspondences.m 566B
match_features.m 1KB
Runme.m 2KB
vis_arrows.png 1.8MB
untitled55.jpg 125KB
操作录像0034.avi 10.94MB
untitled11.jpg 76KB
共 27 条
- 1
资源评论
- yueyuanyuan0062023-02-23感谢大佬分享的资源给了我灵感,果断支持!感谢分享~
- m0_575820592023-01-17支持这个资源,内容详细,主要是能解决当下的问题,感谢大佬分享~
- 索克萨尔_2024-05-27资源使用价值高,内容详实,给了我很多新想法,感谢大佬分享~
- 2301_771127302023-04-13感谢大佬,让我及时解决了当下的问题,解燃眉之急,必须支持!
fpga和matlab
- 粉丝: 17w+
- 资源: 2624
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 通过python实现原型模式(Prototype Pattern).rar
- xiefrnsdklmkds
- 基于PyQt5+pytorch的在线疲劳检测系统项目源码+文档说明(Python毕业设计)
- Excel表格拆分工具.exe
- Python毕业设计基于PyQt5+pytorch的在线疲劳检测系统项目源码+文档说明
- 基于Unity开发的消消乐小游戏源代码(毕业设计和大作业适用).zip
- 基于hadoop和hbase的电商交易记录的简单分析项目源码+文档说明.zip
- Vue 3前端框架核心特性详解及其应用
- F1C100s_with_Keil_RTX4_emWin5-嵌入式开发资源
- gear-lib-嵌入式开发资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功