Unable to perform assignment because the size of the left side is 625-by-1 and the size of the right side is 1875-by-1

조회 수: 1 (최근 30일)
circle_folder = 'C:\Users\MyPC\Documents\CR\start\circle';
name_circle = dir(fullfile(circle_folder, '*.png'));
total_circle = numel(name_circle);
rez_circle = [25 25];
m_circle = zeros(25*25, 5);
for n_circle = 1:total_circle
full_circle = fullfile(circle_folder, name_circle(n_circle).name);
images_circle = imread(full_circle);
images_circle = imresize(images_circle, rez_circle);
store_circle = imbinarize(images_circle);
store_circle = store_circle(:);
m_circle(:, n_circle) = store_circle;
figure(n_circle);
imshow(m_circle);
end
I'm trying to pull images from the folder in question, resize them to 25 by 25 pixels, then turn them into a binary matrix. The code works until the point i attempt to fit the images into said matrix. If I make the matrix bigger, so it becomes 1875-by-1, it works, however, I do need the matrix to be of this size.

답변 (2개)

KSSV
KSSV 2022년 6월 15일
Better save them into an cell array.
circle_folder = 'C:\Users\MyPC\Documents\CR\start\circle';
name_circle = dir(fullfile(circle_folder, '*.png'));
total_circle = numel(name_circle);
rez_circle = [25 25];
m_circle = cell(total_circle,1);
for n_circle = 1:total_circle
full_circle = fullfile(circle_folder, name_circle(n_circle).name);
images_circle = imread(full_circle);
images_circle = imresize(images_circle, rez_circle);
store_circle = imbinarize(images_circle);
store_circle = store_circle(:);
m_circle{n_circle} = store_circle;
figure(n_circle);
imshow(m_circle{n_circle}); %
end

Walter Roberson
Walter Roberson 2022년 6월 15일
One or more of your images are rgb. 25*25*3 = 1875

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by