loading请求处理中...
10大优享服务
62项会员特权

matlab程序修改:显示X2没有定义,如何修改?

问题补充:function [IP]= masaic(image1,image2,X1,X2,Y1,Y2,num)
image1=imread('C:UserswenjingDesktop课设图片left.jpg');%读入left图像给image1
image2=imread('C:UserswenjingDesktop课设图片right.jpg');%读入right图像给image2

I1=double(image1);
[h1 w1 d1]=size(I1);
I2=double(image2);
[h2 w2 d2]=size(I2);

% 估计参数向量(t)
Z  = [ X2'  Y2' ; Y2' -X2' ; 1 1 0 0  ; 0 0 1 1 ]';  
xp = [ X1 ; Y1 ];
t  = Z xp; %  
a  = t(1); % = s cos(alpha)
b  = t(2); % = s sin(alpha)
tx = t(3);
ty = t(4);

% 构建变换矩阵(T)
T = [a b tx ; -b a ty ; 0 0 1];

% warp incoming corners to determine the size of the output image (in to out)
cp = T*[ 1 1 w2 w2 ; 1 h2 1 h2 ; 1 1 1 1 ]; 
Xpr = min( [ cp(1,:) 0 ] ) : max( [cp(1,:) w1] ); % min x : max x
Ypr = min( [ cp(2,:) 0 ] ) : max( [cp(2,:) h1] ); % min y : max y
[Xp,Yp] = ndgrid(Xpr,Ypr);
[wp hp] = size(Xp); % = size(Yp)

% do backwards transform (from out to in)
X = T [ Xp(:) Yp(:) ones(wp*hp,1) ]';  % warp

% re-sample pixel values with bilinear interpolation(双线性插值求重叠区域像素值)
clear Ip;
xI = reshape( X(1,:),wp,hp)';
yI = reshape( X(2,:),wp,hp)';
Ip(:,:,1) = interp2(I2(:,:,1), xI, yI, '*bilinear'); % red
Ip(:,:,2) = interp2(I2(:,:,2), xI, yI, '*bilinear'); % green
Ip(:,:,3) = interp2(I2(:,:,3), xI, yI, '*bilinear'); % blue

% offset and copy original image into the warped image(偏移和复制原始图像进入扭曲的形象)
offset =  -round( [ min( [ cp(1,:) 0 ] ) min( [ cp(2,:) 0 ] ) ] );
Ip(1+offset(2):h1+offset(2),1+offset(1):w1+offset(1),:) = double(I1(1:h1,1:w1,:));

% show the result
figure; image(Ip/255);
axis image;
显示X2没有定义,应该怎么修改?
提问者:网路小时工 2回答 浏览次数:1895 提问时间: 2021/12/01 11:48
提问者采纳
masaic是个函数,这是个函数文件,你要在调用这个函数时设定参数,就是包括X2的那些。而不能直接运行这个函数。。

全部回答

问题分类

我 要 回 答 我 要 提 问
问题分类   验证码 换一组