How to convert multiple images into row vector

5 Ansichten (letzte 30 Tage)
Manjiri
Manjiri am 2 Dez. 2014
Bearbeitet: Azar Alizadeh am 4 Nov. 2020
I have converted using below code into column vector but i need to convert them into row vector
dirData = dir('C:\Users\Manjiri\Documents\MATLAB\*.tif');
fileNames = {dirData.name};
for k = 1:length(dirData)
filename = dirData(k).name;
data1 = imread(filename);
data_all{k}= data1(:);
end
save data_allEx data_all

Antworten (3)

Andrei Bobrov
Andrei Bobrov am 2 Dez. 2014
...
data_all{k}= data1(:)';
...

Jahnavi Mrudula Mudduluru
Jahnavi Mrudula Mudduluru am 4 Mär. 2018
I have a 1*784 matrix, I need to convert it to a 28*28 image, can anyone please tell me how to do it?I used reshage, imagesc for this, but the picture doesn't seem right, any suggestions would be a great help. I'm attaching a file which contains X_train which contains pixels of 12,000 images as row vectors, I'm supposed to study the 12,000th image, it is a 9, but I'm getting some weird shape.
Thank You

Jahnavi Mrudula Mudduluru
Jahnavi Mrudula Mudduluru am 4 Mär. 2018
Sorry, I forgot to attach the file, I'm attaching it here.
  1 Kommentar
Azar Alizadeh
Azar Alizadeh am 4 Nov. 2020
Bearbeitet: Azar Alizadeh am 4 Nov. 2020
load MNIST_train.mat;
X_tr=data(:,2:end);
Y=data(:,1);
"" X_img=reshape(X_tr,60000,28,28);""
you can either use the above line (60000 is the size of Mnist train set) which gives you a 60000x28x28 matrix.
or use a for loop and save each image separatelly , in this case :
for i=1:size(X_tr,1)
X_image{i}=reshape(X_tr,28,28)
end

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by