Main Content

표시된 영상의 x 좌표와 y 좌표 범위 이동하기

이 예제에서는 표시된 영상의 XDataYData 속성을 변경하여 디폴트가 아닌 세계 좌표계를 지정하는 방법을 보여줍니다.

영상을 읽어 들입니다.

I = imread("peppers.png");

내재적 좌표계를 사용하여 영상을 표시하고 ax에 영상 속성을 반환합니다. 축을 켜고 좌표계를 표시합니다.

figure
ax = imshow(I);
title("Image Displayed with Intrinsic Coordinates")
axis on

Figure contains an axes object. The axes object with title Image Displayed with Intrinsic Coordinates contains an object of type image.

x 좌표와 y 좌표의 범위를 확인합니다. 해당 좌표는 axXData 속성과 YData 속성에 저장되어 있습니다. 이 범위는 영상의 차원과 일치합니다.

xrange = ax.XData
xrange = 1×2

     1   512

yrange = ax.YData
yrange = 1×2

     1   384

x 좌표와 y 좌표의 범위를 변경합니다. 이 예제에서는 x 좌표에 100을 더해 영상을 오른쪽으로 이동하고 y 좌표에서 25를 빼서 영상을 위로 이동합니다.

xrangeNew = xrange + 100;
yrangeNew = yrange - 25;

이동한 공간 좌표를 지정하여 영상을 표시합니다.

figure
axNew = imshow(I,"XData",xrangeNew,"YData",yrangeNew);
title("Image Displayed with Nondefault Coordinates");
axis on

Figure contains an axes object. The axes object with title Image Displayed with Nondefault Coordinates contains an object of type image.

새 영상의 x 좌표와 y 좌표의 범위가 xrangeNewyrangeNew로 지정되어 이동한 범위와 일치하는지 확인합니다.

axNew.XData
ans = 1×2

   101   612

axNew.YData
ans = 1×2

   -24   359

관련 항목