matlab函数pixeldup代码
时间: 2024-01-19 21:04:07 浏览: 187
pixeldup函数的代码如下:
```matlab
function out = pixeldup(in, factor)
%PIXELDUP Duplicates pixels in an image
% OUT = PIXELDUP(IN, FACTOR) duplicates each pixel in the input image,
% IN, FACTOR times in both the row and column directions. FACTOR must be a
% positive integer. OUT is the output image.
%
% Class Support
% -------------
% The input image can be uint8, uint16, int16, double, or single. The
% output image is of the same class as the input image.
% Check the input.
if ~isnumeric(in)
error('Input image must be numeric.');
end
if (~isreal(in) || (ndims(in) > 3) || (size(in,4) ~= 1))
error('Input image must be a real, 2-D, or 3-D matrix.');
end
% Check the factor.
if ~isnumeric(factor) || ~isscalar(factor) || (factor < 1) || (factor ~= round(factor))
error('Factor must be a positive integer.');
end
% Duplicate the pixels.
out = repmat(in, [factor factor 1]);
```
该函数的主要作用是将输入图像中的每个像素在行和列方向上复制指定的次数,输出一个新的图像。它可以处理不同类型的输入图像,并返回与输入图像相同类型的输出图像。
阅读全文