Skip to content

Commit

Permalink
updates image comparison script (adds backward compatibility for buil…
Browse files Browse the repository at this point in the history
…dbot checks)
  • Loading branch information
danielpeter committed Oct 28, 2021
1 parent 60180f7 commit 429b37b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions utils/compare_two_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@
raise Exception("Importing skimage.color rgb2gray failed")

# imports rgba2rgb
try:
from skimage.color import rgba2rgb
except:
print("Error importing rgba2rgb from skimage.color, please install skimage package (scikit-image) first...")
sys.tracebacklimit=0
raise Exception("Importing skimage.color rgba2rgb failed")
if new_version == 2:
# since versions >= 0.13.x
try:
from skimage.color import rgba2rgb
except:
print("Error importing rgba2rgb from skimage.color, please install skimage package (scikit-image) first...")
sys.tracebacklimit=0
raise Exception("Importing skimage.color rgba2rgb failed")

# imports imread
if new_version == 2:
Expand Down Expand Up @@ -151,15 +153,20 @@ def compare_images(imageA, imageB, title, show_plot=True):
"""
computes the mean squared error and structural similarity
"""
global new_version

# index values for mean squared error
if VERBOSE: print("comparing mean squared error...")
m = mse(imageA, imageB)

# convert the images to grayscale
if VERBOSE: print("converting to greyscale...")
imageA_grey = rgb2gray(rgba2rgb(imageA))
imageB_grey = rgb2gray(rgba2rgb(imageB))
if new_version == 2:
imageA_grey = rgb2gray(rgba2rgb(imageA))
imageB_grey = rgb2gray(rgba2rgb(imageB))
else:
imageA_grey = rgb2gray(imageA)
imageB_grey = rgb2gray(imageB)

# uses image copies to avoid runtime warning for ssim computation
img1_grey = np.copy(imageA_grey)
Expand Down

0 comments on commit 429b37b

Please sign in to comment.