• 大小: 1.32MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-11
  • 语言: 其他
  • 标签: 配准  融合  

资源简介

可见光与红外图像配准融合代码,内附测试图像。可运行。

资源截图

代码片段和文件信息

% Example 3 Affine registration  
% Load images  
clc;
clear all;  
close all;  
%%%发现只有匹配点对遍布在图像中,匹配效果才会变好  

%
I11=(imread(‘11.jpg‘));%红外图像  
I22=(imread(‘22.jpg‘));%可见光图像  
I10=rgb2gray(I11);  
I20=rgb2gray(I22);  
I1=imadjust(I10);  
I2=imadjust(I20);  


I33=(imread(‘111.png‘));%红外图像   
I30=rgb2gray(I33);  
%I31=imadjust(I30);  

% I1=im2double(edge_detection_1(I1));  
% I2=im2double(edge_detection_1(I2));  
I1 = im2double(edge(I1‘canny‘));   
I2 = im2double(edge(I2‘canny‘));  
I30 = im2double(edge(I30‘canny‘));
figureimshow(I1);  
figureimshow(I2);  
figureimshow(I30); 

%

% I11 = imread(‘111-111.jpg‘);
% I22 = imread(‘222-222.jpg‘);
% % I10=rgb2gray(I11);  
% % I20=rgb2gray(I22);

% I1=imadjust(I11);  
% I2=imadjust(I22);

% I1 = im2double(I1);   
% I2 = im2double(I2);


  
% Get the Key Points  
Options.upright=true;  
Options.tresh=0.0001;  
Ipts1=OpenSurf(I1Options);  %1*268  
Ipts2=OpenSurf(I2Options);  


% Put the landmark descriptors in a matrix  
D1 = reshape([Ipts1.descriptor]64[]);  %64*268  
D2 = reshape([Ipts2.descriptor]64[]);  
  
% Find the best matches  
err=zeros(1length(Ipts1));     
cor1=1:length(Ipts1);  
cor2=zeros(1length(Ipts1));  
for i=1:length(Ipts1)  
    distance=sum((D2-repmat(D1(:i)[1 length(Ipts2)])).^21);%用D2的每一列分别去见D1的每一列  
    [err(i)cor2(i)]=min(distance);  
     
end  
  
% Sort matches on vector distance适量距离排序  
[err ind]=sort(err);  
cor1=cor1(ind);  
cor2=cor2(ind);  
  
% Make vectors with the coordinates of the best matches  
Pos1=[[Ipts1(cor1).y]‘[Ipts1(cor1).x]‘];  
Pos2=[[Ipts2(cor2).y]‘[Ipts2(cor2).x]‘];  
Pos1_1=Pos1;  
Pos2_1=Pos2;  
Pos1(:3)=1; Pos2(:3)=1;Pos1_1(:3)=1; Pos2_1(:3)=1;  
Pos1=Pos1(1:20:);  
Pos2=Pos2(1:20:);  
Pos11=zeros(size(Pos1));  
Pos22=zeros(size(Pos2));  

% Calculate affine matrix  
for i=1:20  
     k(i)=Pos2(i2)/(Pos2(i1)-Pos1(i1));  
end  
tic;  
%%  
%自适应确定k的范围  
positive_num=find(k>0);  
negative_num=find(k<0);  
if length(positive_num)>length(negative_num)  
    flag=1 ; 
    num_err=negative_num;  
    num_correct=positive_num;  
else  
    flag=0;  
    num_err=positive_num;  
    num_correct=negative_num;  
end  
k(num_err)=[];  
k_1=round(k);  
k_2=unique(k_1);%求出k_1有哪些数,剔除重复数据  
temp=zeros(length(k_2)2);%第一列存数,第二列存该数的个数%后边还需要对个数排序  
for i=1:length(k_2)  
    temp_num=0;  
    temp(i1)=k_2(i);  
   for j=1:length(k)  
       if temp(i1)==k_1(j)  
          temp_num=temp_num+1;   
       end  
   end  
   temp(i2)=temp_num;  
end  
%temp  
  
