【图像配准】基于matlab互信息图像配准【含Matlab源码 1210期】
2021/8/11 12:36:30
本文主要是介绍【图像配准】基于matlab互信息图像配准【含Matlab源码 1210期】,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、简介
基于matlab互信息图像配准
二、部分源代码
close all clear all tic x0=[50; 50; -15; 0.5]; % Initial points, [X, Y, angle, scaling] % Select them as close to the matching points as possible % by guessing; otherwize, it will fail. [x, fval]=fminsearch(@image_registr_MI,x0) % Optimization using 'fminsearch' % % Display % load image IM1=double(IM1); IM2=double(IM2); IM2=imresize(IM2, x(4), 'bilinear'); J=imrotate(double(IM2), x(3),'bilinear'); %rotated cropped IMAGE2 function f=image_registr_MI(x) load image IM1=double(IM1); IM2=double(IM2); IM2=imresize(IM2, x(4), 'bilinear'); J=imrotate(double(IM2), x(3),'bilinear'); %rotated cropped IMAGE2 if n1>n3-x(1)/2 f=1000; message=strvcat('The scaling factor is too small.', 'Press Ctrl+C to stop.',... 'Increase x0(4) and restart.'); disp('Press Ctrl+C to stop.') Errordlg(message) pause; else if x(1)>n3-n1 x(1)=n3-n1-1; IM1(1:n1, 1:n2)=255; end if x(2)>n4-n2 x(2)=n4-n2-1; IM1(1:n1, 1:n2)=255; end if x(1)<0 x(1)=0; IM1(1:n1, 1:n2)=255; end if x(2)<0 x(2)=0; IM1(1:n1, 1:n2)=255; end xt=1:n1; yt=1:n2; xx=round(xt+x(1)); yy=round(yt+x(2)); IM2=round(J(xx, yy)); % selecting part of IMAGE2 matching the size of IMAHE1 rows=size(IM1,1); cols=size(IM2,2); N=256; h=zeros(N,N); for ii=1:rows; % col for jj=1:cols; % rows h(IM1(ii,jj)+1,IM2(ii,jj)+1)= h(IM1(ii,jj)+1,IM2(ii,jj)+1)+1; end end [r,c] = size(h); b= h./(r*c); % normalized joint histogram y_marg=sum(b); %sum of the rows of normalized joint histogram x_marg=sum(b');%sum of columns of normalized joint histogran Hy=0; for i=1:c; % col if( y_marg(i)==0 ) %do nothing else Hy = Hy + -(y_marg(i)*(log2(y_marg(i)))); %marginal entropy for image 1 end end Hx=0; for i=1:r; %rows if( x_marg(i)==0 ) %do nothing else Hx = Hx + -(x_marg(i)*(log2(x_marg(i)))); %marginal entropy for image 2 end end h_xy = -sum(sum(b.*(log2(b+(b==0))))); % joint entropy f=-(Hx+Hy-h_xy);% Mutual information %x end
三、运行结果
四、备注
版本:2014a
这篇关于【图像配准】基于matlab互信息图像配准【含Matlab源码 1210期】的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南