How to import the images into 2D array (one image per row)?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Recognition, Object Detection, and Semantic Segmentation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!