为每个图像找到两个最近的
Find two nearest for each image
我有一个字典列表,其中键是图像名称,值是来自 exif 的坐标。
{'IMG_0003_1.tif': {'Latitude': 46.292602599999995, 'Longitude': -119.7299495, 'Altitude': 426.316}}
{'IMG_0004_1.tif': {'Latitude': 46.29282, 'Longitude': -119.7301617, 'Altitude': 477.151}}
{'IMG_0005_1.tif': {'Latitude': 46.2929581, 'Longitude': -119.7303228, 'Altitude': 477.222}}
{'IMG_0006_1.tif': {'Latitude': 46.2931217, 'Longitude': -119.7304816, 'Altitude': 477.432}}
{'IMG_0007_1.tif': {'Latitude': 46.2932815, 'Longitude': -119.7306418, 'Altitude': 477.962}}
{'IMG_0008_1.tif': {'Latitude': 46.293439299999996, 'Longitude': -119.730806, 'Altitude': 477.823}}
{'IMG_0009_1.tif': {'Latitude': 46.2935699, 'Longitude': -119.730942, 'Altitude': 477.506}}
{'IMG_0010_1.tif': {'Latitude': 46.2937307, 'Longitude': -119.7311043, 'Altitude': 477.314}}
{'IMG_0011_1.tif': {'Latitude': 46.2939978, 'Longitude': -119.7313743, 'Altitude': 476.604}}
{'IMG_0012_1.tif': {'Latitude': 46.2940508, 'Longitude': -119.7314279, 'Altitude': 476.334}}
{'IMG_0013_1.tif': {'Latitude': 46.2942515, 'Longitude': -119.7316253, 'Altitude': 475.738}}
{'IMG_0014_1.tif': {'Latitude': 46.294383599999996, 'Longitude': -119.7317627, 'Altitude': 476.546}}
{'IMG_0015_1.tif': {'Latitude': 46.2945286, 'Longitude': -119.73191200000001, 'Altitude': 477.327}}
{'IMG_0016_1.tif': {'Latitude': 46.294699699999995, 'Longitude': -119.73208890000001, 'Altitude': 477.12}}
{'IMG_0017_1.tif': {'Latitude': 46.294854099999995, 'Longitude': -119.732251, 'Altitude': 476.749}}
{'IMG_0018_1.tif': {'Latitude': 46.294931899999995, 'Longitude': -119.7323415, 'Altitude': 475.614}}
{'IMG_0019_1.tif': {'Latitude': 46.2949305, 'Longitude': -119.73230360000001, 'Altitude': 475.913}}
{'IMG_0020_1.tif': {'Latitude': 46.294931299999995, 'Longitude': -119.7317773, 'Altitude': 475.696}}
{'IMG_0021_1.tif': {'Latitude': 46.294931399999996, 'Longitude': -119.7316604, 'Altitude': 475.541}}
{'IMG_0022_1.tif': {'Latitude': 46.2949279, 'Longitude': -119.7314008, 'Altitude': 475.584}}
{'IMG_0023_1.tif': {'Latitude': 46.2949282, 'Longitude': -119.7311443, 'Altitude': 475.132}}
现在我需要根据坐标为每个图像找到最近的两个。如何在 python 中完成?我什至不知道从哪里开始...
首先,我建议您将数据重新格式化为以图像名称为键的大字典,而不是一堆字典。
data = {'IMG_0003_1.tif': {'Latitude': 46.292602599999995, 'Longitude': -119.7299495, 'Altitude': 426.316},
'IMG_0004_1.tif': {'Latitude': 46.29282, 'Longitude': -119.7301617, 'Altitude': 477.151},
'IMG_0005_1.tif': {'Latitude': 46.2929581, 'Longitude': -119.7303228, 'Altitude': 477.222},
'IMG_0006_1.tif': {'Latitude': 46.2931217, 'Longitude': -119.7304816, 'Altitude': 477.432},
'IMG_0007_1.tif': {'Latitude': 46.2932815, 'Longitude': -119.7306418, 'Altitude': 477.962},
'IMG_0008_1.tif': {'Latitude': 46.293439299999996, 'Longitude': -119.730806, 'Altitude': 477.823},
'IMG_0009_1.tif': {'Latitude': 46.2935699, 'Longitude': -119.730942, 'Altitude': 477.506},
'IMG_0010_1.tif': {'Latitude': 46.2937307, 'Longitude': -119.7311043, 'Altitude': 477.314},
'IMG_0011_1.tif': {'Latitude': 46.2939978, 'Longitude': -119.7313743, 'Altitude': 476.604},
'IMG_0012_1.tif': {'Latitude': 46.2940508, 'Longitude': -119.7314279, 'Altitude': 476.334},
'IMG_0013_1.tif': {'Latitude': 46.2942515, 'Longitude': -119.7316253, 'Altitude': 475.738},
'IMG_0014_1.tif': {'Latitude': 46.294383599999996, 'Longitude': -119.7317627, 'Altitude': 476.546},
'IMG_0015_1.tif': {'Latitude': 46.2945286, 'Longitude': -119.73191200000001, 'Altitude': 477.327},
'IMG_0016_1.tif': {'Latitude': 46.294699699999995, 'Longitude': -119.73208890000001, 'Altitude': 477.12},
'IMG_0017_1.tif': {'Latitude': 46.294854099999995, 'Longitude': -119.732251, 'Altitude': 476.749},
'IMG_0018_1.tif': {'Latitude': 46.294931899999995, 'Longitude': -119.7323415, 'Altitude': 475.614},
'IMG_0019_1.tif': {'Latitude': 46.2949305, 'Longitude': -119.73230360000001, 'Altitude': 475.913},
'IMG_0020_1.tif': {'Latitude': 46.294931299999995, 'Longitude': -119.7317773, 'Altitude': 475.696},
'IMG_0021_1.tif': {'Latitude': 46.294931399999996, 'Longitude': -119.7316604, 'Altitude': 475.541},
'IMG_0022_1.tif': {'Latitude': 46.2949279, 'Longitude': -119.7314008, 'Altitude': 475.584},
'IMG_0023_1.tif': {'Latitude': 46.2949282, 'Longitude': -119.7311443, 'Altitude': 475.132}}
之后,首先要做的是创建一个可以计算两个图像之间距离的函数:
def calculate_distance(first_location, second_location):
distance = (second_location["Latitude"] - first_location["Latitude"]) + (second_location["Longitude"] - first_location["Longitude"]) + (second_location["Altitude"] - first_location["Altitude"])
return abs(round(distance, 3))
一个可能的解决方案,(请注意:这不是最有效的解决方案,但它是一个简单的解决方案)代码的核心可以迭代所有元素并比较所有图像之间的距离。之后,您可以对每个图像的结果进行排序。这样,您将得到一个按每个图像的值排序的字典。
(请注意,我没有提取前两个最近的元素,但我给你留下了整个字典)
final_distances = {}
for element, element_value in data.items():
final_distances[element] = {}
for compare, compare_value in data.items():
if compare != element:
final_distances[element][compare] = calculate_distance(element_value, compare_value)
final_distances[element] = {k: v for k, v in sorted(final_distances[element].items(), key=lambda item: item[1])}
for key, value in final_distances.items():
print(key, value)
所以输出将是:
IMG_0003_1.tif {'IMG_0023_1.tif': 48.817, 'IMG_0021_1.tif': 49.226, 'IMG_0022_1.tif': 49.269, 'IMG_0018_1.tif': 49.298, 'IMG_0020_1.tif': 49.381, 'IMG_0013_1.tif': 49.422, 'IMG_0019_1.tif': 49.597, 'IMG_0012_1.tif': 50.018, 'IMG_0014_1.tif': 50.23, 'IMG_0011_1.tif': 50.288, 'IMG_0017_1.tif': 50.433, 'IMG_0016_1.tif': 50.804, 'IMG_0004_1.tif': 50.835, 'IMG_0005_1.tif': 50.906, 'IMG_0010_1.tif': 50.998, 'IMG_0015_1.tif': 51.011, 'IMG_0006_1.tif': 51.116, 'IMG_0009_1.tif': 51.19, 'IMG_0008_1.tif': 51.507, 'IMG_0007_1.tif': 51.646}
IMG_0004_1.tif {'IMG_0016_1.tif': 0.031, 'IMG_0005_1.tif': 0.071, 'IMG_0010_1.tif': 0.163, 'IMG_0015_1.tif': 0.176, 'IMG_0006_1.tif': 0.281, 'IMG_0009_1.tif': 0.355, 'IMG_0017_1.tif': 0.402, 'IMG_0011_1.tif': 0.547, 'IMG_0014_1.tif': 0.605, 'IMG_0008_1.tif': 0.672, 'IMG_0007_1.tif': 0.811, 'IMG_0012_1.tif': 0.817, 'IMG_0019_1.tif': 1.238, 'IMG_0013_1.tif': 1.413, 'IMG_0020_1.tif': 1.455, 'IMG_0018_1.tif': 1.537, 'IMG_0022_1.tif': 1.566, 'IMG_0021_1.tif': 1.609, 'IMG_0023_1.tif': 2.018, 'IMG_0003_1.tif': 50.835}
IMG_0005_1.tif {'IMG_0004_1.tif': 0.071, 'IMG_0010_1.tif': 0.092, 'IMG_0016_1.tif': 0.102, 'IMG_0015_1.tif': 0.105, 'IMG_0006_1.tif': 0.21, 'IMG_0009_1.tif': 0.284, 'IMG_0017_1.tif': 0.473, 'IMG_0008_1.tif': 0.601, 'IMG_0011_1.tif': 0.618, 'IMG_0014_1.tif': 0.676, 'IMG_0007_1.tif': 0.74, 'IMG_0012_1.tif': 0.888, 'IMG_0019_1.tif': 1.309, 'IMG_0013_1.tif': 1.484, 'IMG_0020_1.tif': 1.525, 'IMG_0018_1.tif': 1.608, 'IMG_0022_1.tif': 1.637, 'IMG_0021_1.tif': 1.68, 'IMG_0023_1.tif': 2.089, 'IMG_0003_1.tif': 50.906}
IMG_0006_1.tif {'IMG_0009_1.tif': 0.074, 'IMG_0015_1.tif': 0.105, 'IMG_0010_1.tif': 0.118, 'IMG_0005_1.tif': 0.21, 'IMG_0004_1.tif': 0.281, 'IMG_0016_1.tif': 0.312, 'IMG_0008_1.tif': 0.391, 'IMG_0007_1.tif': 0.53, 'IMG_0017_1.tif': 0.683, 'IMG_0011_1.tif': 0.828, 'IMG_0014_1.tif': 0.886, 'IMG_0012_1.tif': 1.098, 'IMG_0019_1.tif': 1.519, 'IMG_0013_1.tif': 1.694, 'IMG_0020_1.tif': 1.735, 'IMG_0018_1.tif': 1.818, 'IMG_0022_1.tif': 1.847, 'IMG_0021_1.tif': 1.89, 'IMG_0023_1.tif': 2.299, 'IMG_0003_1.tif': 51.116}
IMG_0007_1.tif {'IMG_0008_1.tif': 0.139, 'IMG_0009_1.tif': 0.456, 'IMG_0006_1.tif': 0.53, 'IMG_0015_1.tif': 0.635, 'IMG_0010_1.tif': 0.648, 'IMG_0005_1.tif': 0.74, 'IMG_0004_1.tif': 0.811, 'IMG_0016_1.tif': 0.842, 'IMG_0017_1.tif': 1.213, 'IMG_0011_1.tif': 1.358, 'IMG_0014_1.tif': 1.416, 'IMG_0012_1.tif': 1.628, 'IMG_0019_1.tif': 2.049, 'IMG_0013_1.tif': 2.224, 'IMG_0020_1.tif': 2.265, 'IMG_0018_1.tif': 2.348, 'IMG_0022_1.tif': 2.377, 'IMG_0021_1.tif': 2.42, 'IMG_0023_1.tif': 2.829, 'IMG_0003_1.tif': 51.646}
IMG_0008_1.tif {'IMG_0007_1.tif': 0.139, 'IMG_0009_1.tif': 0.317, 'IMG_0006_1.tif': 0.391, 'IMG_0015_1.tif': 0.496, 'IMG_0010_1.tif': 0.509, 'IMG_0005_1.tif': 0.601, 'IMG_0004_1.tif': 0.672, 'IMG_0016_1.tif': 0.703, 'IMG_0017_1.tif': 1.074, 'IMG_0011_1.tif': 1.219, 'IMG_0014_1.tif': 1.277, 'IMG_0012_1.tif': 1.489, 'IMG_0019_1.tif': 1.91, 'IMG_0013_1.tif': 2.085, 'IMG_0020_1.tif': 2.126, 'IMG_0018_1.tif': 2.209, 'IMG_0022_1.tif': 2.238, 'IMG_0021_1.tif': 2.281, 'IMG_0023_1.tif': 2.69, 'IMG_0003_1.tif': 51.507}
IMG_0009_1.tif {'IMG_0006_1.tif': 0.074, 'IMG_0015_1.tif': 0.179, 'IMG_0010_1.tif': 0.192, 'IMG_0005_1.tif': 0.284, 'IMG_0008_1.tif': 0.317, 'IMG_0004_1.tif': 0.355, 'IMG_0016_1.tif': 0.386, 'IMG_0007_1.tif': 0.456, 'IMG_0017_1.tif': 0.757, 'IMG_0011_1.tif': 0.902, 'IMG_0014_1.tif': 0.96, 'IMG_0012_1.tif': 1.172, 'IMG_0019_1.tif': 1.593, 'IMG_0013_1.tif': 1.768, 'IMG_0020_1.tif': 1.809, 'IMG_0018_1.tif': 1.892, 'IMG_0022_1.tif': 1.921, 'IMG_0021_1.tif': 1.964, 'IMG_0023_1.tif': 2.373, 'IMG_0003_1.tif': 51.19}
IMG_0010_1.tif {'IMG_0015_1.tif': 0.013, 'IMG_0005_1.tif': 0.092, 'IMG_0006_1.tif': 0.118, 'IMG_0004_1.tif': 0.163, 'IMG_0009_1.tif': 0.192, 'IMG_0016_1.tif': 0.194, 'IMG_0008_1.tif': 0.509, 'IMG_0017_1.tif': 0.565, 'IMG_0007_1.tif': 0.648, 'IMG_0011_1.tif': 0.71, 'IMG_0014_1.tif': 0.768, 'IMG_0012_1.tif': 0.98, 'IMG_0019_1.tif': 1.401, 'IMG_0013_1.tif': 1.576, 'IMG_0020_1.tif': 1.617, 'IMG_0018_1.tif': 1.7, 'IMG_0022_1.tif': 1.729, 'IMG_0021_1.tif': 1.772, 'IMG_0023_1.tif': 2.181, 'IMG_0003_1.tif': 50.998}
IMG_0011_1.tif {'IMG_0014_1.tif': 0.058, 'IMG_0017_1.tif': 0.145, 'IMG_0012_1.tif': 0.27, 'IMG_0016_1.tif': 0.516, 'IMG_0004_1.tif': 0.547, 'IMG_0005_1.tif': 0.618, 'IMG_0019_1.tif': 0.691, 'IMG_0010_1.tif': 0.71, 'IMG_0015_1.tif': 0.723, 'IMG_0006_1.tif': 0.828, 'IMG_0013_1.tif': 0.866, 'IMG_0009_1.tif': 0.902, 'IMG_0020_1.tif': 0.907, 'IMG_0018_1.tif': 0.99, 'IMG_0022_1.tif': 1.019, 'IMG_0021_1.tif': 1.062, 'IMG_0008_1.tif': 1.219, 'IMG_0007_1.tif': 1.358, 'IMG_0023_1.tif': 1.471, 'IMG_0003_1.tif': 50.288}
IMG_0012_1.tif {'IMG_0014_1.tif': 0.212, 'IMG_0011_1.tif': 0.27, 'IMG_0017_1.tif': 0.415, 'IMG_0019_1.tif': 0.421, 'IMG_0013_1.tif': 0.596, 'IMG_0020_1.tif': 0.637, 'IMG_0018_1.tif': 0.72, 'IMG_0022_1.tif': 0.749, 'IMG_0016_1.tif': 0.786, 'IMG_0021_1.tif': 0.792, 'IMG_0004_1.tif': 0.817, 'IMG_0005_1.tif': 0.888, 'IMG_0010_1.tif': 0.98, 'IMG_0015_1.tif': 0.993, 'IMG_0006_1.tif': 1.098, 'IMG_0009_1.tif': 1.172, 'IMG_0023_1.tif': 1.201, 'IMG_0008_1.tif': 1.489, 'IMG_0007_1.tif': 1.628, 'IMG_0003_1.tif': 50.018}
IMG_0013_1.tif {'IMG_0020_1.tif': 0.041, 'IMG_0018_1.tif': 0.124, 'IMG_0022_1.tif': 0.153, 'IMG_0019_1.tif': 0.175, 'IMG_0021_1.tif': 0.196, 'IMG_0012_1.tif': 0.596, 'IMG_0023_1.tif': 0.605, 'IMG_0014_1.tif': 0.808, 'IMG_0011_1.tif': 0.866, 'IMG_0017_1.tif': 1.011, 'IMG_0016_1.tif': 1.382, 'IMG_0004_1.tif': 1.413, 'IMG_0005_1.tif': 1.484, 'IMG_0010_1.tif': 1.576, 'IMG_0015_1.tif': 1.589, 'IMG_0006_1.tif': 1.694, 'IMG_0009_1.tif': 1.768, 'IMG_0008_1.tif': 2.085, 'IMG_0007_1.tif': 2.224, 'IMG_0003_1.tif': 49.422}
IMG_0014_1.tif {'IMG_0011_1.tif': 0.058, 'IMG_0017_1.tif': 0.203, 'IMG_0012_1.tif': 0.212, 'IMG_0016_1.tif': 0.574, 'IMG_0004_1.tif': 0.605, 'IMG_0019_1.tif': 0.633, 'IMG_0005_1.tif': 0.676, 'IMG_0010_1.tif': 0.768, 'IMG_0015_1.tif': 0.781, 'IMG_0013_1.tif': 0.808, 'IMG_0020_1.tif': 0.849, 'IMG_0006_1.tif': 0.886, 'IMG_0018_1.tif': 0.932, 'IMG_0009_1.tif': 0.96, 'IMG_0022_1.tif': 0.961, 'IMG_0021_1.tif': 1.004, 'IMG_0008_1.tif': 1.277, 'IMG_0023_1.tif': 1.413, 'IMG_0007_1.tif': 1.416, 'IMG_0003_1.tif': 50.23}
IMG_0015_1.tif {'IMG_0010_1.tif': 0.013, 'IMG_0005_1.tif': 0.105, 'IMG_0006_1.tif': 0.105, 'IMG_0004_1.tif': 0.176, 'IMG_0009_1.tif': 0.179, 'IMG_0016_1.tif': 0.207, 'IMG_0008_1.tif': 0.496, 'IMG_0017_1.tif': 0.578, 'IMG_0007_1.tif': 0.635, 'IMG_0011_1.tif': 0.723, 'IMG_0014_1.tif': 0.781, 'IMG_0012_1.tif': 0.993, 'IMG_0019_1.tif': 1.414, 'IMG_0013_1.tif': 1.589, 'IMG_0020_1.tif': 1.63, 'IMG_0018_1.tif': 1.713, 'IMG_0022_1.tif': 1.742, 'IMG_0021_1.tif': 1.785, 'IMG_0023_1.tif': 2.194, 'IMG_0003_1.tif': 51.011}
IMG_0016_1.tif {'IMG_0004_1.tif': 0.031, 'IMG_0005_1.tif': 0.102, 'IMG_0010_1.tif': 0.194, 'IMG_0015_1.tif': 0.207, 'IMG_0006_1.tif': 0.312, 'IMG_0017_1.tif': 0.371, 'IMG_0009_1.tif': 0.386, 'IMG_0011_1.tif': 0.516, 'IMG_0014_1.tif': 0.574, 'IMG_0008_1.tif': 0.703, 'IMG_0012_1.tif': 0.786, 'IMG_0007_1.tif': 0.842, 'IMG_0019_1.tif': 1.207, 'IMG_0013_1.tif': 1.382, 'IMG_0020_1.tif': 1.423, 'IMG_0018_1.tif': 1.506, 'IMG_0022_1.tif': 1.535, 'IMG_0021_1.tif': 1.578, 'IMG_0023_1.tif': 1.987, 'IMG_0003_1.tif': 50.804}
IMG_0017_1.tif {'IMG_0011_1.tif': 0.145, 'IMG_0014_1.tif': 0.203, 'IMG_0016_1.tif': 0.371, 'IMG_0004_1.tif': 0.402, 'IMG_0012_1.tif': 0.415, 'IMG_0005_1.tif': 0.473, 'IMG_0010_1.tif': 0.565, 'IMG_0015_1.tif': 0.578, 'IMG_0006_1.tif': 0.683, 'IMG_0009_1.tif': 0.757, 'IMG_0019_1.tif': 0.836, 'IMG_0013_1.tif': 1.011, 'IMG_0020_1.tif': 1.052, 'IMG_0008_1.tif': 1.074, 'IMG_0018_1.tif': 1.135, 'IMG_0022_1.tif': 1.164, 'IMG_0021_1.tif': 1.207, 'IMG_0007_1.tif': 1.213, 'IMG_0023_1.tif': 1.616, 'IMG_0003_1.tif': 50.433}
IMG_0018_1.tif {'IMG_0022_1.tif': 0.029, 'IMG_0021_1.tif': 0.072, 'IMG_0020_1.tif': 0.083, 'IMG_0013_1.tif': 0.124, 'IMG_0019_1.tif': 0.299, 'IMG_0023_1.tif': 0.481, 'IMG_0012_1.tif': 0.72, 'IMG_0014_1.tif': 0.932, 'IMG_0011_1.tif': 0.99, 'IMG_0017_1.tif': 1.135, 'IMG_0016_1.tif': 1.506, 'IMG_0004_1.tif': 1.537, 'IMG_0005_1.tif': 1.608, 'IMG_0010_1.tif': 1.7, 'IMG_0015_1.tif': 1.713, 'IMG_0006_1.tif': 1.818, 'IMG_0009_1.tif': 1.892, 'IMG_0008_1.tif': 2.209, 'IMG_0007_1.tif': 2.348, 'IMG_0003_1.tif': 49.298}
IMG_0019_1.tif {'IMG_0013_1.tif': 0.175, 'IMG_0020_1.tif': 0.216, 'IMG_0018_1.tif': 0.299, 'IMG_0022_1.tif': 0.328, 'IMG_0021_1.tif': 0.371, 'IMG_0012_1.tif': 0.421, 'IMG_0014_1.tif': 0.633, 'IMG_0011_1.tif': 0.691, 'IMG_0023_1.tif': 0.78, 'IMG_0017_1.tif': 0.836, 'IMG_0016_1.tif': 1.207, 'IMG_0004_1.tif': 1.238, 'IMG_0005_1.tif': 1.309, 'IMG_0010_1.tif': 1.401, 'IMG_0015_1.tif': 1.414, 'IMG_0006_1.tif': 1.519, 'IMG_0009_1.tif': 1.593, 'IMG_0008_1.tif': 1.91, 'IMG_0007_1.tif': 2.049, 'IMG_0003_1.tif': 49.597}
IMG_0020_1.tif {'IMG_0013_1.tif': 0.041, 'IMG_0018_1.tif': 0.083, 'IMG_0022_1.tif': 0.112, 'IMG_0021_1.tif': 0.155, 'IMG_0019_1.tif': 0.216, 'IMG_0023_1.tif': 0.563, 'IMG_0012_1.tif': 0.637, 'IMG_0014_1.tif': 0.849, 'IMG_0011_1.tif': 0.907, 'IMG_0017_1.tif': 1.052, 'IMG_0016_1.tif': 1.423, 'IMG_0004_1.tif': 1.455, 'IMG_0005_1.tif': 1.525, 'IMG_0010_1.tif': 1.617, 'IMG_0015_1.tif': 1.63, 'IMG_0006_1.tif': 1.735, 'IMG_0009_1.tif': 1.809, 'IMG_0008_1.tif': 2.126, 'IMG_0007_1.tif': 2.265, 'IMG_0003_1.tif': 49.381}
IMG_0021_1.tif {'IMG_0022_1.tif': 0.043, 'IMG_0018_1.tif': 0.072, 'IMG_0020_1.tif': 0.155, 'IMG_0013_1.tif': 0.196, 'IMG_0019_1.tif': 0.371, 'IMG_0023_1.tif': 0.408, 'IMG_0012_1.tif': 0.792, 'IMG_0014_1.tif': 1.004, 'IMG_0011_1.tif': 1.062, 'IMG_0017_1.tif': 1.207, 'IMG_0016_1.tif': 1.578, 'IMG_0004_1.tif': 1.609, 'IMG_0005_1.tif': 1.68, 'IMG_0010_1.tif': 1.772, 'IMG_0015_1.tif': 1.785, 'IMG_0006_1.tif': 1.89, 'IMG_0009_1.tif': 1.964, 'IMG_0008_1.tif': 2.281, 'IMG_0007_1.tif': 2.42, 'IMG_0003_1.tif': 49.226}
IMG_0022_1.tif {'IMG_0018_1.tif': 0.029, 'IMG_0021_1.tif': 0.043, 'IMG_0020_1.tif': 0.112, 'IMG_0013_1.tif': 0.153, 'IMG_0019_1.tif': 0.328, 'IMG_0023_1.tif': 0.452, 'IMG_0012_1.tif': 0.749, 'IMG_0014_1.tif': 0.961, 'IMG_0011_1.tif': 1.019, 'IMG_0017_1.tif': 1.164, 'IMG_0016_1.tif': 1.535, 'IMG_0004_1.tif': 1.566, 'IMG_0005_1.tif': 1.637, 'IMG_0010_1.tif': 1.729, 'IMG_0015_1.tif': 1.742, 'IMG_0006_1.tif': 1.847, 'IMG_0009_1.tif': 1.921, 'IMG_0008_1.tif': 2.238, 'IMG_0007_1.tif': 2.377, 'IMG_0003_1.tif': 49.269}
IMG_0023_1.tif {'IMG_0021_1.tif': 0.408, 'IMG_0022_1.tif': 0.452, 'IMG_0018_1.tif': 0.481, 'IMG_0020_1.tif': 0.563, 'IMG_0013_1.tif': 0.605, 'IMG_0019_1.tif': 0.78, 'IMG_0012_1.tif': 1.201, 'IMG_0014_1.tif': 1.413, 'IMG_0011_1.tif': 1.471, 'IMG_0017_1.tif': 1.616, 'IMG_0016_1.tif': 1.987, 'IMG_0004_1.tif': 2.018, 'IMG_0005_1.tif': 2.089, 'IMG_0010_1.tif': 2.181, 'IMG_0015_1.tif': 2.194, 'IMG_0006_1.tif': 2.299, 'IMG_0009_1.tif': 2.373, 'IMG_0008_1.tif': 2.69, 'IMG_0007_1.tif': 2.829, 'IMG_0003_1.tif': 48.817}
此解决方案的一个可能改进可能不是重复已经在两点之间执行的计算(例如比较点 1 和点 2,然后比较点 2 和点 1),而是识别何时已执行操作并检索数据
我有一个字典列表,其中键是图像名称,值是来自 exif 的坐标。
{'IMG_0003_1.tif': {'Latitude': 46.292602599999995, 'Longitude': -119.7299495, 'Altitude': 426.316}}
{'IMG_0004_1.tif': {'Latitude': 46.29282, 'Longitude': -119.7301617, 'Altitude': 477.151}}
{'IMG_0005_1.tif': {'Latitude': 46.2929581, 'Longitude': -119.7303228, 'Altitude': 477.222}}
{'IMG_0006_1.tif': {'Latitude': 46.2931217, 'Longitude': -119.7304816, 'Altitude': 477.432}}
{'IMG_0007_1.tif': {'Latitude': 46.2932815, 'Longitude': -119.7306418, 'Altitude': 477.962}}
{'IMG_0008_1.tif': {'Latitude': 46.293439299999996, 'Longitude': -119.730806, 'Altitude': 477.823}}
{'IMG_0009_1.tif': {'Latitude': 46.2935699, 'Longitude': -119.730942, 'Altitude': 477.506}}
{'IMG_0010_1.tif': {'Latitude': 46.2937307, 'Longitude': -119.7311043, 'Altitude': 477.314}}
{'IMG_0011_1.tif': {'Latitude': 46.2939978, 'Longitude': -119.7313743, 'Altitude': 476.604}}
{'IMG_0012_1.tif': {'Latitude': 46.2940508, 'Longitude': -119.7314279, 'Altitude': 476.334}}
{'IMG_0013_1.tif': {'Latitude': 46.2942515, 'Longitude': -119.7316253, 'Altitude': 475.738}}
{'IMG_0014_1.tif': {'Latitude': 46.294383599999996, 'Longitude': -119.7317627, 'Altitude': 476.546}}
{'IMG_0015_1.tif': {'Latitude': 46.2945286, 'Longitude': -119.73191200000001, 'Altitude': 477.327}}
{'IMG_0016_1.tif': {'Latitude': 46.294699699999995, 'Longitude': -119.73208890000001, 'Altitude': 477.12}}
{'IMG_0017_1.tif': {'Latitude': 46.294854099999995, 'Longitude': -119.732251, 'Altitude': 476.749}}
{'IMG_0018_1.tif': {'Latitude': 46.294931899999995, 'Longitude': -119.7323415, 'Altitude': 475.614}}
{'IMG_0019_1.tif': {'Latitude': 46.2949305, 'Longitude': -119.73230360000001, 'Altitude': 475.913}}
{'IMG_0020_1.tif': {'Latitude': 46.294931299999995, 'Longitude': -119.7317773, 'Altitude': 475.696}}
{'IMG_0021_1.tif': {'Latitude': 46.294931399999996, 'Longitude': -119.7316604, 'Altitude': 475.541}}
{'IMG_0022_1.tif': {'Latitude': 46.2949279, 'Longitude': -119.7314008, 'Altitude': 475.584}}
{'IMG_0023_1.tif': {'Latitude': 46.2949282, 'Longitude': -119.7311443, 'Altitude': 475.132}}
现在我需要根据坐标为每个图像找到最近的两个。如何在 python 中完成?我什至不知道从哪里开始...
首先,我建议您将数据重新格式化为以图像名称为键的大字典,而不是一堆字典。
data = {'IMG_0003_1.tif': {'Latitude': 46.292602599999995, 'Longitude': -119.7299495, 'Altitude': 426.316},
'IMG_0004_1.tif': {'Latitude': 46.29282, 'Longitude': -119.7301617, 'Altitude': 477.151},
'IMG_0005_1.tif': {'Latitude': 46.2929581, 'Longitude': -119.7303228, 'Altitude': 477.222},
'IMG_0006_1.tif': {'Latitude': 46.2931217, 'Longitude': -119.7304816, 'Altitude': 477.432},
'IMG_0007_1.tif': {'Latitude': 46.2932815, 'Longitude': -119.7306418, 'Altitude': 477.962},
'IMG_0008_1.tif': {'Latitude': 46.293439299999996, 'Longitude': -119.730806, 'Altitude': 477.823},
'IMG_0009_1.tif': {'Latitude': 46.2935699, 'Longitude': -119.730942, 'Altitude': 477.506},
'IMG_0010_1.tif': {'Latitude': 46.2937307, 'Longitude': -119.7311043, 'Altitude': 477.314},
'IMG_0011_1.tif': {'Latitude': 46.2939978, 'Longitude': -119.7313743, 'Altitude': 476.604},
'IMG_0012_1.tif': {'Latitude': 46.2940508, 'Longitude': -119.7314279, 'Altitude': 476.334},
'IMG_0013_1.tif': {'Latitude': 46.2942515, 'Longitude': -119.7316253, 'Altitude': 475.738},
'IMG_0014_1.tif': {'Latitude': 46.294383599999996, 'Longitude': -119.7317627, 'Altitude': 476.546},
'IMG_0015_1.tif': {'Latitude': 46.2945286, 'Longitude': -119.73191200000001, 'Altitude': 477.327},
'IMG_0016_1.tif': {'Latitude': 46.294699699999995, 'Longitude': -119.73208890000001, 'Altitude': 477.12},
'IMG_0017_1.tif': {'Latitude': 46.294854099999995, 'Longitude': -119.732251, 'Altitude': 476.749},
'IMG_0018_1.tif': {'Latitude': 46.294931899999995, 'Longitude': -119.7323415, 'Altitude': 475.614},
'IMG_0019_1.tif': {'Latitude': 46.2949305, 'Longitude': -119.73230360000001, 'Altitude': 475.913},
'IMG_0020_1.tif': {'Latitude': 46.294931299999995, 'Longitude': -119.7317773, 'Altitude': 475.696},
'IMG_0021_1.tif': {'Latitude': 46.294931399999996, 'Longitude': -119.7316604, 'Altitude': 475.541},
'IMG_0022_1.tif': {'Latitude': 46.2949279, 'Longitude': -119.7314008, 'Altitude': 475.584},
'IMG_0023_1.tif': {'Latitude': 46.2949282, 'Longitude': -119.7311443, 'Altitude': 475.132}}
之后,首先要做的是创建一个可以计算两个图像之间距离的函数:
def calculate_distance(first_location, second_location):
distance = (second_location["Latitude"] - first_location["Latitude"]) + (second_location["Longitude"] - first_location["Longitude"]) + (second_location["Altitude"] - first_location["Altitude"])
return abs(round(distance, 3))
一个可能的解决方案,(请注意:这不是最有效的解决方案,但它是一个简单的解决方案)代码的核心可以迭代所有元素并比较所有图像之间的距离。之后,您可以对每个图像的结果进行排序。这样,您将得到一个按每个图像的值排序的字典。 (请注意,我没有提取前两个最近的元素,但我给你留下了整个字典)
final_distances = {}
for element, element_value in data.items():
final_distances[element] = {}
for compare, compare_value in data.items():
if compare != element:
final_distances[element][compare] = calculate_distance(element_value, compare_value)
final_distances[element] = {k: v for k, v in sorted(final_distances[element].items(), key=lambda item: item[1])}
for key, value in final_distances.items():
print(key, value)
所以输出将是:
IMG_0003_1.tif {'IMG_0023_1.tif': 48.817, 'IMG_0021_1.tif': 49.226, 'IMG_0022_1.tif': 49.269, 'IMG_0018_1.tif': 49.298, 'IMG_0020_1.tif': 49.381, 'IMG_0013_1.tif': 49.422, 'IMG_0019_1.tif': 49.597, 'IMG_0012_1.tif': 50.018, 'IMG_0014_1.tif': 50.23, 'IMG_0011_1.tif': 50.288, 'IMG_0017_1.tif': 50.433, 'IMG_0016_1.tif': 50.804, 'IMG_0004_1.tif': 50.835, 'IMG_0005_1.tif': 50.906, 'IMG_0010_1.tif': 50.998, 'IMG_0015_1.tif': 51.011, 'IMG_0006_1.tif': 51.116, 'IMG_0009_1.tif': 51.19, 'IMG_0008_1.tif': 51.507, 'IMG_0007_1.tif': 51.646}
IMG_0004_1.tif {'IMG_0016_1.tif': 0.031, 'IMG_0005_1.tif': 0.071, 'IMG_0010_1.tif': 0.163, 'IMG_0015_1.tif': 0.176, 'IMG_0006_1.tif': 0.281, 'IMG_0009_1.tif': 0.355, 'IMG_0017_1.tif': 0.402, 'IMG_0011_1.tif': 0.547, 'IMG_0014_1.tif': 0.605, 'IMG_0008_1.tif': 0.672, 'IMG_0007_1.tif': 0.811, 'IMG_0012_1.tif': 0.817, 'IMG_0019_1.tif': 1.238, 'IMG_0013_1.tif': 1.413, 'IMG_0020_1.tif': 1.455, 'IMG_0018_1.tif': 1.537, 'IMG_0022_1.tif': 1.566, 'IMG_0021_1.tif': 1.609, 'IMG_0023_1.tif': 2.018, 'IMG_0003_1.tif': 50.835}
IMG_0005_1.tif {'IMG_0004_1.tif': 0.071, 'IMG_0010_1.tif': 0.092, 'IMG_0016_1.tif': 0.102, 'IMG_0015_1.tif': 0.105, 'IMG_0006_1.tif': 0.21, 'IMG_0009_1.tif': 0.284, 'IMG_0017_1.tif': 0.473, 'IMG_0008_1.tif': 0.601, 'IMG_0011_1.tif': 0.618, 'IMG_0014_1.tif': 0.676, 'IMG_0007_1.tif': 0.74, 'IMG_0012_1.tif': 0.888, 'IMG_0019_1.tif': 1.309, 'IMG_0013_1.tif': 1.484, 'IMG_0020_1.tif': 1.525, 'IMG_0018_1.tif': 1.608, 'IMG_0022_1.tif': 1.637, 'IMG_0021_1.tif': 1.68, 'IMG_0023_1.tif': 2.089, 'IMG_0003_1.tif': 50.906}
IMG_0006_1.tif {'IMG_0009_1.tif': 0.074, 'IMG_0015_1.tif': 0.105, 'IMG_0010_1.tif': 0.118, 'IMG_0005_1.tif': 0.21, 'IMG_0004_1.tif': 0.281, 'IMG_0016_1.tif': 0.312, 'IMG_0008_1.tif': 0.391, 'IMG_0007_1.tif': 0.53, 'IMG_0017_1.tif': 0.683, 'IMG_0011_1.tif': 0.828, 'IMG_0014_1.tif': 0.886, 'IMG_0012_1.tif': 1.098, 'IMG_0019_1.tif': 1.519, 'IMG_0013_1.tif': 1.694, 'IMG_0020_1.tif': 1.735, 'IMG_0018_1.tif': 1.818, 'IMG_0022_1.tif': 1.847, 'IMG_0021_1.tif': 1.89, 'IMG_0023_1.tif': 2.299, 'IMG_0003_1.tif': 51.116}
IMG_0007_1.tif {'IMG_0008_1.tif': 0.139, 'IMG_0009_1.tif': 0.456, 'IMG_0006_1.tif': 0.53, 'IMG_0015_1.tif': 0.635, 'IMG_0010_1.tif': 0.648, 'IMG_0005_1.tif': 0.74, 'IMG_0004_1.tif': 0.811, 'IMG_0016_1.tif': 0.842, 'IMG_0017_1.tif': 1.213, 'IMG_0011_1.tif': 1.358, 'IMG_0014_1.tif': 1.416, 'IMG_0012_1.tif': 1.628, 'IMG_0019_1.tif': 2.049, 'IMG_0013_1.tif': 2.224, 'IMG_0020_1.tif': 2.265, 'IMG_0018_1.tif': 2.348, 'IMG_0022_1.tif': 2.377, 'IMG_0021_1.tif': 2.42, 'IMG_0023_1.tif': 2.829, 'IMG_0003_1.tif': 51.646}
IMG_0008_1.tif {'IMG_0007_1.tif': 0.139, 'IMG_0009_1.tif': 0.317, 'IMG_0006_1.tif': 0.391, 'IMG_0015_1.tif': 0.496, 'IMG_0010_1.tif': 0.509, 'IMG_0005_1.tif': 0.601, 'IMG_0004_1.tif': 0.672, 'IMG_0016_1.tif': 0.703, 'IMG_0017_1.tif': 1.074, 'IMG_0011_1.tif': 1.219, 'IMG_0014_1.tif': 1.277, 'IMG_0012_1.tif': 1.489, 'IMG_0019_1.tif': 1.91, 'IMG_0013_1.tif': 2.085, 'IMG_0020_1.tif': 2.126, 'IMG_0018_1.tif': 2.209, 'IMG_0022_1.tif': 2.238, 'IMG_0021_1.tif': 2.281, 'IMG_0023_1.tif': 2.69, 'IMG_0003_1.tif': 51.507}
IMG_0009_1.tif {'IMG_0006_1.tif': 0.074, 'IMG_0015_1.tif': 0.179, 'IMG_0010_1.tif': 0.192, 'IMG_0005_1.tif': 0.284, 'IMG_0008_1.tif': 0.317, 'IMG_0004_1.tif': 0.355, 'IMG_0016_1.tif': 0.386, 'IMG_0007_1.tif': 0.456, 'IMG_0017_1.tif': 0.757, 'IMG_0011_1.tif': 0.902, 'IMG_0014_1.tif': 0.96, 'IMG_0012_1.tif': 1.172, 'IMG_0019_1.tif': 1.593, 'IMG_0013_1.tif': 1.768, 'IMG_0020_1.tif': 1.809, 'IMG_0018_1.tif': 1.892, 'IMG_0022_1.tif': 1.921, 'IMG_0021_1.tif': 1.964, 'IMG_0023_1.tif': 2.373, 'IMG_0003_1.tif': 51.19}
IMG_0010_1.tif {'IMG_0015_1.tif': 0.013, 'IMG_0005_1.tif': 0.092, 'IMG_0006_1.tif': 0.118, 'IMG_0004_1.tif': 0.163, 'IMG_0009_1.tif': 0.192, 'IMG_0016_1.tif': 0.194, 'IMG_0008_1.tif': 0.509, 'IMG_0017_1.tif': 0.565, 'IMG_0007_1.tif': 0.648, 'IMG_0011_1.tif': 0.71, 'IMG_0014_1.tif': 0.768, 'IMG_0012_1.tif': 0.98, 'IMG_0019_1.tif': 1.401, 'IMG_0013_1.tif': 1.576, 'IMG_0020_1.tif': 1.617, 'IMG_0018_1.tif': 1.7, 'IMG_0022_1.tif': 1.729, 'IMG_0021_1.tif': 1.772, 'IMG_0023_1.tif': 2.181, 'IMG_0003_1.tif': 50.998}
IMG_0011_1.tif {'IMG_0014_1.tif': 0.058, 'IMG_0017_1.tif': 0.145, 'IMG_0012_1.tif': 0.27, 'IMG_0016_1.tif': 0.516, 'IMG_0004_1.tif': 0.547, 'IMG_0005_1.tif': 0.618, 'IMG_0019_1.tif': 0.691, 'IMG_0010_1.tif': 0.71, 'IMG_0015_1.tif': 0.723, 'IMG_0006_1.tif': 0.828, 'IMG_0013_1.tif': 0.866, 'IMG_0009_1.tif': 0.902, 'IMG_0020_1.tif': 0.907, 'IMG_0018_1.tif': 0.99, 'IMG_0022_1.tif': 1.019, 'IMG_0021_1.tif': 1.062, 'IMG_0008_1.tif': 1.219, 'IMG_0007_1.tif': 1.358, 'IMG_0023_1.tif': 1.471, 'IMG_0003_1.tif': 50.288}
IMG_0012_1.tif {'IMG_0014_1.tif': 0.212, 'IMG_0011_1.tif': 0.27, 'IMG_0017_1.tif': 0.415, 'IMG_0019_1.tif': 0.421, 'IMG_0013_1.tif': 0.596, 'IMG_0020_1.tif': 0.637, 'IMG_0018_1.tif': 0.72, 'IMG_0022_1.tif': 0.749, 'IMG_0016_1.tif': 0.786, 'IMG_0021_1.tif': 0.792, 'IMG_0004_1.tif': 0.817, 'IMG_0005_1.tif': 0.888, 'IMG_0010_1.tif': 0.98, 'IMG_0015_1.tif': 0.993, 'IMG_0006_1.tif': 1.098, 'IMG_0009_1.tif': 1.172, 'IMG_0023_1.tif': 1.201, 'IMG_0008_1.tif': 1.489, 'IMG_0007_1.tif': 1.628, 'IMG_0003_1.tif': 50.018}
IMG_0013_1.tif {'IMG_0020_1.tif': 0.041, 'IMG_0018_1.tif': 0.124, 'IMG_0022_1.tif': 0.153, 'IMG_0019_1.tif': 0.175, 'IMG_0021_1.tif': 0.196, 'IMG_0012_1.tif': 0.596, 'IMG_0023_1.tif': 0.605, 'IMG_0014_1.tif': 0.808, 'IMG_0011_1.tif': 0.866, 'IMG_0017_1.tif': 1.011, 'IMG_0016_1.tif': 1.382, 'IMG_0004_1.tif': 1.413, 'IMG_0005_1.tif': 1.484, 'IMG_0010_1.tif': 1.576, 'IMG_0015_1.tif': 1.589, 'IMG_0006_1.tif': 1.694, 'IMG_0009_1.tif': 1.768, 'IMG_0008_1.tif': 2.085, 'IMG_0007_1.tif': 2.224, 'IMG_0003_1.tif': 49.422}
IMG_0014_1.tif {'IMG_0011_1.tif': 0.058, 'IMG_0017_1.tif': 0.203, 'IMG_0012_1.tif': 0.212, 'IMG_0016_1.tif': 0.574, 'IMG_0004_1.tif': 0.605, 'IMG_0019_1.tif': 0.633, 'IMG_0005_1.tif': 0.676, 'IMG_0010_1.tif': 0.768, 'IMG_0015_1.tif': 0.781, 'IMG_0013_1.tif': 0.808, 'IMG_0020_1.tif': 0.849, 'IMG_0006_1.tif': 0.886, 'IMG_0018_1.tif': 0.932, 'IMG_0009_1.tif': 0.96, 'IMG_0022_1.tif': 0.961, 'IMG_0021_1.tif': 1.004, 'IMG_0008_1.tif': 1.277, 'IMG_0023_1.tif': 1.413, 'IMG_0007_1.tif': 1.416, 'IMG_0003_1.tif': 50.23}
IMG_0015_1.tif {'IMG_0010_1.tif': 0.013, 'IMG_0005_1.tif': 0.105, 'IMG_0006_1.tif': 0.105, 'IMG_0004_1.tif': 0.176, 'IMG_0009_1.tif': 0.179, 'IMG_0016_1.tif': 0.207, 'IMG_0008_1.tif': 0.496, 'IMG_0017_1.tif': 0.578, 'IMG_0007_1.tif': 0.635, 'IMG_0011_1.tif': 0.723, 'IMG_0014_1.tif': 0.781, 'IMG_0012_1.tif': 0.993, 'IMG_0019_1.tif': 1.414, 'IMG_0013_1.tif': 1.589, 'IMG_0020_1.tif': 1.63, 'IMG_0018_1.tif': 1.713, 'IMG_0022_1.tif': 1.742, 'IMG_0021_1.tif': 1.785, 'IMG_0023_1.tif': 2.194, 'IMG_0003_1.tif': 51.011}
IMG_0016_1.tif {'IMG_0004_1.tif': 0.031, 'IMG_0005_1.tif': 0.102, 'IMG_0010_1.tif': 0.194, 'IMG_0015_1.tif': 0.207, 'IMG_0006_1.tif': 0.312, 'IMG_0017_1.tif': 0.371, 'IMG_0009_1.tif': 0.386, 'IMG_0011_1.tif': 0.516, 'IMG_0014_1.tif': 0.574, 'IMG_0008_1.tif': 0.703, 'IMG_0012_1.tif': 0.786, 'IMG_0007_1.tif': 0.842, 'IMG_0019_1.tif': 1.207, 'IMG_0013_1.tif': 1.382, 'IMG_0020_1.tif': 1.423, 'IMG_0018_1.tif': 1.506, 'IMG_0022_1.tif': 1.535, 'IMG_0021_1.tif': 1.578, 'IMG_0023_1.tif': 1.987, 'IMG_0003_1.tif': 50.804}
IMG_0017_1.tif {'IMG_0011_1.tif': 0.145, 'IMG_0014_1.tif': 0.203, 'IMG_0016_1.tif': 0.371, 'IMG_0004_1.tif': 0.402, 'IMG_0012_1.tif': 0.415, 'IMG_0005_1.tif': 0.473, 'IMG_0010_1.tif': 0.565, 'IMG_0015_1.tif': 0.578, 'IMG_0006_1.tif': 0.683, 'IMG_0009_1.tif': 0.757, 'IMG_0019_1.tif': 0.836, 'IMG_0013_1.tif': 1.011, 'IMG_0020_1.tif': 1.052, 'IMG_0008_1.tif': 1.074, 'IMG_0018_1.tif': 1.135, 'IMG_0022_1.tif': 1.164, 'IMG_0021_1.tif': 1.207, 'IMG_0007_1.tif': 1.213, 'IMG_0023_1.tif': 1.616, 'IMG_0003_1.tif': 50.433}
IMG_0018_1.tif {'IMG_0022_1.tif': 0.029, 'IMG_0021_1.tif': 0.072, 'IMG_0020_1.tif': 0.083, 'IMG_0013_1.tif': 0.124, 'IMG_0019_1.tif': 0.299, 'IMG_0023_1.tif': 0.481, 'IMG_0012_1.tif': 0.72, 'IMG_0014_1.tif': 0.932, 'IMG_0011_1.tif': 0.99, 'IMG_0017_1.tif': 1.135, 'IMG_0016_1.tif': 1.506, 'IMG_0004_1.tif': 1.537, 'IMG_0005_1.tif': 1.608, 'IMG_0010_1.tif': 1.7, 'IMG_0015_1.tif': 1.713, 'IMG_0006_1.tif': 1.818, 'IMG_0009_1.tif': 1.892, 'IMG_0008_1.tif': 2.209, 'IMG_0007_1.tif': 2.348, 'IMG_0003_1.tif': 49.298}
IMG_0019_1.tif {'IMG_0013_1.tif': 0.175, 'IMG_0020_1.tif': 0.216, 'IMG_0018_1.tif': 0.299, 'IMG_0022_1.tif': 0.328, 'IMG_0021_1.tif': 0.371, 'IMG_0012_1.tif': 0.421, 'IMG_0014_1.tif': 0.633, 'IMG_0011_1.tif': 0.691, 'IMG_0023_1.tif': 0.78, 'IMG_0017_1.tif': 0.836, 'IMG_0016_1.tif': 1.207, 'IMG_0004_1.tif': 1.238, 'IMG_0005_1.tif': 1.309, 'IMG_0010_1.tif': 1.401, 'IMG_0015_1.tif': 1.414, 'IMG_0006_1.tif': 1.519, 'IMG_0009_1.tif': 1.593, 'IMG_0008_1.tif': 1.91, 'IMG_0007_1.tif': 2.049, 'IMG_0003_1.tif': 49.597}
IMG_0020_1.tif {'IMG_0013_1.tif': 0.041, 'IMG_0018_1.tif': 0.083, 'IMG_0022_1.tif': 0.112, 'IMG_0021_1.tif': 0.155, 'IMG_0019_1.tif': 0.216, 'IMG_0023_1.tif': 0.563, 'IMG_0012_1.tif': 0.637, 'IMG_0014_1.tif': 0.849, 'IMG_0011_1.tif': 0.907, 'IMG_0017_1.tif': 1.052, 'IMG_0016_1.tif': 1.423, 'IMG_0004_1.tif': 1.455, 'IMG_0005_1.tif': 1.525, 'IMG_0010_1.tif': 1.617, 'IMG_0015_1.tif': 1.63, 'IMG_0006_1.tif': 1.735, 'IMG_0009_1.tif': 1.809, 'IMG_0008_1.tif': 2.126, 'IMG_0007_1.tif': 2.265, 'IMG_0003_1.tif': 49.381}
IMG_0021_1.tif {'IMG_0022_1.tif': 0.043, 'IMG_0018_1.tif': 0.072, 'IMG_0020_1.tif': 0.155, 'IMG_0013_1.tif': 0.196, 'IMG_0019_1.tif': 0.371, 'IMG_0023_1.tif': 0.408, 'IMG_0012_1.tif': 0.792, 'IMG_0014_1.tif': 1.004, 'IMG_0011_1.tif': 1.062, 'IMG_0017_1.tif': 1.207, 'IMG_0016_1.tif': 1.578, 'IMG_0004_1.tif': 1.609, 'IMG_0005_1.tif': 1.68, 'IMG_0010_1.tif': 1.772, 'IMG_0015_1.tif': 1.785, 'IMG_0006_1.tif': 1.89, 'IMG_0009_1.tif': 1.964, 'IMG_0008_1.tif': 2.281, 'IMG_0007_1.tif': 2.42, 'IMG_0003_1.tif': 49.226}
IMG_0022_1.tif {'IMG_0018_1.tif': 0.029, 'IMG_0021_1.tif': 0.043, 'IMG_0020_1.tif': 0.112, 'IMG_0013_1.tif': 0.153, 'IMG_0019_1.tif': 0.328, 'IMG_0023_1.tif': 0.452, 'IMG_0012_1.tif': 0.749, 'IMG_0014_1.tif': 0.961, 'IMG_0011_1.tif': 1.019, 'IMG_0017_1.tif': 1.164, 'IMG_0016_1.tif': 1.535, 'IMG_0004_1.tif': 1.566, 'IMG_0005_1.tif': 1.637, 'IMG_0010_1.tif': 1.729, 'IMG_0015_1.tif': 1.742, 'IMG_0006_1.tif': 1.847, 'IMG_0009_1.tif': 1.921, 'IMG_0008_1.tif': 2.238, 'IMG_0007_1.tif': 2.377, 'IMG_0003_1.tif': 49.269}
IMG_0023_1.tif {'IMG_0021_1.tif': 0.408, 'IMG_0022_1.tif': 0.452, 'IMG_0018_1.tif': 0.481, 'IMG_0020_1.tif': 0.563, 'IMG_0013_1.tif': 0.605, 'IMG_0019_1.tif': 0.78, 'IMG_0012_1.tif': 1.201, 'IMG_0014_1.tif': 1.413, 'IMG_0011_1.tif': 1.471, 'IMG_0017_1.tif': 1.616, 'IMG_0016_1.tif': 1.987, 'IMG_0004_1.tif': 2.018, 'IMG_0005_1.tif': 2.089, 'IMG_0010_1.tif': 2.181, 'IMG_0015_1.tif': 2.194, 'IMG_0006_1.tif': 2.299, 'IMG_0009_1.tif': 2.373, 'IMG_0008_1.tif': 2.69, 'IMG_0007_1.tif': 2.829, 'IMG_0003_1.tif': 48.817}
此解决方案的一个可能改进可能不是重复已经在两点之间执行的计算(例如比较点 1 和点 2,然后比较点 2 和点 1),而是识别何时已执行操作并检索数据