How to get all the results for every input file with Do loop?

I have several images to be processed with a series of functions. The current script I have only gives me the result for the last image. How can I get all the results for every single images? Thanks in advance!

The script I have now:

NotebookDirectory[]
ClearAll;
files1 = FileNames["*.jpg", NotebookDirectory[]]
nfile = Length [files1]
i = 1
Do[Data = Import[files1[[i]]];
 img = Dilation[Data, DiskMatrix[5]];
 img = Binarize[img, 0.67];
 img = CurvatureFlowFilter[img, 10];
 img = EdgeDetect[img, 10];
 img = RemoveAlphaChannel[ColorNegate@ColorConvert[img, "Grayscale"]];
 pts = PixelValuePositions[img, Black, .2];
 s1 = Select[pts, #[[1]] > 0 &];
 s1 = Select[s1, #[[1]] < 100 &];
 line1 = Fit[s1, {1, x}, x];
 a = Coefficient[line1, x ^1], {i, 1, nfile}]

The images are like
WP83t How to get all the results for every input file with Do loop?5Hc4C How to get all the results for every input file with Do loop?

1 Answer

Let’s block ads! (Why?)

Recent Questions – Mathematica Stack Exchange