omar87 commited on
Commit
e20a8b4
·
1 Parent(s): 77a3aec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -8,7 +8,11 @@ def calculate_similarity(img1, img2):
8
  img1 = cv2.cvtColor(img1, cv2.COLOR_GRAY2RGB)
9
  if len(img2.shape) == 2:
10
  img2 = cv2.cvtColor(img2, cv2.COLOR_GRAY2RGB)
11
- similarity_score = ssim(img1, img2, multichannel=True)
 
 
 
 
12
  return similarity_score
13
 
14
  def image_similarity(img1, img2):
 
8
  img1 = cv2.cvtColor(img1, cv2.COLOR_GRAY2RGB)
9
  if len(img2.shape) == 2:
10
  img2 = cv2.cvtColor(img2, cv2.COLOR_GRAY2RGB)
11
+ max_height = max(img1.shape[0], img2.shape[0])
12
+ max_width = max(img1.shape[1], img2.shape[1])
13
+ img1_resized = cv2.resize(img1, (max_width, max_height))
14
+ img2_resized = cv2.resize(img2, (max_width, max_height))
15
+ similarity_score = ssim(img1_resized, img2_resized, multichannel=True)
16
  return similarity_score
17
 
18
  def image_similarity(img1, img2):