只筛选nr

编程入门 行业动态 更新时间:2024-10-10 21:32:15

只筛选<a href=https://www.elefans.com/category/jswz/34/1757832.html style=nr"/>

只筛选nr

E:\graduate-experience\version2可重复性测评0930 - 副本\可重复性测评\0827sumerizeCornertest\01Algorithm\gcm

function Result=Comparison_cpda()
close all
clc
tic
Result=[];
for cnt =1:21
cnt
ldpath = sprintf(‘%d.png’,cnt);
f=imread(ldpath);
f=rgb2gray(f);
s = [‘load(’‘’ int2str(cnt) ‘.mat’‘)’];
a=eval(s);
a_first=a.first;
original_corners=GCMDetector(f); %获得原始图片的角点

% figure(1);
% imshow(f);
% hold on;
% plot(a_first(:,2), a_first(:,1),‘ro’,‘MarkerSize’,2,‘MarkerFaceColor’,‘r’);
%
%
% figure(2);
% imshow(f);
% hold on;
% plot(original_corners1(:,2), original_corners1(:,1),‘ro’,‘MarkerSize’,2,‘MarkerFaceColor’,‘r’);
%
% original_corners1= filter_origion(original_corners,a_first)
% figure(3);
% imshow(f);
% hold on;
% plot(original_corners(:,2), original_corners(:,1),‘ro’,‘MarkerSize’,2,‘MarkerFaceColor’,‘r’);

        Ar_a=[];Le_a=[];%% 旋转%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 旋转%rotation transformation,from -90°to 90°,at 10° apart,excluding 0°toppoints=[];Le_a_for_rotation=[];                                 %存放图片旋转后的定位误差Ar_a_for_rotation=[];                                 %存放图片旋转后的平均重复率for angle=0fr=imrotate(f,angle);%[change_corners,toppoints]=rotation_coordinate_change(original_corners,f,fr,angle);[change_afirst,toppoints]=rotation_coordinate_change( a_first,f,fr,angle);[Ar,Le]=calculate(fr,change_corners,change_afirst,toppoints);Ar_a_for_rotation=[Ar_a_for_rotation;Ar];Le_a_for_rotation=[Le_a_for_rotation;Le];endfor angle=-90:10:-10fr=imrotate(f,angle);[change_corners,toppoints]=rotation_coordinate_change(original_corners,f,fr,angle);[change_afirst,toppoints]=rotation_coordinate_change( a_first,f,fr,angle);[Ar,Le]=calculate(fr,change_corners,change_afirst,toppoints);Ar_a_for_rotation=[Ar_a_for_rotation;Ar];Le_a_for_rotation=[Le_a_for_rotation;Le];endfor angle=10:10:90fr=imrotate(f,angle);[change_corners,toppoints]=rotation_coordinate_change(original_corners,f,fr,angle);[change_afirst,toppoints]=rotation_coordinate_change( a_first,f,fr,angle);[Ar,Le]=calculate(fr,change_corners,change_afirst,toppoints);Ar_a_for_rotation=[Ar_a_for_rotation;Ar];Le_a_for_rotation=[Le_a_for_rotation;Le];end  Ar_a_for_rotation=mean(Ar_a_for_rotation);             %平均Le_a_for_rotation=mean(Le_a_for_rotation);Ar_a=[Ar_a;Ar_a_for_rotation];Le_a=[Le_a;Le_a_for_rotation];%% 旋转End%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 旋转End%% 比例%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 比例%%uniform and nonuniform scaling transformation,x from 0.5 to 2.0,at 0.1 apart,y from 0.5 toppoints=[];Ar_a_for_scale=[];Le_a_for_scale=[];for scale_x=0.5:0.1:2.0for scale_y=0.5:0.1:2.0if scale_x~=1 ||scale_y~=1 T = maketform('affine',[scale_x 0 0; 0 scale_y 0; 0 0 1]);fu= imtransform(f,T);a_first_change=nonuniform_coordinate_change(original_corners,scale_x,scale_y);change_afirst=nonuniform_coordinate_change( a_first,scale_x,scale_y);[Ar,Le]=calculate(fu,a_first_change,change_afirst,toppoints);Le_a_for_scale=[Le_a_for_scale;Le];Ar_a_for_scale=[Ar_a_for_scale;Ar];endendendAr_a_for_scale=mean(Ar_a_for_scale);Le_a_for_scale=mean(Le_a_for_scale);Ar_a=[Ar_a;Ar_a_for_scale];Le_a=[Le_a;Le_a_for_scale];%% 比例End%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 比例变换End%% 仿射%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 仿射%combined(affine) transformation,angles range form -30°to -30°;x,y from %0.8 to 1.2,at 0.1 apart,y from 0.8 to 1.2,at 0.1 apart,excluding x=ytoppoints=[]; Le_a_for_affine=[];Ar_a_for_affine=[];angle_array=[-30 -20 -10 10 20 30 ];for i=1:6angle=angle_array(i);for scale_x=0.8:0.1:1.2for scale_y=0.8:0.1:1.2if abs(scale_x-scale_y)>1e-3if scale_x~=1 ||scale_y~=1 T = maketform('affine',[scale_x 0 0; 0 scale_y 0; 0 0 1]);fr=imrotate(f,angle);fu= imtransform(fr,T);[a_first_change1,toppoints]=rotation_coordinate_change(original_corners,f,fr,angle);a_first_change2=nonuniform_coordinate_change(a_first_change1,scale_x,scale_y);[change_afirst1,toppoints]=rotation_coordinate_change(a_first,f,fr,angle);change_afirst2=nonuniform_coordinate_change(change_afirst1,scale_x,scale_y);if isempty(toppoints)==0toppoints=floor(toppoints.*repmat([scale_y scale_x],[size(toppoints,1),1]));end[Ar,Le]=calculate(fu,a_first_change2,change_afirst2,toppoints);Le_a_for_affine=[Le_a_for_affine;Le];Ar_a_for_affine=[Ar_a_for_affine;Ar];endendendendendAr_a_for_affine=mean(Ar_a_for_affine);Le_a_for_affine=mean(Le_a_for_affine);Ar_a=[Ar_a;Ar_a_for_affine];Le_a=[Le_a;Le_a_for_affine];%% 仿射End%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 仿射变换End%% Jpeg%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Jpegtoppoints=[];Le_a_for_compression=[];Ar_a_for_compression=[];for quality_factor=5:5:100imwrite(f,'a_compression.jpg','Quality',quality_factor,'mode','lossy');fc=imread('a_compression.jpg');[Ar,Le]=calculate(fc,original_corners,a_first,toppoints);Le_a_for_compression=[Le_a_for_compression;Le];Ar_a_for_compression=[Ar_a_for_compression;Ar];endAr_a_for_compression=mean(Ar_a_for_compression);Le_a_for_compression=mean(Le_a_for_compression);Ar_a=[Ar_a;Ar_a_for_compression];Le_a=[Le_a;Le_a_for_compression];%% JpegEnd%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% JpegEnd%% 高斯噪声%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 高斯噪声toppoints=[];Le_a_for_noise=[];Ar_a_for_noise=[];for noise=0.005:0.005:0.05fi=imnoise(f,'Gaussian',noise);[Ar,Le]=calculate(fi,original_corners,a_first,toppoints);Le_a_for_noise=[Le_a_for_noise;Le];Ar_a_for_noise=[Ar_a_for_noise;Ar];endAr_a_for_noise=mean(Ar_a_for_noise);Le_a_for_noise=mean(Le_a_for_noise);Ar_a=[Ar_a;Ar_a_for_noise];Le_a=[Le_a;Le_a_for_noise];Ar_a=Ar_aLe_a=Le_aResult=[Result;Ar_a];Result=[Result;Le_a];%% 高斯噪声End%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 高斯噪声End
