reading multiple images in a folder and storing the data

1 vue (au cours des 30 derniers jours)
Ahmed Alsmaeil
Ahmed Alsmaeil le 19 Oct 2021
Hello,
I have the following code which was provided by one of the members. It reads an image and calculate the surface and sectional areas.
I tried to modify the code so that it reads several images, say from 1-100 and store the sectional and surface areas in a text file, but it didn't work.
Any suggestions?
inpict = rgb2gray(imread('44.png'));
% generate binary image of object alone
m = ~imbinarize(inpict,'adaptive','foregroundpolarity','dark','sensitivity',0.5);
m = bwareafilt(imclearborder(m),1);
st = strel('disk',20);
m = imerode(~bwareafilt(imerode(~m,st),1),st);
%imshow(m)
% calculate areas
d = sum(m,1);
d = d(d~=0);
Asurf = sum(pi*d) % assuming rotational symmetry
Asect = sum(m,'all')

Réponses (1)

Image Analyst
Image Analyst le 19 Oct 2021
There is nothing in that code that stores anything in a text file. Try fopen(), then fprintf() and then fclose(), or the writematrix() function.
To process a sequence of image files, see code samples in the FAQ.
Write back if you can't figure it out.

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by