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!