How to save multiple data in one text file
Show older comments
I want to save height and width value from multiple objects in one text file, but it only saved the last processed image data. here's my code:
contents = get(hObject,'Value')
pilih=guidata(gcbo);
theImage{1}=getImage(handles.axes1);
theImage{2}=getImage(handles.axes2);
theImage{3}=getImage(handles.axes3);
theImage{4}=getImage(handles.axes4);
theImage{5}=getImage(handles.axes5);
for z = 1:5;
Img = theImage{z};
abu=rgb2gray(Img);
cb=imclearborder(abu);
thresh=graythresh(cb);
b=im2bw(cb,thresh);
bw=bwareaopen(b,60);
bwfill=imfill(bw,'holes');
s=regionprops(bwfill,'BoundingBox');
objects=cell(numel(s),1);
for idx=1:numel(s)
bb=floor(s(idx).BoundingBox);
out=bsxfun(@times,Img,uint8(bwfill));
objects{idx}=out(bb(2):bb(2)+bb(4),bb(1):bb(1)+bb(3),:);
end
X = zeros(3, numel(objects));
for k = 1:numel(objects)
k1=objects{k};
c1=rgb2gray(k1);
t1=graythresh(c1);
biner1=im2bw(c1,t1);
[height,width]=size(biner1);
a1=bwarea(biner1);
X(:,k)=[height;width;a1];
end
end
save grading/datauji.txt X -ascii;
What should I do? Thank you very much.
Answers (0)
Categories
Find more on Import, Export, and Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!