title: I'm trying to write a script to search a folder full of images and compare them to one specific image and find the image that is the most similar
body: <p>This is what I have so far: the output of the script doesn't even print the difference values yet.</p>
  
  <pre><code>import os
  import sys
  from skimage.measure import compare_ssim
  import cv2
  
  im1 =  cv2.imread("7.jpeg");
  dir= '/Users/Desktop/images'
  //I'm trying to search the specified directory and compare each image 
  in the "images" folder to im1. Then compute the difference between the 
  two images for each image in the folder. Lastly I want the program to 
  output the name of the image that has the smallest difference with im1.
  
  def get_nb_files(dir):
    for r in dir:
        grayA = cv2.cvtColor(im1, cv2.COLOR_BGR2GRAY)
        grayB = cv2.cvtColor(r, cv2.COLOR_BGR2GRAY)
        diff = (diff * 255).astype("uint8")
        (score, diff) = compare_ssim(im1, r, full=True)
        print("SSIM: {}".format(score))
  </code></pre>