用matlab图像配准中出现Subscript indices must either be real positive integers or logicals是什么题I=imread('lily.jpg');lily=rgb2gray(I);M=imread('flowers.jpg');flowers=rgb2gray(M);%选择图像的配准区域imshow(lily)figure,imshow(flowe

来源:学生作业帮助网 编辑:作业帮 时间:2024/12/01 09:56:11
用matlab图像配准中出现Subscript indices must either be real positive integers or logicals是什么题I=imread('lily.jpg');lily=rgb2gray(I);M=imread('flowers.jpg');flowers=rgb2gray(M);%选择图像的配准区域imshow(lily)figure,imshow(flowe
xVSVW5 ƙNGqHH G*kXmE`in}Hȹ|;9^&I}<*q6w|[E~ }c*($^T !NWb86DA.I2$|̪wK @aj03+2R4Jlz zE,G7@'?K xp'0Ka|W$L&DPo73\y&i'5~ _tpC+$dIBʌnx}^g:nS.o9T$fVztA,?v& 4GzuK*ը6>u6BLR I>&@i?uю\ B~16' gV;VTOX\VM !U4>(6(S!NeD}K4̇Q2q%k"S) 6=htYD8ΆudtuA-<!G⓶s{6W<\SZ/,W}hN\O2V!K6SK'+1 epPY͖K+R0i[4!iG/s?8!ByY|<,+HBN2lծj,mAMqM7Nq=' 23{_Ssx" Pr6_kKơ8P$L![\&ΓfqR@hr~hg+30&@HL`8]w+vGgbUAsM_(F%o} ^D&l:GM$JmF۬WM_Ԗ*F66ub1𝍏p"$wnT۝~Ck rZwɗΩ޼!W@#pZCEēv3NPk nS³"MLjcѸ9@hn!0vi-Iyhj}|eUAPq7ݡ6WzV;u# 5,#toڼqueZ+Hj1 W|7մ9 .,Һ^3Jj`k>-mEzUQ$Rgo%\E#D"3` t%FED7 `'`=m/<`xݯF_O=v;21"lro/!

用matlab图像配准中出现Subscript indices must either be real positive integers or logicals是什么题I=imread('lily.jpg');lily=rgb2gray(I);M=imread('flowers.jpg');flowers=rgb2gray(M);%选择图像的配准区域imshow(lily)figure,imshow(flowe
用matlab图像配准中出现Subscript indices must either be real positive integers or logicals是什么题
I=imread('lily.jpg');
lily=rgb2gray(I);
M=imread('flowers.jpg');
flowers=rgb2gray(M);
%选择图像的配准区域
imshow(lily)
figure,imshow(flowers)
rect_lily=[50 121 200 120];
rect_flowers=[50 0 428 129];
sub_lily=imcrop(lily,rect_lily);
sub_flowers=imcrop(flowers,rect_flowers);
%计算两幅图的互相关
c=normxcorr2(sub_lily(:,:,1),sub_flowers(:,:,1));
figure,surf(c),shading flat
%根据互相关计算两幅图像的偏差
[max_c,imax]=max(abs(c(:)));
[ypeak,xpeak]=ind2sub(size(c),imax(1));
corr_offset=[(xpeak-size(sub_lily,2))
(ypeak-size(sub_lily,1))];
rect_offset=[(rect_flowers(1)-rect_lily(1))
(rect_flowers(2)-rect_lily(2))];
offset=corr_offset+rect_offset;
xoffset=offset(1);
yoffset=offset(2);
%从标准图像中提取待配准图像
xbegin=xoffset+1;
xend=xoffset+size(lily,2);
ybegin=yoffset+1;
yend=yoffset+size(lily,1);
extracted_lily=flowers(ybegin:yend,xbegin:xend,:);
if isequal(lily,extracted_lily)
disp('lily.jpg was extracted from flowers.jpg')
end
%修正待配图像
recovered_lily=uint8(zeros(size(flowers)));
recovered_lily(ybegin:yend,xbegin:xend,:)=lily;
figure,imshow(recovered_lily)
%将修正待配图像和标准图像融合
[m,n,p]=size(flowers);
mask=ones(m,n);
i=find(recovered_lily(:,:,1)= =0);
mask(i)=2;
figure,imshow(flowers(:,:,1)) %仅显示红色的花
hold on
h=imshow(recovered_lily); %覆盖recovered_lily图像
set(h,'AlphaData',mask)

用matlab图像配准中出现Subscript indices must either be real positive integers or logicals是什么题I=imread('lily.jpg');lily=rgb2gray(I);M=imread('flowers.jpg');flowers=rgb2gray(M);%选择图像的配准区域imshow(lily)figure,imshow(flowe
Subscript indices must either be real positive integers or logicals
中文解释:下标索引必须是正整数类型或者逻辑类型
出错原因:在访问矩阵(包括向量、二维矩阵、多维数组,下同)的过程中,下标索引要么从 0 开始,要么出现了负数.注:matlab 的语法规定矩阵的索引从 1 开始,这与 C 等编程语言的习惯不一样.
解决办法:自己调试一下程序,把下标为 0 或者负数的地方修正.
另,我运行上述两句时是正确的,且得到了结果.
>> p=[1 -8 6 -30];
>> r=roots(p)
r =
7.7260
0.1370 + 1.9658i
0.1370 - 1.9658i
>>