reading multiple images in a folder and storing the data
3 次查看(过去 30 天)
显示 更早的评论
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')
0 个评论
回答(1 个)
Image Analyst
2021-10-19
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!