旅程一瞥
照片可以存储在既包含像素内容又含有元信息的文件中. 使用 Import, 就可以得到这样的元数据从而通过编程一探有关照片的背景.
导入并分析在里斯本参观期间拍摄的照片集.
In[1]:=
files = Map[img \[Function] ExampleData[img, "FilePath"],
ExampleData[{"TestImageSet", "Lisbon2016"}]];
查看照片的日期直方图.
In[2]:=
dates = Map[file \[Function] Import[file, "DateTime"], files];
In[3]:=
DateHistogram[dates, Quantity[1, "Hours"]]
Out[3]=
查看缩略图拼贴画.
In[4]:=
thumbnails =
ExampleData[{"TestImageSet", "Lisbon2016"}, "ThumbnailList"];
In[5]:=
ImageCollage[thumbnails, Method -> "Columns", ImagePadding -> 2]
Out[5]=
在时间轴上展示照片.
In[6]:=
TimelinePlot[MapThread[Labeled, {dates, thumbnails}],
PlotLayout -> "Vertical", ImageSize -> Medium]
Out[6]=
收集一个数据集的所有信息.
In[7]:=
gps = Map[file \[Function] Import[file, "GeoPosition"], files];
In[8]:=
ds = Dataset[
MapThread[
AssociationThread[{"Thumbnail", "DateTime",
"GeoPosition"} -> {##}] &, {thumbnails, dates, gps}]]
Out[8]=
显示照片的拍摄地点.
In[9]:=
GeoGraphics[
MapThread[
GeoMarker, {Normal[ds[All, "GeoPosition"]],
Normal[ds[All, "Thumbnail"]]}], ImageSize -> Medium]
Out[9]=