How to create a .mat file to store multiple images and its histograms.
Mostrar comentarios más antiguos
Hi,
I'm new to matlab and would greatly appreciate if anyone could guide me about .MAT file. I'm doing a image retrieval system which requires a database of 1000 images. Currently, i have a .mat file which contains the training data for 100 images but i would like it to increase 1000 images. How do i edit the .mat file or how to do i go about creating a .MAT file which it can store 1000 images and its histograms. Your help is greatly appreciated. Thanks.
Respuestas (1)
Walter Roberson
el 24 de En. de 2013
For example,
for K = 1 : 1000
filename = sprintf('image_%04d.tif', K);
I = imread(filename);
IGray = rgb2gray(I);
H = hist(Igray(:), 32); %32 bins in the histogram
imgs(K).image = I;
imgs(K).histogram = H;
end
save('ImageDatabase.mat', 'imgs');
3 comentarios
Walter Roberson
el 24 de En. de 2013
image_%04d.tif is the pattern of the names of the images that are read in in this example, The pattern is 'image_' followed by a 4-digit number with leading 0's, followed by '.tif'
The example is a demonstration of how you might build up the big database by reading in a bunch of images that are currently in separate files, the names of which follow a numeric pattern. If you want to get file names from the directory, please see this FAQ
The number of bins to use for your histogram depends entirely on your purposes. Different investigations have found different number of bins to be better.
Note that in the sample code, I transformed the image to grayscale and did a histogram on the grayscale values (independent of position.) If you want to do RGB or HSV histograms, you would not do the rgb2gray(), and you would need to figure out how you want to create a histogram when you have 3 different color planes, R vs G vs B, or H vs S vs V would require 3 dimensional outputs... and then what?
Revathi
el 24 de En. de 2013
Fattah Tuhin
el 23 de Feb. de 2015
Nice . This helped me lot. Thank you
Categorías
Más información sobre Convert Image Type en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!