You can move the location where the image will be drawn by setting XData
and YData
to imshow
. To center, you define that the position of the image (by default is [0,0]) is [-large / 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;
Demonstration
For the following image:
Andthisfunction:
t=0:0.0001:2*pi;x=50*cos(t);y=50*sin(t);plot(x,y)
Centralizingtheimage,youhave:
To center the function on the image you can simply move the function elements to the center of the image. For example:
For this 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);
What results in: