Error: subscripted assignment dimension mismatch for loop

Hello,
The error I get is :
for i = 1:numTraining mhi_fig = sprintf('data%d.png', i); img(i,:)=imread(mhi_fig); end Why does this happen? and what is the solution?

Respuestas (1)

Thorsten
Thorsten el 16 de Sept. de 2015
The error occurs because you try to assign an image (2D) to a row (1D) img(i,:).
You can use
img{i} = imread(mhi_fig);
or, if the images have all the same size
img(:,:,i) = imread(mhi_fig); % for gray scale images
img(:,:,:,i) = imread(mhi_fig); % for color images

Categorías

Más información sobre Computer Vision Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Sept. de 2015

Respondida:

el 16 de Sept. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by