How to create .mat file?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to create .mat file according to the following data. I have 100 of dog images, 100 of cat images and 100 of bird images. These three class image data will be in same mat file in three variable dog,cat and bird.
Anyone could help me by providing the matlab code.
Thanks
6 comentarios
Rik
el 22 de Jun. de 2017
You really should mention the specifications yourself. I found on that page you linked the following text about the data structure:
data -- a 10000x3072 numpy array of uint8s. Each row of the array stores a 32x32 colour image. The first 1024 entries contain the red channel values, the next 1024 the green, and the final 1024 the blue. The image is stored in row-major order, so that the first 32 entries of the array are the red channel values of the first row of the image.
labels -- a list of 10000 numbers in the range 0-9. The number at index i indicates the label of the ith image in the array data.
The links that Stephen gave you should really help you out. If not, show some effort and show you have followed the steps here.
Respuestas (1)
Jan
el 22 de Jun. de 2017
The relation to CIFAR-10 is unclear. This seems to be a very different task. So please explain if a simple MAT file is sufficient. If it is, the creation is not hard:
- use dir to obtain the file names
- a for loop over the files
- imread to import the files and store them in a cell array
- Use struct like Data.cat, Data.dog, Data.bird. You could use the names of the folders as Data.(FolderName), such that the import of the 3 folders can run in a loop.
- Finally call save to store the struct.
Please try this by your own and ask a specific question, if problems occur. It would be less efficient if the readers of the forum invent some code, because this will not match your need exactly.
0 comentarios
Ver también
Categorías
Más información sobre Cell Arrays 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!