moving the center of an image from point to another?
이전 댓글 표시
Hi All
i have this image
i want to moving it to the center of the whole figure , how this can be done in matlab i.e how can i raise this image to the center of the whole figure.
for example the first center point coordinates is 160 173 and the second center point coordinates is 160 121
how can i moving the center from first point to the second point?
i tried this code
y=imread('.......bmp');
[r c]=size(y);
for i=0:1:r
for j=1:1:c
y(i,j)=y(i,j+50);
end
end
imshow(y);
but the result was this error:
??? Attempted to access y(0,52); index must be a positive integer or logical.
any help? my regards
채택된 답변
추가 답변 (2개)
Image Analyst
2012년 1월 29일
Is zero a positive integer? No. Indexing starts at 1 in MATLAB. Anyway, that won't move it. That's more like a copy and paste rather than a cut and paste. Try circshift
out = circshift(in, [-50, 0]);
댓글 수: 8
mmm ssss
2012년 1월 29일
Image Analyst
2012년 1월 29일
I don't understand what the "error" is. It shifted the images up by 50 pixels. That is what you said you wanted to do. What's the problem? Why do you want to shift the image anyway? Anything you want to do can be done on the unshifted image.
mmm ssss
2012년 1월 29일
Image Analyst
2012년 1월 29일
Not sure what the problem is. Is it that you don't know how to figure out the "50" - the amount to shift the image?
mmm ssss
2012년 1월 29일
Image Analyst
2012년 1월 29일
Try my demo code I just submitted here.
mmm ssss
2012년 1월 29일
mmm ssss
2012년 1월 29일
카테고리
도움말 센터 및 File Exchange에서 Morphological Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!