[temp1temp1_location]=sort(temp(:2)‘descend‘)  
xu=temp1(2);  
temp=temp(temp1_location)  
k_1=zeros(size(12));  
k_1(1)=temp(1);  
k_1(2)=temp(2);  
k_1=sort(k_1‘descend‘);  
k_11=k_1(11)+0.5;  
k_12=k_1(11)-0.5;  
k_21=k_1(12)-0.5  
k_22=k_1(12)+0.5  
count=0;  
  
for i=1:20  
     k=Pos2(i2)/(Pos2(i1)-Pos1(i1));   %%%%可不可以把数据归一化  
     if

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-12 18:40  1\
     文件        5854  2017-12-21 14:05  1\11.jpg
     文件        6409  2017-12-21 14:06  1\22.jpg
     目录           0  2018-03-12 18:40  1\OpenSURF_version1c\
     文件        3778  2010-09-07 00:27  1\OpenSURF_version1c\OpenSurf.m
     目录           0  2018-03-12 18:40  1\OpenSURF_version1c\SubFunctions\
     文件         603  2010-07-27 04:56  1\OpenSURF_version1c\SubFunctions\FastHessian_BuildDerivative.m
     文件         738  2010-07-30 04:32  1\OpenSURF_version1c\SubFunctions\FastHessian_Responselayer.m
     文件        1699  2010-07-30 00:10  1\OpenSURF_version1c\SubFunctions\FastHessian_buildResponselayer.m
     文件        1877  2010-07-21 00:37  1\OpenSURF_version1c\SubFunctions\FastHessian_buildResponseMap.m
     文件        2353  2010-07-30 23:43  1\OpenSURF_version1c\SubFunctions\FastHessian_getIpoints.m
     文件         455  2010-07-27 04:56  1\OpenSURF_version1c\SubFunctions\FastHessian_getLaplacian.m
     文件         450  2010-07-27 04:56  1\OpenSURF_version1c\SubFunctions\FastHessian_getResponse.m
     文件        2478  2010-07-30 23:02  1\OpenSURF_version1c\SubFunctions\FastHessian_interpolateExtremum.m
     文件        1680  2010-07-30 22:56  1\OpenSURF_version1c\SubFunctions\FastHessian_isExtremum.m
     文件         791  2010-07-29 22:58  1\OpenSURF_version1c\SubFunctions\IntegralImage_BoxIntegral.m
     文件         494  2010-07-30 04:32  1\OpenSURF_version1c\SubFunctions\IntegralImage_HaarX.m
     文件         556  2010-07-30 04:37  1\OpenSURF_version1c\SubFunctions\IntegralImage_HaarY.m
     文件         796  2010-07-29 22:42  1\OpenSURF_version1c\SubFunctions\IntegralImage_IntegralImage.m
     文件        1089  2010-07-30 23:39  1\OpenSURF_version1c\SubFunctions\PaintSURF.m
     文件        1554  2010-07-31 00:39  1\OpenSURF_version1c\SubFunctions\SurfDescriptor_DecribeInterestPoints.m
     文件        3636  2010-07-31 00:40  1\OpenSURF_version1c\SubFunctions\SurfDescriptor_GetDescriptor.m
     文件        2921  2010-07-31 00:07  1\OpenSURF_version1c\SubFunctions\SurfDescriptor_GetOrientation.m
     目录           0  2018-03-12 18:40  1\OpenSURF_version1c\TestImages\
     文件      239755  2010-09-07 00:22  1\OpenSURF_version1c\TestImages\lena1.png
     文件      211716  2010-09-07 00:22  1\OpenSURF_version1c\TestImages\lena2.png
     文件        5296  2010-07-20 05:38  1\OpenSURF_version1c\TestImages\test.png
     文件      123228  2010-07-27 01:06  1\OpenSURF_version1c\TestImages\testc1.png
     文件      122063  2010-07-27 01:06  1\OpenSURF_version1c\TestImages\testc2.png
     目录           0  2018-03-12 18:40  1\OpenSURF_version1c\WarpFunctions\
     文件        9721  2010-09-07 01:04  1\OpenSURF_version1c\WarpFunctions\affine_warp.m
............此处省略5个文件信息

评论

共有 条评论