Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Image Analyst
Image Analyst el 22 de Jul. de 2012
Editada: Image Analyst el 23 de Jul. de 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 comentarios
sameen
sameen el 23 de Jul. de 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 el 23 de Jul. de 2012
Editada: Image Analyst el 23 de Jul. de 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().

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import from MATLAB 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