Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Image Analyst
Image Analyst il 22 Lug 2012
Modificato: Image Analyst il 23 Lug 2012
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 Commenti
sameen
sameen il 23 Lug 2012
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 il 23 Lug 2012
Modificato: Image Analyst il 23 Lug 2012
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().

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by