You can move the location where the image will be drawn by setting XData
and YData
in imshow
. To center, you define that the image position (by default is [0.0]) is [-width/2, -height/2].
Example
% carrega a imagem
image=imread('imagem.jpg');
% calcula a metade da altura e largura
image_sz = size(image) * 0.5;
% desenha a imagem deslocada
imshow(image, 'XData', [-image_sz(1) image_sz(1)],'YData', [-image_sz(2) image_sz(2)]);
hold on;
Demontraction
To the following image:
And that function:
t = 0:0.0001:2*pi;
x = 50 * cos(t);
y = 50 * sin(t);
plot(x,y)
Centering the image, you have:
To center the function to the image you can simply move the function elements to the center of the image. For example:
For that function:
t = 0:0.0001:2*pi;
x = 50 * cos(t);
y = 50 * sin(t);
Scroll using:
x = x + image_sz(1);
y = y + image_sz(2);
Which results in:
Plot is the one that needs to be centered not the image.
– Igoto
So just shift the elements of the function. But, I think shift the image more efficiently.
– Lucas Lima
I considered it right because it solved otherwise, but in my case this is not possible I had to move the function as commented.
– Igoto