moving the center of an image from point to another?
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (2)
Image Analyst
am 29 Jan. 2012
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 Kommentare
mmm ssss
am 29 Jan. 2012
Image Analyst
am 29 Jan. 2012
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
am 29 Jan. 2012
Image Analyst
am 29 Jan. 2012
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
am 29 Jan. 2012
Image Analyst
am 29 Jan. 2012
Try my demo code I just submitted here.
mmm ssss
am 29 Jan. 2012
mmm ssss
am 29 Jan. 2012
Kategorien
Mehr zu Morphological Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!