I have several thousands of small .jpg
files (30kb each) which I need to import into Mathematica. (I plan to use ImageDistance
to investigate their differences.) I tried several ways to import these files, but all of them seem very slow. So I wonder if I have been doing something wrong?
Here is what I tried:
files = FileNames["*.jpg", path];
images= (Import[#,"JPEG"]&)/@files;
The above takes several minutes to import about 30mb worth of files (about 2 thousand images). Alternatively, I tried:
Dynamic[{i, Length[files]}]
Do[
imgs[i] = Import[files[[i]], "JPEG"];
, {i, 1, Length[files]}]
This has the advantage that it shows the progress during the import process. Still, it imports about 10 files per second. This means about 300kb worth of data per second. Clearly, this rate is ridiculously low. That is why I am pretty sure that I am doing something wrong here. What should I do to import the files faster?
ParallelMap
,ParallelDo
) $\endgroup$ParallelDo
function works faster or slower. Maybe you have a suggestion for some other option to set in order to improve parallel computing performance in this case? $\endgroup$