深圳网站建设 外包合作,哪两个数字域名是做医疗信息网站的,网站开发好要租服务器吗,小公司做网站需要什么条件本文讲述如何利用Matlab Image Processing Toolbox中的图像配准工具实现线性正投影、仿射、投影、多项式、分段线性、局部加权平均配准的过程。实验平台X86 PC#xff0c;Windows XP sp2, Matlab 7.1资源的获取matlab工具的使用方法#xff1a;查看帮助mage Processing Toolb…本文讲述如何利用Matlab Image Processing Toolbox中的图像配准工具实现线性正投影、仿射、投影、多项式、分段线性、局部加权平均配准的过程。实验平台X86 PCWindows XP sp2, Matlab 7.1资源的获取matlab工具的使用方法查看帮助mage Processing Toolbox Users Guide——Image registration。涉及配准方法简介该工具箱提供的配准方法均需手工选择图像间的匹配点对(control points pair)均属于交互配准方法。其基本过程为读入图像数据在两副图像上选择足够匹配点选择配准算法计算变换参数变换图像。假设input image(输入图像)为欲进行配准的图像base image为配准是的参考图像。以下是我参考matlab帮助给出了简介。1线性正投影(linear conformal)最简单。平面映射成平面。当输入输入图像与参考图像对比只是存在全局的平移、旋转、缩放或其三者组合的差别时(正方形仍对应正方形)选择此配准方法。此方法至少需要2对匹配点。2仿射(affine)将平行线转换成平行线。当输入图像形状存在切变现象(正方形对应平行四边形)选此法。至少需3对匹配点。3投影(projective)将直线映射成直线。如果输入图像呈现倾斜翘起现象选此法。至少需4对匹配点。4多项式(polynomial)将直线映射成曲线。如果输入图像出现不规则曲变采用此法。Matlab中提供有2、3、4次幂的实现分别至少需要61010对匹配点。5分段线性(piecewise linear)如果输入图像的各个局部之间的退化模式明显不一样选此法。至少需要4对匹配点。6局部加权平均(local weighted mean)与分段线性一致但效果较之好。至少需要6对(推荐12对)匹配点。实验步骤1读取图像数据。因为源图像以矩阵形式存在一个二进制的文件里用fread可将其读取到变量矩阵中。将读取文件编制成一个子函数(RTIread.m)源代码如下function imMatrixRTIread(FILENAME,SIZE)%RTIreadRead the image matrix from binary Registration Test Image file.%imMatrixRTIread(FILENAME,SIZE) opens the file FILENAME, and reads the%number of elements specified by SIZE.%%FILENAME is a string containing the name of the file to be opened.%Valid entries for SIZE are:%Nread N elements into a column vector.%infread to the end of the file.%[M,N]read elements to fill an M-by-N matrix, in column order.%N can be inf, but M cant.%%It returns the image matrix.fidfopen(FILENAME,r);imMatrixfread(fid,SIZE,uint8uint8);fclose(fid);%image(imMatrix);这里我们选取了两张600×600的图片文件名为“casitas84”和“casitas86”。运行以下代码读取图像矩阵% 1. Read the images into the MATLABworkspace.baseRTIread(casitas84,[600,600]);inputRTIread(casitas86,[600,600]);2选取匹配点(control points)。根据预定的配准方法选定足够的匹配点对。运行下列代码% 2.Specify control point pairs n the images andsave.cpselect(input,base);%pleaseselect 15 points for test.出现GUI界面。操作很简单只需注意选点要均匀布开以增加其代表性。选定完毕File- Save Points toWorkspace将数据保存到工作区中。Workspace立刻多出两个N×2的数组(其中N为选定的匹配点对数)分别为input_points和base_points如input_points 119.5185193.5926168.9012242.9753105.9383140.5062459.0247131.8642313.3457257.7901292.3580165.1975276.308633.0988283.7160380.012376.3086297.2963135.567983.7160360.2593313.345794.8272446.679070.1358354.0864181.2469361.4938381.2469460.2593252.8519433.09883利用十字相关法调整选定了的匹配点。这步可选。运行代码% 3.Fine-tune the control points usingcross-correlation.input_points_corr cpcorr(input_points,base_points,input,base); %optimism thepointsinput_points_corr为优化后在输入图片的对应匹配点。4计算变换公式的参数。利用cp2tform选定变换类型(即配准方法)计算变换参数。以下只需选定一种即可。% 4.Specify the type of transformation to be usedand infer its parameters% (1) not Fine-tune pointsTlinear cp2tform(input_points,base_points,linear conformal);Taffine cp2tform(input_points,base_points,affine);Tprojective cp2tform(input_points,base_points,projective);Tpolynomial2 cp2tform(input_points,base_points,polynomial,2);Tpolynomial3 cp2tform(input_points,base_points,polynomial,3);Tpolynomial4 cp2tform(input_points,base_points,polynomial,4);Tpiecewise cp2tform(input_points,base_points,piecewise linear);Tlwm cp2tform(input_points,base_points,lwm);% (2)Fine-tune pointsfTlinear cp2tform(input_points_corr,base_points,linearconformal);fTaffine cp2tform(input_points_corr,base_points,affine);fTprojective cp2tform(input_points_corr,base_points,projective);fTpolynomial2 cp2tform(input_points_corr,base_points,polynomial,2);fTpolynomial3 cp2tform(input_points_corr,base_points,polynomial,3);fTpolynomial4 cp2tform(input_points_corr,base_points,polynomial,4);fTpiecewise cp2tform(input_points_corr,base_points,piecewiselinear);fTlwm cp2tform(input_points_corr,base_points,lwm);诸如Tlinear的变量为一个称为TFORM的数据结构尚没做仔细研究Tlinear ndims_in:2ndims_out:2forward_fcn:fwd_affineinverse_fcn:inv_affinetdata:[1x1 struct]5变换图像。% 5.Transform the unregistered image to bring itinto alignment.title(image registration polynomialmethod);subplot(2,2,1);imshow(base);title(Base image);subplot(2,2,2);imshow(input);title(Input image);subplot(2,2,3);imshow(imtransform(input,Tpolynomial2));title(registered image);subplot(2,2,4);imshow(imtransform(input,fTpolynomial2));title(registered image(fine-tunepoints));结果如下总结1image和imshow区别。前者视baseinput此类二维图片矩阵为索引图像在系统的index库中选取颜色。2选择适当的方法来建立转换参数并非算法越复杂越好应参考成像因素(退化因素)。3尚没有看出十字相关法的好处。4.利用cpselect选择匹配点cpselect可以返回一个GUI句柄。欲实现如下功能当打开cpselect GUI时m文件程序暂停运行关闭之后继续执行。因为对GUI编程不懂 使用了waitfor,pause函数都没法实现。尝试中……