Problem about "normxcorr2"
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I = im2double(dicomread('I.dcm'), 'frames',1 ));
T=imread('T.jpg');
c = normxcorr2(T,I);
[ypeak, xpeak] = find(c==max(c(:)));
---------------------------------------------------------
This is work I can get the correct ypeak, xpeak.
---------------------------------------------------------
I = im2double(dicomread('I.dcm'), 'frames',1 ));
T=imread('T.jpg');
c = normxcorr2(T,I);
i= 1
while i < 100
I = im2double(dicomread('I.dcm'), 'frames',i+1 ));
i = i+1;
c = normxcorr2(T,I);
[ypeak, xpeak] = find(c==max(c(:)));
End
-------------------------------------------------------------------
This is also work.
-------------------------------------------------------------------
However, when I use ypeak, xpeak to create a new template and use the templates in the loop is not work.
I = im2double(dicomread('I.dcm'), 'frames',1 ));
T=imread('T.jpg');
c = normxcorr2(T,I);
[ypeak, xpeak] = find(c==max(c(:)));
i= 1
while i < 100
I = im2double(dicomread('I.dcm'), 'frames',i+1 ));
i = i+1;
c = normxcorr2(T,I);
[ypeak, xpeak] = find(c==max(c(:)));
T = I(ypeak: ypeak+100,xpeak : xpeak+100,:);
End
It can create new templates, but ypeak, xpeak value is not update.
ypeak= 50;
xpeak= 50;
if I change
T = I(ypeak: ypeak+100,xpeak :xpeak+100,:);
to
T = I(50: 150,50:150,:);
ypeak, xpeak value can be updated.
I don't know why when I use ypeak, xpeak to create a new template normxcorr2 is seem stop working and return only the first value of ypeak, xpeak.
3 comentarios
Walter Roberson
el 17 de Sept. de 2017
Your code
I = im2double(dicomread('I.dcm'), 'frames',1 ));
is not right. You need
I = im2double(dicomread('I.dcm', 'frames', 1 ));
Respuestas (1)
Walter Roberson
el 15 de Sept. de 2017
Editada: Walter Roberson
el 15 de Sept. de 2017
You have
[ypeak, xpeak] = find(c==max(c(:)));
T = I(ypeak: ypeak+100,xpeak : xpeak+100,:);
The only reason to use find comparing the array to its max() is for the case where there could be multiple matches against the max and you want to find all of them. But when that happens then you have problems with the ":" operator.
If you only expect and need a single max value, then
[~, idx] = max(c(:));
[ypeak, xpeak] = ind2sub(size(c), idx);
2 comentarios
Image Analyst
el 17 de Sept. de 2017
You still have the same problem because you're preventing people from helping you.
I asked you to supply the I and T images so we could run the code and try to fix it, but you have not done that, so your problem remains.
The best I can do for you is to just attach my normxcorr2() demo.
Good luck.
Ver también
Categorías
Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!