Resize image resize image

 

Explanation

Examples

B = imresize(A,scale) The image returns  B, it is the  A length and width of the size of the scaled  scale image after times. The input image  A may be a grayscale, RGB, or binary image. If  A there are more than two dimensions,  imresize only adjust the size of the first two dimensions. If  scale in the range [0, 1], the  B ratio of  A small. If  scale greater than 1,  B than the  A larger. By default, imresize the use of bi-cubic interpolation.

Examples

B = imresize(A,[numrows numcols]) Returns an image  B, the number of rows and columns of elements from the two vectors  [numrows numcols] specified.

Examples

[Y,newmap] = imresize(X,map,___) Adjust the index image  X size, which  map is the color associated with the image of FIG. By default, imresize back through the new optimized color map ( newmap) and resized images. To return to the original color map and the same color chart, use  'Colormap' parameters.

Examples

___ = imresize(___,method) Specifies the interpolation method used.

___ = imresize(___,Name,Value) Returns the size of the resized image, wherein  Name,Value various aspects of the control group resize operation.

 

Examples

Collapse

The default interpolation method using the length and width of the reduced image one-half

The image is loaded into the workspace.

I = imread('ngc6543a.jpg');

The length and width of the image reduced one-half.

J = imresize(I, 0.5);

The image resize and display the original image.

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

 
 

Using the nearest neighbor interpolation method will reduce the length and width of one-half

The image is loaded into the workspace.

I = imread('ngc6543a.jpg');

Using the nearest neighbor interpolation method will reduce the length and width of one-half. This is the fastest method, but the worst quality.

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

The image resize and display the original image.

figure 
imshow(I)

figure
imshow(J)

 
 

调整 RGB 图像的大小

将 RGB 图像读取到工作区。

RGB = imread('peppers.png');

将 RGB 图像的大小调整为 64 行。imresize 会自动计算列数。

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

显示原始图像和调整大小后的图像。

figure
imshow(RGB)

figure
imshow(RGB2)

 
 

调整索引图像的大小

将索引图像读取到工作区。

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

将索引图像的长宽缩小二分之一。

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

显示原始图像和调整大小后的图像。

figure
imshow(X,map)

figure
imshow(Y, newmap)

 
 

输入参数

全部折叠

A - 要调整大小的图像
实数非稀疏数值数组或逻辑数组

要调整大小的图像,指定为实数非稀疏数值数组。

数据类型: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

scale - 大小调整因子
实数标量

大小调整因子,指定为实数数值标量。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

[numrows numcols] - 输出图像的行和列维度
由正值组成的二元素数值向量

输出图像的行和列维度,指定为由正值组成的二元素数值向量。numrows 或 numcols 可以为 NaN 值,在这种情况下,imresize 将自动计算行数或列数,以保持图像的纵横比。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

X - 要调整大小的索引图像
实数非稀疏数值数组

要调整大小的索引图像,指定为实数非稀疏数值数组。

示例: [X2, newmap] = imresize(X,map,0.75);

数据类型: double | uint8 | uint16

map - 与索引图像关联的颜色图
m×3 数值数组

与索引图像关联的颜色图,指定为 m×3 数值数组。

数据类型: double

method - 插值方法
'bicubic' (默认) | 字符向量 | 二元素元胞数组

插值方法,指定为字符向量或二元素元胞数组。

当 method 是字符向量时,它标识下表中列出的特定方法或指定的插值核。

方法 说明

'nearest'

最近邻插值;赋给输出像素的值就是其输入点所在像素的值。不考虑其他像素。

'bilinear'

双线性插值;输出像素值是最近 2×2 邻点中的像素的加权平均值

'bicubic'

双三次插值;输出像素值是最近 4×4 邻点中的像素的加权平均值

注意

双三次插值可能生成在原始范围之外的像素值。

插值核 说明
'box' 盒形核
'triangle' 三角形核(等效于 'bilinear'
'cubic' 三次方核(等效于 'bicubic'
'lanczos2' Lanczos-2 核
'lanczos3' Lanczos-3 核

当 method 是二元素元胞数组时,用来定义自定义插值核。元胞数组的形式为 {f,w},其中 f 是自定义插值核的函数句柄,w 是自定义核的宽度。f(x) 在区间 -w/2 <= x < w/2 外的值必须为零。函数句柄 f 可通过标量或向量输入进行调用。对于用户指定的插值核,输出图像可以有一些值稍微超出输入图像中的像素值范围。

数据类型: char | cell

名称-值对组参数

指定可选的、以逗号分隔的 Name,Value 对组参数。Name 为参数名称,Value 为对应的值。Name 必须放在引号中。您可采用任意顺序指定多个名称-值对组参数,如 Name1,Value1,...,NameN,ValueN 所示。

示例: I2 = imresize(I,0.5,'Antialiasing',false);

'Antialiasing' - 缩小图像时消除锯齿
true | false

缩小图像时消除锯齿,以逗号分隔的对组形式指定,该对组由 'Antialiasing' 和逻辑布尔值 true 或 false 组成。默认值取决于插值方法。如果插值方法是最近邻插值 ('nearest'),则默认值为 false。对于其他所有插值方法,默认值为 true

数据类型: logical

'Colormap' - 返回优化的颜色图
'optimized' (默认) | 'original'

返回优化的颜色图,以逗号分隔的对组形式指定,该对组由 'Colormap' 和字符向量 'optimized' 或 'original' 组成。(仅限于索引图像。)如果设置为 'original',则输出颜色图 (newmap) 与输入颜色图 (map) 相同。如果设置为 'optimized',则 imresize 返回经过优化的新颜色图。

数据类型: char

'Dither' - 执行颜色抖动
true (默认) | false

执行颜色抖动,以逗号分隔的对组形式指定,该对组由 'Dither' 和逻辑布尔值 true 或 false 组成。(仅限于索引图像。)

执行抖动时,会对图像应用一种噪声,以使量化误差随机化并防止出现大范围色块。

数据类型: logical

'Method' - 插值方法
'bicubic' (默认) | 字符向量 | 元胞数组

插值方法,以逗号分隔的对组形式指定,该对组由 'Method' 和一个字符向量或二元素元胞数组组成。有关详细信息,请参阅 method

数据类型: char | cell

'OutputSize' - 输出图像的大小
二元素数值向量

输出图像的大小,以逗号分隔的对组形式指定,该对组由 'OutputSize' 和一个 [numrows numcols] 形式的二元素向量组成。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

'Scale' - 大小调整缩放因子
正数值标量 | 由正值组成的二元素向量

大小调整缩放因子,以逗号分隔的对组形式指定,该对组由 'Scale' 和一个正数值标量或由正值组成的二元素向量组成。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

输出参数

全部折叠

B - 调整大小后的图像
实数非稀疏数值数组

调整大小后的图像,以实数非稀疏数值数组的形式返回,图像的类与输入图像相同。

Y - 调整大小后的索引图像
实数非稀疏数值数组

调整大小后的索引图像,以实数非稀疏数值数组的形式返回,图像的类与输入图像相同。

newmap - 优化后的颜色图
m×3 数值数组

优化后的颜色图,以 m×3 数值数组的形式返回。

提示

  • 如果输出图像的大小不是整数,则 imresize 不会使用指定的比例。imresize 在计算输出图像大小时使用 ceil

扩展功能

Guess you like

Origin www.cnblogs.com/Ph-one/p/11566728.html