end % end cnt =1:12
xlswrite('result/ccn_result_gcm1-21.xlsx',Result);
toc

end

%本函数为图片旋转后,GT角点应该也响应旋转
%In:
%corners:Ground Truth为原来角点
%image_or为原始图片
%image_ch为旋转后的图片
%angele为图片旋转后的角度

%Out:
%corners:

function [corners,toppoints]=rotation_coordinate_change(corners,image_or,image_ch,angle)
if isempty(corners)==0
theta=-angle*pi/180;
[cyo,cxo]=size(image_or);
[cy_ro,cx_ro]=size(image_ch);
tp1=[1 1];
tp2=[1 cyo];
tp3=[cxo 1];
tp4=[cxo cyo];
xo=corners(:,2);
yo=corners(:,1);
corners=[tp1;tp2;tp3;tp4;xo yo];
corners_change_axis=corners.repmat([1 -1],[size(corners,1),1])+repmat([-cxo/2 cyo/2],[size(corners,1),1]);
corners_rotate=corners_change_axis
[cos(theta) -sin(theta);sin(theta) cos(theta)];
corners_restore=corners_rotate.*repmat([1 -1],[size(corners_rotate,1),1])+repmat([cx_ro/2 cy_ro/2],[size(corners_rotate,1),1]);
corners_restore=floor(corners_restore);
corners=[corners_restore(:,2) corners_restore(:,1)];
toppoints=corners(1:4,:);
corners=corners(5:size(corners,1)😅;
else
corners=[];
toppoints=[];
end
end
%%%%%%%%%%%%%%%%%检测到的角点和gt比较%%%%%%%%%%%%%%%%%%
function [filtercorners]=filter_origion(corners,cor_first)
original_cor=corners;
size_first=size(cor_first,1);
size_corners=size(corners,1);
% filter_origion_corners=[];
No=size_first;
Nt=size(corners,1);
Nr=0;
Nf=0;
Nm=0;
mark=[];
miss=[];
filtercorners=[];
false_corners=corners;
if isempty(corners)0
for i=1:size_first
compare_first_corner=corners-ones(size_corners,1)*cor_first(i,:);
compare_first_corner=compare_first_corner.^2;
compare_first_corner=compare_first_corner(:,1)+compare_first_corner(:,2);
mark=find(compare_first_corner<=9);
if size(mark,1)0
Nm=Nm+1;
miss=[miss;cor_first(i,:)];
else
filtercorners=[filtercorners;cor_first(i,:)];
corners(find(compare_first_corner
min(compare_first_corner)),:)=0;
false_corners(find(compare_first_corner
min(compare_first_corner)),:)=0;
Nr =Nr+1;
end
end
miss=miss;
false_corners=false_corners;

% filtercorners1=original_cor-false_corners
% indexzero= all(filtercorners1~=0,2)
% indexnozero=find(indexzero)
% filtercorners=[filtercorners;filtercorners1(indexnozero,:)]
Nf=Nt-Nr;
else
Nm=size_first;
Nr=0;
Nf=0;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Ar,Le]=calculate(f,change_corners,change_afirst,toppoints)
[detect_corners]=GCMDetector(f);
detect_corners2=detect_corners;
size_change=size(change_corners,1);
size_detect=size(detect_corners,1);
Nc=size_change;
Nd=size(detect_corners,1);
Nr=0;
Ar=0;
Le=0;
reapeatecorner=[];
% mark=[];
% miss=[];
% false_corners=detect_corners;
%% match first level corners
if isempty(detect_corners)==0

    for i=1:size_changecompare_first_corner=detect_corners-ones(size_detect,1)*change_corners(i,:);compare_first_corner=compare_first_corner.^2;compare_first_corner=compare_first_corner(:,1)+compare_first_corner(:,2);mark=find(compare_first_corner<=18);if size(mark,1)==0
