how to find coordinate of a puzzle piece?

조회 수: 1 (최근 30일)
Tiodong Nongni Gilles Patrick
Tiodong Nongni Gilles Patrick 2021년 1월 16일
I try to determine the coordinates of a puzzle piece on the original image using the normxcorr2 function. Then I draw a rectangle on the correspondence of the two elements. Unfortunately, I notice that the coordinates that this match has given me are not good. Could someone have an idea how to improve the use of this feature and get some better results.
The puzzle piece has the name "cpiece" and the original picture has the name "bild"
cpiece = im2gray(imread('cpiece1.jpg'));
bild = im2gray(imread('original.jpg'));
montage({bild,cpiece})
c = normxcorr2(cpiece,bild);
surf(c)
shading flat
[ypeak,xpeak] = find(c==max(c(:)));
yoffSet = ypeak-size(cpiece,1);
xoffSet = xpeak-size(cpiece,2);
imshow(bild)
drawrectangle(gca,'Position',[xoffSet,yoffSet,size(cpiece,2),size(cpiece,1)],'FaceAlpha',0);

답변 (1개)

Image Analyst
Image Analyst 2021년 1월 16일
See my demo and try to adapt it.
  댓글 수: 1
Tiodong Nongni Gilles Patrick
Tiodong Nongni Gilles Patrick 2021년 1월 16일
I saw your demo and it is not very different from my code. The important part with normxcross fonction, max fonction and calculating of the offset value are the same. that is why I got the same result. the coordinate that the match give, are still not correct.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Filter Banks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by