I want to compare perceptual hash values that are stored in CSV files: a CSV for each type of modification performed on the image and a CSV for the originals.
How can I extract the hash values from the CSV file when the filename from the Original matches the filename from the modified images CSV?
It is my goal for each hash value for each image in the Original CSV dataset, compare each hash value from each of the other CSV files when and only when the filenames match. So far, I have the filenames matching, but I want to access the data stored in the other columns.
originalImages_path = 'FullPath\Python Project\Images\Original'
path = 'FullPath\Python Project\Images\'
fields = ('Filename', 'aHash', 'pHash', 'wHash', 'DHash', 'ColorHash')
originalImages_CSV = pd.read_csv(originalImages_path + '\Originalimagehashes.csv', usecols=fields)
for AHash_Original in originalImages_CSV.Filename:
AHash_OriginalStrip = AHash_Original.replace('Original', '').split('.')
for folder in os.listdir(path):
if folder != 'Original':
for file in os.listdir(path + folder):
if file.endswith('.csv'):
modifiedImagesCSV = pd.read_csv(path + folder + '\' + file, usecols=fields)
for modifiedImage in modifiedImagesCSV.Filename:
modifiedImageName = modifiedImage.split('_')
if AHash_OriginalStrip(0) == modifiedImageName(0):
print(f'MATCH! {AHash_Original} and {modifiedImage}')
The above code shows me that I can successfully match each original image to its modified version in each of the modified CSVs. I am unsure where to go from here and have been struggling with the logic behind it. The code above is just for aHash, however there are 4 other hash algorithms I have stored and would like to compare.