用resize函数即可

imresize -

Resize image

Syntax

B = imresize(A, scale)

B = imresize(A, [mrows ncols])

[Y newmap] = imresize(X, map, scale)

[...] = imresize(..., method)

[...] = imresize(..., parameter, value, ...)

Description

B = imresize(A, scale) returns image B that is scale times the size of A. The input image A can be a grayscale, RGB, or binary image. If scale is between 0 and 1.0, B is smaller than A. If scale is greater than 1.0, B is larger than A.

B = imresize(A, [mrows ncols]) returns image B that has the number of rows and columns specified by [mrows ncols]. Either NUMROWS or NUMCOLS may be NaN, in which case imresize computes the number of rows or columns automatically to preserve the image aspect ratio.

[Y newmap] = imresize(X, map, scale) resizes the indexed image X. scale can either be a numeric scale factor or a vector that specifies the size of the output image ([numrows numcols]). By default, imresize returns a new, optimized colormap (newmap) with the resized image. To return a colormap that is the same as the original colormap, use the 'Colormap' parameter (see below).

[...] = imresize(..., method) resizes the indexed image. method can be (1) a text string that specifies a general interpolation method, (2) a text string that specifies an interpolation kernel, or (3) a two-element cell array that specifies an interpolation kernel.

(1) Text String Specifying Interpolation Method

Method Name        Description

'nearest'

Nearest-neighbor interpolation; the output pixel is assigned the value of the pixel that the point falls within. No other pixels are considered.

'bilinear'

Bilinear interpolation; the output pixel value is a weighted average of pixels in the nearest 2-by-2 neighborhood

'bicubic'

Bicubic interpolation (the default); the output pixel value is a weighted average of pixels in the nearest 4-by-4 neighborhood

(2) Text String Specifying Interpolation Kernel

Kernel Name        Description

'box'        Box-shaped kernel

'triangle'        Triangular kernel (equivalent to 'bilinear')

'cubic'        Cubic kernel (equivalent to 'bicubic')

'lanczos2'        Lanczos-2 kernel

'lanczos3'        Lanczos-3 kernel

(3) Two-element Cell Array Specifying Interpolation Kernel

Form        Description

{f,w}        f is a function handle for a custom interpolation kernel and w is the custom kernel's width.f(x) must be zero outside the interval -w/2 <= x < w/2. Your function handle f may be called with a scalar or a vector input.

[...] = imresize(..., parameter, value, ...) you can control various aspects of the resizing operation by specifying parameter/value pairs with any of the previous syntaxes. The following table lists these parameters.

Parameter        Value

'Antialiasing'        A Boolean value that specifies whether to perform antialiasing when shrinking an image. The default value depends on the interpolation method. If the method is nearest-neighbor ('nearest'), the default is false; for all other interpolation methods, the default is true.

'Colormap'        A text string that specifies whether imresize returns an optimized colormap or the original colormap (Indexed images only). If set to 'original', the output colormap (newmap) is the same as the input colormap (map). If set to 'optimized', imresize returns a new optimized colormap. The default value is 'optimized'.

'Dither'        A Boolean value that specifies whether to perform color dithering (Indexed images only). The default value is true.

'Method'        As described above

'OutputSize'        A two-element vector, [MROWS NCOLS], that specifies the size of the output image. If you specify NaN for one of the values, imresize computes the value of the dimension to preserve the aspect ratio of the original image.

'Scale'        A scalar or two-element vector that specifies the resize scale factors. If you specify a scalar, imresize uses the value as the scale factor for each dimension. If you specify a vector, imresize uses the individual values as the scale factors for the row and column dimensions, respectively.

Remarks

The function imresize changed in version 5.4 (R2007a). Previous versions of the Image Processing Toolbox used a somewhat different algorithm by default. If you need the same results produced by the previous implementation, use the function imresize_old.

For bicubic interpolation, the output image may have some values slightly outside the range of pixel values in the input image. This may also occur for user-specified interpolation kernels.

Class Support

The input image can be numeric or logical and it must be nonsparse. The output image is of the same class as the input image. An input image that is an indexed image can be uint8, uint16, or double.

Examples

Shrink by factor of two using the defaults of bicubic interpolation and antialiasing.

I = imread('rice.png');

J = imresize(I, 0.5);

figure, imshow(I), figure, imshow(J)

Shrink by factor of two using nearest-neighbor interpolation. (This is the fastest method, but it has the lowest quality.)

J2 = imresize(I, 0.5, 'nearest');

Resize an indexed image

[X, map] = imread('trees.tif');

[Y, newmap] = imresize(X, map, 0.5);

imshow(Y, newmap)

Resize an RGB image to have 64 rows. The number of columns is computed automatically.

RGB = imread('peppers.png');

RGB2 = imresize(RGB, [64 NaN]);

See Also

imrotate, imtransform, tformarray

interp2 in the MATLAB Function Reference

