필터 지우기
필터 지우기

save CIFAR-100 images

조회 수: 15 (최근 30일)
Abo
Abo 2017년 3월 13일
댓글: Komal B 2019년 11월 8일
dear all, I'm working with CIFAR-100 images for training CNN, available here: https://www.cs.toronto.edu/~kriz/cifar-10-matlab.tar.gz
as im extracting the file, would see different mat files (each contain one called 'labels' another 'data'). any body know what is labels and data? how can i do the same for my own data? I meant save my images as mat file with data and labels? thanks

답변 (1개)

Antonio Cedillo Hernandez
Antonio Cedillo Hernandez 2018년 5월 5일
편집: Antonio Cedillo Hernandez 2018년 5월 5일
Hi Abo! I apologize if my answer is too late, but as there is 21 views of this question in last 30 days, so I will post my answer to your question. There are three MAT files called meta.dat, test.mat and train.mat. All of them are matrices with data in order to guide the correct extracting process of the images. Here is my code to extract the images from the dataset:
if true
clc;
clear all;
load('meta.mat');
%Create folders
for i=1:length(fine_label_names)
mkdir('CIFAR-100\TEST\',fine_label_names{i});
mkdir('CIFAR-100\TRAIN\',fine_label_names{i});
end
%%Training images
load('train.mat');
im=zeros(32,32,3);
for cpt=1:50000
R=data(cpt,1:1024);
G=data(cpt,1025:2048);
B=data(cpt,2049:3072);
k=1;
for x=1:32
for i=1:32
im(x,i,1)=R(k);
im(x,i,2)=G(k);
im(x,i,3)=B(k);
k=k+1;
end
end
im=uint8(im);
pathdest = strcat('CIFAR-100\TRAIN\',fine_label_names{fine_labels(cpt)+1},'\',filenames{cpt});
imwrite(im,pathdest,'png');
end
%%Test images
load('test.mat');
im=zeros(32,32,3);
for cpt=1:10000
R=data(cpt,1:1024);
G=data(cpt,1025:2048);
B=data(cpt,2049:3072);
k=1;
for x=1:32
for i=1:32
im(x,i,1)=R(k);
im(x,i,2)=G(k);
im(x,i,3)=B(k);
k=k+1;
end
end
im=uint8(im);
pathdest = strcat('CIFAR-100\TEST\',fine_label_names{fine_labels(cpt)+1},'\',filenames{cpt});
imwrite(im,pathdest,'png');
end
end
  댓글 수: 4
Toshi Sinha
Toshi Sinha 2019년 6월 3일
Download 7-zip and extract the ".tar.gz" files using it. They will be extracted to a folder now you can see all .mat files
Komal B
Komal B 2019년 11월 8일
Thanks a lot Antonio. That program works like a charm.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by