Borrar filtros
Borrar filtros

Saving data in an array in .mat file

2 visualizaciones (últimos 30 días)
Nermeen alami
Nermeen alami el 24 de Feb. de 2013
hi I'm working on image classification project using hue, saturation and value histograms. i get the histograms and i can save it into .mat file but i want to retrieve data to send it to nearest neighbor classifier. i can save the hue, saturation and value histograms of six bins as six values for each histogram (for each image). How can i save the 18 values(6 for hue, 6 for saturation , 6 for value) in one raw for each image (i.e for 15 images i want to have (15 * 19) denominational array in a file, the 19th column is for label). but i have no idea how to do that and if is that doable ?..... this is the code i used
%constants
savefile='hists.mat';
numberofbins=6;
status=1; %means plant leave is not infected
rgbImage = imread('c:/seg.jpg');
% Display the original image.
% Convert to HSV color space
hsv = rgb2hsv(rgbImage);
hsv=im2double(hsv);
% Extract out the individual channels.
h = hsv(:,:,1);
s = hsv(:,:,2);
v = hsv(:,:,3);
% Take histograms
hhist=hist(h(:), numberofbins);
shist=hist(s(:), numberofbins);
vhist=hist(v(:), numberofbins);
save(savefile, 'hhist','shist','vhist','status');
% the result of the previous code as following
b=open('hists.mat')
b =
status: 1
hhist: [264762 146522 3420 483 5137 292]
shist: [233127 3829 47680 120489 4495 10996]
vhist: [102904 4912 85358 84347 2252 140843]
what i wish to have is: 264762 146522 3420 483 5137 292 233127 3829 47680 120489 4495 10996 102904 4912 85358 84347 2252 140843 1 in one raw
thanks a lot... waiting for help :)

Respuesta aceptada

the cyclist
the cyclist el 24 de Feb. de 2013
If I understand your question correctly, all you need to do is concatenate each of your values into one vector:
oneVectorToRuleThemAll = [hhist, shist, vhist, status];
and then save that vector like you did other ones.
You could also concatenate multiple vectors like that, vertically, into an array:
oneArray = [v1; v2; v3];
to get your 15x19 array.

Más respuestas (0)

Categorías

Más información sobre Histograms 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!

Translated by