Problem about "normxcorr2"
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Walter Roberson
il 17 Set 2017
Your code
I = im2double(dicomread('I.dcm'), 'frames',1 ));
is not right. You need
I = im2double(dicomread('I.dcm', 'frames', 1 ));
Risposte (1)
Walter Roberson
il 15 Set 2017
Modificato: Walter Roberson
il 15 Set 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 Commenti
Image Analyst
il 17 Set 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.
Vedere anche
Categorie
Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!