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!