Effacer les filtres
Effacer les filtres

How to import the images into 2D array (one image per row)?

3 vues (au cours des 30 derniers jours)
May
May le 18 Fév 2017
Commenté : May le 19 Fév 2017
I downloaded the DeepLearnToolbox-master and try to train the CNN. In the test_example_CNN.m,the train images are imported into 2D matrices (one image per row). I would like to train the CNN with my own images, but I don't know how to import the images into 2D array (one image per row). Please, explain me how to do it.
Thanks, May
% Load the MNIST hand-written digit dataset.
load mnist_uint8;
% Reshape the example digits back into 2D images.
%
% 'train_x' and 'test_x' begin as 2D matrices with one image per row.
% train_x [60000 x 784]
% test_x [10000 x 784]
%
% Also, rescale the pixel values from 0 - 255 to 0 - 1.
train_x = double(reshape(train_x',28,28,60000))/255;
test_x = double(reshape(test_x',28,28,10000))/255;
train_y = double(train_y');
test_y = double(test_y');
% You can use this command to display an example image. Note that the
% images need to be transposed in order to be oriented properly.
colormap gray;
imagesc(train_x(:, :, 105)');
axis square;

Réponse acceptée

Walter Roberson
Walter Roberson le 18 Fév 2017
img = imread(TheFileName);
train_x(end+1,:) = reshape(img, 1, []);
  1 commentaire
May
May le 19 Fév 2017
Thank you very much for your answer.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by