<p><strong>Premise</strong></p>

<p>I'll focus my answer on the image processing part, as I believe implementation details e.g. traversing a file system is not the core of your problem. Also, all that follows is just my humble opinion, I am sure that there are better ways to retrieve your image of which I am not aware. Anyway, I agree with what your prof said and I'll follow the same line of thought, so I'll share some ideas on possible similarity indexes you might use.</p>

<p><strong>Answer</strong></p>

<ul>
<li><em>MSE and SSIM</em> - This is a possible solution, as suggested by your prof. As I assume the low quality images also have a different resolution than the good ones, remember to downsample the good ones (and not upsample the bad ones).</li>
<li><em>Image subtraction (1-norm distance)</em> - Subtract two images -> if they are equal you'll get a black image. If they are slightly different, the non-black pixels (or the sum of the pixel intensity) can be used as a similarity index. This is actually the 1-norm distance.</li>
<li><em>Histogram distance</em> - You can refer to this paper: <a href="https://www.cse.huji.ac.il/~werman/Papers/ECCV2010.pdf" rel="nofollow noreferrer">https://www.cse.huji.ac.il/~werman/Papers/ECCV2010.pdf</a>. Comparing two images' histograms might be potentially robust for your task. Check out this question too: <a href="https://stackoverflow.com/questions/6499491/comparing-two-histograms">Comparing two histograms</a></li>
<li><em>Embedding learning</em> - As I see you included tensorflow, keras or pytorch as tags, let's consider deep learning. This paper came to my
mind: <a href="https://arxiv.org/pdf/1503.03832.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/1503.03832.pdf</a> The idea is to learn a
mapping from the image space to a Euclidian space - i.e. compute an
embedding of the image. In the embedding hyperspace, images are
points. This paper learns an embedding function by minimizing the
triplet loss. The triplet loss is meant to maximize the distance
between images of different classes and minimize the distance between
images of the same class. You could train the same model on a Dataset
like ImageNet. You could augment the dataset with by lowering the
quality of the images, in order to make the model "invariant" to
difference in image quality (e.g. down-sampling followed by
up-sampling, image compression, adding noise, etc.). Once you can
compute embedding, you could compute the Euclidian distance (as a
substitute of the MSE). This <strong>might</strong> work better than using MSE/SSIM as a similarity indexes. Repo of FaceNet: <a href="https://github.com/timesler/facenet-pytorch" rel="nofollow noreferrer">https://github.com/timesler/facenet-pytorch</a>. Another general purpose approach (not related to faces) which might help you: <a href="https://github.com/zegami/image-similarity-clustering" rel="nofollow noreferrer">https://github.com/zegami/image-similarity-clustering</a>. </li>
<li><em>Siamese networks for predicting similarity score</em> - I am referring to this paper on face verification: <a href="http://bmvc2018.org/contents/papers/0410.pdf" rel="nofollow noreferrer">http://bmvc2018.org/contents/papers/0410.pdf</a>. The siamese network takes two images as input and outputs a value in the [0, 1]. We can interpret the output as the probability that the two images belong to the same class. You can train a model of this kind to predict 1 for image pairs of the following kind: (good quality image, artificially degraded image). To degrade the image, again, you can combine e.g. down-sampling followed by
up-sampling, image compression, adding noise, etc. Let the model predict 0 for image pairs of different classes (e.g. different images). The output of the network can e used as a similarity index. </li>
</ul>

<p><strong>Remark 1</strong></p>

<p>These different approaches can also be combined. They all provide you with similarity indexes, so you can very easily average the outcomes.</p>

<p><strong>Remark 2</strong></p>

<p>If you only need to do it once, the effort you need to put in implementing and training deep models might be not justified. I would not suggest it. Still, you can consider it if you can't find any other solution and that Mac is REALLY FULL of images and a manual search is not possible. </p>
Reverse Image search (for image duplicates) on local computer
<p>I have a bunch of poor quality photos that I extracted from a pdf. Somebody I know has the good quality photo's somewhere on her computer(Mac), but it's my understanding that it will be difficult to find them.</p>
<p>I would like to</p>
<ul>
<li>loop through each poor quality photo</li>
<li>perform a reverse image search using each poor quality photo as the query image and using this persons computer as the database to search for the higher quality images</li>
<li>and create a copy of each high quality image in one destination folder.</li>
</ul>
<p>Example pseudocode</p>
<pre><code>for each image in poorQualityImages:
    search ./macComputer for a higherQualityImage of image
    copy higherQualityImage to ./higherQualityImages
</code></pre>
<p>I need to perform this action once.
I am looking for a <strong>tool, github repo or library</strong> which can perform this functionality more so than a deep understanding of content based image retrieval.</p>
<hr />
<p>There's <a href="https://www.reddit.com/r/DataHoarder/comments/asr5iz/reverse_image_search_for_local_files/" rel="nofollow noreferrer">a post on reddit</a> where someone was trying to do something similar</p>
<p><a href="https://github.com/knjcode/imgdupes" rel="nofollow noreferrer">imgdupes</a> is a program which seems like it almost achieves this, but I do not want to delete the duplicates, I want to copy the highest quality duplicate to a destination folder</p>
<hr />
<p><strong>Update</strong></p>
<p>Emailed my previous image processing prof and he sent me this</p>
<blockquote>
<p>Off the top of my head, nothing out of the box.</p>
<p>No guaranteed solution here, but you can narrow the search space.
You’d need a little program that outputs the MSE or SSIM similarity
index between two images, and then write another program or shell
script that scans the hard drive and computes the MSE between each
image on the hard drive and each query image, then check the images
with the top X percent similarity score.</p>
<p>Something like that.  Still not maybe guaranteed to find everything
you want.  And if the low quality images are of different pixel
dimensions than the high quality images, you’d have to do some image
scaling to get the similarity index.   If the poor quality images have
different aspect ratios, that’s even worse.</p>
<p>So I think it’s not hard but not trivial either.  The degree of
difficulty is partly dependent on the nature of the corruption in the
low quality images.</p>
</blockquote>
<hr />
<p><strong>UPDATE</strong></p>
<p><a href="https://github.com/samgermain/Copy_Duplicate_Images" rel="nofollow noreferrer">Github project I wrote which achieves what I want</a></p>