matlab图像resize,Resize an Image with imresize Function

Specify the Magnification Value

Read an image into the workspace.

I = imread('circuit.tif');

Resize the image, using the imresize function. In this example, you specify a magnification factor. To enlarge an image, specify a magnification factor greater than 1.

J = imresize(I,1.25);

Display the original image next to the enlarged version.

figure

imshowpair(I,J,'montage')

axis off

def20acd0789e2bef613d43dbee21d5a.png

Specify the Size of the Output Image

Resize the image again, this time specifying the desired size of the output image, rather than a magnification value. Pass imresize a vector that contains the number of rows and columns in the output image. If the specified size does not produce the same aspect ratio as the input image, the output image will be distorted. If you specify one of the elements in the vector as NaN, imresize calculates the value for that dimension to preserve the aspect ratio of the image. To perform the resizing required for multi-resolution processing, use impyramid.

K = imresize(I,[100 150]);

figure, imshow(K)

5a566b02851632a4b667173207f69aff.png

Specify the Interpolation Method

Resize the image again, this time specifying the interpolation method. When you enlarge an image, the output image contains more pixels than the original image. imresize uses interpolation to determine the values of these pixels, computing a weighted average of some set of pixels in the vicinity of the pixel location. imresize bases the weightings on the distance each pixel is from the point. By default, imresize uses bicubic interpolation, but you can specify other interpolation methods or interpolation kernels. See the imresize reference page for a complete list. You can also specify your own custom interpolation kernel. This example use bilinear interpolation.

L = imresize(I,1.5,'bilinear');

figure, imshow(L)

edebedda0a4f59df76cdf57b77f23cb0.png

Prevent Aliasing When Shrinking an Image

Resize the image again, this time shrinking the image. When you reduce the size of an image, you lose some of the original pixels because there are fewer pixels in the output image. This can introduce artifacts, such as aliasing. The aliasing that occurs as a result of size reduction normally appears as stair-step patterns (especially in high-contrast images), or as moire (ripple-effect) patterns in the output image. By default, imresize uses antialiasing to limit the impact of aliasing on the output image for all interpolation types except nearest neighbor. To turn off antialiasing, specify the 'Antialiasing' parameter and set the value to false. Even with antialiasing turned on, resizing can introduce artifacts because information is always lost when you reduce the size of an image.

M = imresize(I,.75,'Antialiasing',false);

figure, imshow(M)

858d092e51070b2bd015b56c3423b56c.png

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值