How to save 2 column vectors of multiple arrays existing in workspace to a .txt file or in excel file ?

2 次查看(过去 30 天)
i got my all labeled arrays in workspace . now i want to store those arrays separately in some .txt file or in excel file .. like label 1's 2's ....max coordinates save in one file ..or it will save in multiple files having no idea about that . Help me

采纳的回答

Image Analyst
Image Analyst 2012-7-22
编辑:Image Analyst 2012-7-23
I don't think you want to save them in a text file or an Excel workbook, based on reading your other posting. I think they should be images also. Use something like this (untested)
[labeledImage numberOfBlobs] = bwlabel(binaryImage, 8); % Label each blob so we can make measurements of it
% Get all the blob properties.
blobMeasurements = regionprops(labeledImage, 'PixelList');
for r = 1 : numberOfBlobs
% Extract blobs one at a time.
% Note how we use ismember() to do this.
oneRegion = ismember(labeledImage, r);
% Save it to disk.
baseFilename = sprintf('Region number %d.png', r);
fullFileName = fullfile(folder, baseFilename);
imwrite(oneRegion , fullFileName);
thesePixels = blobMeasurements(r).PixelList;
% Now use fopen(), fprintf(), and fclose() to write thesePixels to a disk file.
end
  2 个评论
sameen
sameen 2012-7-23
sir the above code is giving me this error
??? Error using ==> regionprops Too many output arguments.
and please tell me how to store all those coordinate values in some text or excel file (which is most suitable and easily integrated with c sharp???)
Image Analyst
Image Analyst 2012-7-23
编辑:Image Analyst 2012-7-23
Sorry - I edited it to fix the mistake. I assume you know how (or can easily figure out how) to use fprintf() to write the coordinates to a file. Comment out the filename and imwrite line if you don't want an image file. Don't use Excel since that will take a long time - much longer than fprintf().

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by