HI All ,Here i want to Reshape 2D images into 1D image vectors , why i get this error ? Error using '?? Transpose on ND array is not defined. Error in testauto (line 14) temp = reshape(img',r*c,1); .please help its urgent Thanks.
Mostrar comentarios más antiguos
clear all close all clc
path = dir('e:\testImage\*.png'); X = [];
n = length(path);
for i = 1 : n
file = strcat('e:\testImage\',path(i).name);
img = imread(file);
% figure,imshow(img);
[r,c] = size(img);
temp = reshape(img',r*c,1);
X = [X temp];
end
3 comentarios
Jan
el 28 de Dic. de 2016
- Please format your code properly. It is not difficult. See instructions
- Omit the brute clearing header clear all close all clc. It is inefficient and a bad habit. As soon as you will work with different GUIs, you will hate this darn auto-closing.
- Do not use "path" as a name of a variable. This is an importanmt function of Matlab and it is hard to predict what might happen during debugging.
- Use fullfile instead of strcat to join path names.
- When you write in the forum, that you get an error message, post a complete copy of the message.
- Use the debugger to examine the problems: The error message is clear: you try to transpose a multi-dimensional array. With the debugger you can find out the dimensions of img. Most likely it is a 3D RGB image.
Enayat Ansari
el 28 de Dic. de 2016
Respuesta aceptada
Más respuestas (1)
Greg
el 28 de Dic. de 2016
0 votos
The error tells you exactly where the problem is: transposing an ND array on line 14. More specifically, the single tick (') operator is matrix transpose. Replace "img'" with "img". temp = reshape(img',r*c,1);
Better way to convert ANYTHING into a single column vector is "temp = img(:);"
1 comentario
Enayat Ansari
el 28 de Dic. de 2016
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!