An error occurred using: coder.internal.errorIf The values of TEMPLATE cannot all be equal.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
global str2num;
global med_u_sub;
global med_v_sub;
global x_min;
global x_max;
global y_min;
global y_max;
a= str2num{1,1};
b= str2num{1,2};
imagea = imread(a);
imageb = imread(b);
interrogationarea = app.windowsizeEditField.Value;
xmin = x_min + interrogationarea/2+1; % 33
xmax = x_max - (interrogationarea/2+1); % 3840-(64/2+1)=3807 . (732)
ymin = y_min + interrogationarea/2+1 ; %33
ymax = y_max - (interrogationarea/2+1); % 2160-(64/2+1)=2127 . (991)
imagea=padarray(imagea,[ceil(interrogationarea/2) ceil(interrogationarea/2)], min(min(imagea)));
imageb=padarray(imageb,[ceil(interrogationarea/2) ceil(interrogationarea/2)], min(min(imageb)));
clear u v
jj=0;
ii=0;
step = 0.5*interrogationarea;
if (rem(interrogationarea,2) == 0) %for the subpixel displacement measurement
SubPixOffset=1;
else
SubPixOffset=0.5;
end
for J=xmin:step:xmax
jj=1+jj;
ii=1;
for I=ymin:step:ymax
ii=1+ii;
test_ima=imagea(J:J+interrogationarea-1, I:I+interrogationarea-1);
test_imb=imageb(ceil(J-0.5*interrogationarea):ceil(J+1.5*interrogationarea-1), ceil(I-interrogationarea/2):ceil(I+1.5*interrogationarea-1));
test_ima=test_ima-mean(mean(test_ima)); %64*64->1*64->1*1
test_imb=test_imb-mean(mean(test_imb));
correlation = normxcorr2(test_ima,test_imb);
%An error occurred using: coder.internal.errorIf The values of TEMPLATE cannot all be equal.
%I don't understand this part
[ypeak xpeak] = find(correlation==max(correlation(:)));
centerx = ceil(size(correlation,1)/2);
centery = ceil(size(correlation,2)/2);
u(jj,ii)= max(xpeak) - centerx-SubPixOffset;
v(jj,ii)= max(ypeak) - centery-SubPixOffset;
[vector] = SUBPIX2DGAUSS(correlation, interrogationarea, xpeak, ypeak, SubPixOffset);
u_sub(jj,ii)= sqrt(vector(1)*conj(vector(1))) - centerx;
v_sub(jj,ii)= sqrt(vector(2)*conj(vector(2))) - centery;
end
end
0 commentaires
Réponses (1)
Shivam
le 16 Oct 2023
Hi KiBaek,
It is my understanding that you are getting an error while using the function 'normxcorr2', which is used to compute the normalized cross-correlation of two matrices.
As per the documentation for 'normxcorr2', you can compute the normalized cross-correlation of the matrices' template' and 'A' as:
C = normxcorr2(template, A);
where the values of 'template' cannot all be equal. You can check the 'test_ima' matrix for the error.
You can refer to the following documentation to know more about the error and the use of the 'normxcorr2' function: https://www.mathworks.com/help/releases/R2023a/images/ref/normxcorr2.html
I hope this helps in resolving the error.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!