Labeling JPEG Pictures and Saving to Dataset
4 views (last 30 days)
Show older comments
I have a large set of JPEG pictures that I would like to label with a binary label. For example, for a given JPEG, the person viewing the image will either assign it a 1 for "cat present" or a 0 for "no cat". After the image is viewed and the user has assigned it a label, I would like the label for the corresponding image to saved in a dataset for later use. Any ideas of any matlab app or functions that can perform this task?
0 Comments
Answers (1)
Rishabh Mishra
on 5 Nov 2020
Hi,
It is advised to manually loop through each of the ‘.JPEG’ images in the folder and label them.
Refer to the MATLAB code below that serves the purpose.
% path of the folder where images are present
myFolder = 'C:\Users\Documents\My Pictures';
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.jpeg');
% Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
% after looking at image, save the image with new label in dataset folder (to create dataset)
% the label can be 0/1
prompt = 'Enter Label?';
x = input(prompt);
Path = sprintf('C:\Users\Documents\Dataset\%s.jpeg’,x);
Imwrite(imageArray,path);
end
To apply segmentation labelling on the images, Image Labeler Application in applications tab can be used.
Hope this helps.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!