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+
- 资源: 2628
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 该存储库将演示如何使用 OpenVINO 运行时 API 部署官方 YOLOv7 预训练模型.zip
- 该存储库包含使用 YOLOv9 对象检测模型和 DeepSORT 算法在视频中进行对象检测和跟踪的代码 .zip
- 论文《YOLO-ReT在边缘 GPU 上实现高精度实时物体检测》的实现.zip
- 让yolov6可以更方便的改变网络结构.zip
- springboot0桂林旅游景点导游平台(代码+数据库+LW)
- mmexportf3d00a398950f9982c0f132475da3f26_1732379945062.jpeg
- mmexport1732556836794.jpg
- 12月考核变动点.wps
- 自定义数据集上的实现.zip
- 891833097559212数据恢复大师_3.8会员版.apk
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功