Error in matrix assignment
显示 更早的评论
I am attempting to create a MXNXP image stack, where M and N are the vertical and horizontal dimensions, and P is a third dimension that represents the number of images in the stack. For one particular set of images, I keep getting an error message that says "Unable to perform assignment because the size of the left side is 128-by-128 and the size of the right side is 256-by-256." Not sure what this means, but it looks like m and n are getting multiplied by 2.. Do not know why it would be doing this. This same code works for other sets of images. Here is the code:
function num_images = img_2_stack(path)
% path = '/path/to/image/directory'
% create image stack
dir_info = dir(fullfile(path, '*.png'));
num_images = numel(dir_info)
m = 128; % vertical pixels
n = 128; % horizontal pixels
img_stack = zeros(m,n,num_images); % initialize image stack
for i = 1:num_images
fn = dir_info(i).name;
img = imread(fullfile(path, fn));
img_stack(:,:,i) = img;
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!