translate matlab,Translate an Image using imtranslate Function

Translate an Image using imtranslate Function

This example shows how to perform a translation operation on an image using the imtranslate function. A translation operation shifts an image by a specified number of pixels in either the x- or y-direction, or both.

Read an image into the workspace.

I = imread('cameraman.tif');

Display the image. The size of the image is 256-by-256 pixels. By default, imshow displays the image with the upper right corner at (0,0).

figure

imshow(I)

title('Original Image')

2c92aa59fd202ce5e2d085c1b5449184.png

Translate the image, shifting the image by 15 pixels in the x-direction and 25 pixels in the y-direction. Note that, by default, imtranslate displays the translated image within the boundaries (or limits) of the original 256-by-256 image. This results in some of the translated image being clipped.

J = imtranslate(I,[15, 25]);

Display the translated image. The size of the image is 256-by-256 pixels.

figure

imshow(J)

title('Translated Image')

8570aa544cac2b8d7c79672e1129ccff.png

Use the 'OutputView' parameter set to 'full' to prevent clipping the translated image. The size of the new image is 281-by-271 pixels.

K = imtranslate(I,[15, 25],'OutputView','full');

Display the translated image.

figure

imshow(K)

title('Translated Image, Unclipped')

b71249a94f6d060d474156f97de335cc.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值