필터 지우기
필터 지우기

Saving data in an array in .mat file

조회 수: 2 (최근 30일)
Nermeen alami
Nermeen alami 2013년 2월 24일
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 :)

채택된 답변

the cyclist
the cyclist 2013년 2월 24일
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.
  댓글 수: 1
Nermeen alami
Nermeen alami 2013년 2월 24일
that's what i want thank u a lot

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by