Problem about "normxcorr2"
조회 수: 8 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2017년 9월 17일
Your code
I = im2double(dicomread('I.dcm'), 'frames',1 ));
is not right. You need
I = im2double(dicomread('I.dcm', 'frames', 1 ));
답변 (1개)
Walter Roberson
2017년 9월 15일
편집: Walter Roberson
2017년 9월 15일
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
Image Analyst
2017년 9월 17일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!