comparison #3
@ -1,6 +1,6 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from skimage.metrics import structural_similarity
|
||||
|
||||
def histogram_comparison(data_a: np.ndarray, data_b: np.ndarray) -> dict:
|
||||
hsv_a = cv2.cvtColor(data_a, cv2.COLOR_BGR2HSV)
|
||||
@ -23,3 +23,7 @@ def histogram_comparison(data_a: np.ndarray, data_b: np.ndarray) -> dict:
|
||||
'intersection': cv2.compareHist(hist_a, hist_b, 2),
|
||||
'bhattacharyya-distance': cv2.compareHist(hist_a, hist_b, 3),
|
||||
}
|
||||
|
||||
|
||||
def structural_similarity_index(data_a: np.ndarray, data_b: np.ndarray) -> float:
|
||||
return structural_similarity(cv2.cvtColor(data_a, cv2.COLOR_BGR2GRAY), cv2.cvtColor(data_b, cv2.COLOR_BGR2GRAY))
|
||||
|
3
main.py
3
main.py
@ -3,7 +3,7 @@ import cv2
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from comparisons import histogram_comparison
|
||||
from comparisons import histogram_comparison, structural_similarity_index
|
||||
|
||||
# Allows imports from the style transfer submodule
|
||||
sys.path.append('DCT-Net')
|
||||
@ -44,6 +44,7 @@ def compare_with_anime_characters(data: np.ndarray) -> int:
|
||||
data_rescaled = cv2.resize(data, example_face.shape[:2])
|
||||
plot_two_images(example_face, data_rescaled)
|
||||
print(histogram_comparison(data_rescaled, example_face))
|
||||
print(f'structural-similarity: {structural_similarity_index(data_rescaled, example_face)}')
|
||||
|
||||
|
||||
def transfer_to_anime(img: np.ndarray):
|
||||
|
@ -8,3 +8,4 @@ lxml==4.9.2
|
||||
opencv-python==4.7.0.68
|
||||
torch==1.13.1
|
||||
matplotlib==3.6.3
|
||||
scikit-image==0.19.3
|
Loading…
Reference in New Issue
Block a user