Borrar filtros
Borrar filtros

Crashing on size(img)

4 visualizaciones (últimos 30 días)
Ludzavark
Ludzavark el 13 de Mayo de 2024
Comentada: Voss el 13 de Mayo de 2024
I am having trouble calling the following code:
% Load image and convert image to array
img = imread(imgPath);
% Get the size of the image
imageSize = size(img);
It crashes at the second line, with the error:
Array indices must be positive integers or logical values.
imageSize = size(img);
I've tried checking the path is correct, it is.
I've tried isempty() on img, it's not
I've tried resaving the image to the project folder, it looks fine.
I've tried checking the format it's in, it's uint8
I've tried disp(img) and it says:
(:,:,1) =
Columns 1 through 23
208 209 210 212 213 214 214 214 213 213 213 214 214 214 215 215 217 217 217 217 217 217 217
... for many more lines
Please can someone tell me what I'm doing wrong

Respuesta aceptada

Voss
Voss el 13 de Mayo de 2024
Editada: Voss el 13 de Mayo de 2024

You have a variable called "size".

If this is a script, do

clear size

and then run the script again.

If this is a function, rename your size variable to another name that's not a function's name.

  4 comentarios
Ludzavark
Ludzavark el 13 de Mayo de 2024
Thank you for the explanation - though as a matlab newbie most of that still goes over my head even when you explain it to me! Like what you've said makes sense but I couldn't apply it on my own.
I'm used to the compiler telling me what's wrong, like when I defined the variable 'size' it might have shown me a warning saying that it overlaps a function name from my project.
Anyway thanks again!
Voss
Voss el 13 de Mayo de 2024
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Computer Vision with Simulink en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by