%             Nm=Nm+1;
%             miss=[miss;change_corners(i,:)];

% Nr=0;
% Le=0;
else
detect_corners(find(compare_first_corner==min(compare_first_corner)),:)=0;
reapeatecorner=[reapeatecorner;change_corners(i,:)];
Nr =Nr+1;
Le=Le+min(compare_first_corner);
end
end

%%if isempty(toppoints)==0for i=1:4compare_first_corner=detect_corners2-ones(size_detect,1)*toppoints(i,:);compare_first_corner=compare_first_corner.^2;compare_first_corner=compare_first_corner(:,1)+compare_first_corner(:,2);mark=find(compare_first_corner<=18);if size(mark,1)~=0Nd=Nd-size(mark,1);endendend    
%%
filterreapeatecorner=filter_origion(reapeatecorner,change_afirst);
Nrgt=size(filterreapeatecorner,1);

% Le=sqrt(Le/Nd);
% % Ar=Nr/2*(1/Nc+1/Nd);
% Ar=Nrgt/2*(1/Nc+1/Nd);
if Nd~=0
Le=sqrt(Le/Nd);
else
Le=0;
end

    if Nc==0Ar=Nrgt/2*(1/Nd);elseif Nd==0Ar=Nrgt/2*(1/Nc); elseAr=Nrgt/2*(1/Nc+1/Nd);end
elseLe=0;Ar=0;
end

end

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%change the standard corners’ coordinate when the images transformed with
%%uniform or nonuniform scaling
function [corners]=nonuniform_coordinate_change(corners,scale_x,scale_y)
if isempty(corners)==0
corners=floor(corners.*repmat([scale_y scale_x],[size(corners,1),1]));
else
corners=[];
end
end

更多推荐

只筛选nr

本文发布于:2024-02-25 12:40:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1698994.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:nr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!