matlab批量修改图片的大小_图像处理成统一大小相关推荐

  1. MATLAB批量修改图片名称

    申明:转载请注明出处. 设在"D:\UserDesktop\pic\"目录下有很多张格式为jpg照片,命名不规则,如图. 现在用MATLAB批量修改所有图片的命名格式,改为1.jp ...

  2. 使用Excel和Matlab批量修改图片名称

    目录 批量获取原图片名称 使用Matlab批量获取重命名图片名称 生成批量修改文件名称命令 在创作自己的数据集时,为了方便辨识,往往需要按照一定的格式来对图片进行重命名.但由于数据集图片数量过多,这往 ...

  3. 用matlab批量修改图片名称

    前言:在网上看了一些修改图片名称的代码,发现很多都没有达到预期的结果,所以在这里把我的代码贴出来,仅供大家参考, 也希望帮到大家少走一些弯路. file_path1='G:\VOC2012datase ...

  4. matlab批量修改图片的大小_MATLAB实现批量处理图像图片的两种方法

    基本上有两个方法:一个是将你的图像统一进行一次重命名如:1.jpg,2.jpg等,然后利用for循环依次进行处理即可,如下面的语句:假设你的图像共有20副: str='D:\做差\好的图像\'; %我 ...

  5. 使用matlab批量修改图片分辨率

    项目实践中,找了一组图片用于某设备测试,但该设备要求图片分辨率只有一种格式才能下发.因此使用matlab创建一个应用,将统一文件夹中的所有图片修改成特定分辨率输出. 主要是通过imgresize函数完 ...

  6. background-image属性设置图片尺寸_Matlab | 批量修改图片尺寸及图片灰度化

    介绍: 在情绪认知的心理学实验中,我们从不同的人脸图片库获取实验所需的实验材料.在正式使用之前往往需要对人脸进行预处理,以控制无关变量对实验结果的影响.常见的预处理有将图片修改为统一尺寸.灰度化.本文 ...

  7. 如何用python批量处理图片大小_python批量修改图片大小的方法

    本文实例为大家分享了python批量修改图片大小的具体代码,供大家参考,具体内容如下 引用的模块 from PIL import Image Image的使用 def resize_image(img ...

  8. php图片大小怎么改,如何批量修改图片大小/尺寸

    小编给大伙分享一个小巧实用的批量修改图片大小工具,可以批量修改图片大小尺寸,限制缩放后的图片文件大小,以满足在线照片打印的要求,或便于上传图片到网店商铺以方便您的照片展示.很是实用! 操作灰常简单的哟 ...

  9. 在WORD中批量修改图片大小

    今天在word中批量修改图片时发现了word一个强大的功能,不多说废话,直接附上步骤: 1.首先按一定的顺序将图片插入word当中: 2.点击"视图"----"宏&quo ...

最新文章

  1. Spring Boot 参考指南(运行你的应用程序)
  2. python 的dict的append()?
  3. 大型分布式C++框架《四:netio之请求包中转站 上》
  4. mysql+br_mysql有哪几种索引
  5. C语言高级编程:数组指针与数组
  6. 热插拔服务器电源维修,无需关停系统即可热插拔,TE Connectivity推出滑轨电源连接器...
  7. php加密后无法读取,无法解密的php加密文件
  8. jzoj5986. 【WC2019模拟2019.1.4】立体几何题 (权值线段树)
  9. scala上界_Scala方差,上界和下界
  10. 拓端tecdat|R语言时间序列数据指数平滑法分析交互式动态可视化
  11. FPGA实现的线性反馈移位寄存器LFSR
  12. JAVA解析IP地址
  13. MySQL--- 有哪些“饮鸩止渴”提高性能的方法?
  14. 关于高性能的MIMO技术的实现方法介绍
  15. 胡晓曼:MindSpore 开源运营与治理 | DEV. Together 2021 中国开发者生态峰会
  16. proxmox的安装
  17. 海思屏幕HAL代码解析
  18. 计算机视觉:2.3.1、梯度下降法优化权重矩阵
  19. hadoop进入退出安全模式
  20. Codeforces round #628 C.Ehab and Path-etic MEXs

热门文章

  1. python时间加减秒_Python 日期时间datetime 加一天,减一天,加减一小时一分钟,加减一年...
  2. mysql数据库增量复制_mysql数据库增量备份
  3. adb不是内部命令或外部命令,也不是可运行的程序或批处理文件
  4. 又收到一只瑞星寄来的卡卡狮……汗!
  5. linux内核中input子系统框图
  6. JCMSuite应用-高功率半导体激光器
  7. 详细的web开发部署步骤(在新版配置环境下的自我总结)(内附精美五子棋游戏代码)
  8. Simotion应用与组网之二通讯篇
  9. Springboot 读取模板excel信息内容并发送邮件, 并不是你想想中的那么简单
  10. flask_jsonify 中文乱码(unicode)