How to import the images into 2D array (one image per row)?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
May
el 18 de Feb. de 2017
Comentada: May
el 19 de Feb. de 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;
0 comentarios
Respuesta aceptada
Walter Roberson
el 18 de Feb. de 2017
img = imread(TheFileName);
train_x(end+1,:) = reshape(img, 1, []);
Más respuestas (0)
Ver también
Categorías
Más información sobre Recognition, Object Detection, and Semantic Segmentation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!