任何人都可以提供帮助?不知道为什么会出错? ???
Assignment has more non-singleton rhs dimensions than non-singleton subscripts Error in ==> create_padded_image at 17 padded_image(padding+1:padding+image_size(1), padding+1:padding+image_size(2)) = image; Error in ==> create_padded_image at 9 padded_image = create_padded_image(image)
function padded_image = create_padded_image(image, padding)
if nargin < 2
% if no padding passed - define it.
padding = 5;
end
if nargin < 1
% let's create an image if none is given
image = imread('GreyScale.bmp');
padded_image = create_padded_image(image)
end
% what are the image dimensions?
image_size = size(image);
% allocate zero array of new padded image
padded_image = zeros(2*padding + image_size(1), 2*padding + image_size(2));
% write image into the center of padded image
padded_image(padding+1:padding+image_size(1), padding+1:padding+image_size(2)) = image;
end
答案 0 :(得分:0)
尝试
image_size = size(image);
padded_image = zeros(2*padding + image_size(1), 2*padding + image_size(2), size(image,3), class(image));
padded_image(padding+1:padding+image_size(1), padding+1:padding+image_size(2), :) = image;