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.

조회 수: 4 (최근 30일)
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

댓글을 달려면 로그인하십시오.

채택된 답변

Ahmet Cecen
Ahmet Cecen 2016년 12월 28일
Not enough information, but it is likely that the image you are reading is a color image and is actually r by c by 3. I will also speculate you probably want to do:
img = rgb2gray(img);
  댓글 수: 4
Jan
Jan 2016년 12월 28일
When this is your purpose, "[X temp]" might not be useful. When the images have different sizes, this command must fail in addition.
Enayat Ansari
Enayat Ansari 2016년 12월 28일
so what is the right way to store temp(which is now 1D array) into a matrix.help me i am pretty beginner

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Greg
Greg 2016년 12월 28일
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(:);"

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by