MNIST data store in a folder

1 vue (au cours des 30 derniers jours)
HIRAKJYOTI BASUMATARY
HIRAKJYOTI BASUMATARY le 22 Oct 2017
I am trying to store the images of MNIST training images into a folder. But first, i want to store the images with labels 0 in a serial order, then images with labels 1 in a serial order, so on. Could anyone please guide me how to proceed.
% ========================================================================
%Read and display the MNIST train images and the labels
% ========================================================================
function storemnist
close all;
clear all;
% Loading the training images and the labels
images = loadMNISTImages('train-images.idx3-ubyte');
labels = loadMNISTLabels('train-labels.idx1-ubyte');
image_size = sqrt(size( images, 1));
imageCell={};
Training='TRAINING';
mkdir(Training);
for i =1:length(labels);
% display(['sample no: ', int2str( i) ,' has label = ',int2str(labels(i) )]);
img_matrix = reshape( images(:, i), [ image_size ,image_size ]);
img_matrix = floor( img_matrix *255);
img_matrix =uint8(img_matrix);
p=labels(i,:);
baseFileName = sprintf('%d%d.pgm',p,i); % e.g. "1.png"
fullFileName = fullfile(Training, baseFileName);
imwrite(img_matrix, fullFileName);
end
img_matrix;
end
  2 commentaires
HIRAKJYOTI BASUMATARY
HIRAKJYOTI BASUMATARY le 22 Oct 2017
Sorry , i was able to tackle it finally. Sorry for the inconvenience.
chakradhar Reddy Vardhireddy
Could you please explain how you figured out it and also please provie assistance of how to load "images = loadMNISTImages('train-images.idx3-ubyte');". I am not able to figure out this. Please let me know about it. Thanks

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Images 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