Skip to content

Commit

Permalink
feat(#38): set ssim + psnr as default
Browse files Browse the repository at this point in the history
mse is still not enough
  • Loading branch information
williamfzc committed Aug 25, 2019
1 parent 113b3cd commit b51dc00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions stagesepx/cutter/cut_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,18 @@ def get_length(self):

def is_stable(self,
threshold: float = None,
mse_threshold: float = None,
psnr_threshold: float = None,
**_) -> bool:
# IMPORTANT function!
# it decided whether a range is stable => everything is based on it!
if not threshold:
threshold = 0.95
if not mse_threshold:
mse_threshold = 0.7

# ssim
res = np.mean(self.ssim) > threshold
# mse
res = res and np.mean(self.mse) < mse_threshold

# default: disable if no threshold
# usually, ssim + mse is enough
if psnr_threshold:
res = res and np.mean(self.psnr) < psnr_threshold
# psnr (double check if stable)
if res and psnr_threshold:
res = np.mean(self.psnr) > psnr_threshold

return res

Expand Down
2 changes: 1 addition & 1 deletion stagesepx/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def calc_mse(pic1: np.ndarray, pic2: np.ndarray) -> float:

def calc_psnr(pic1: np.ndarray, pic2: np.ndarray) -> float:
# PSNR: https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
return compare_psnr(pic1, pic2)
return compare_psnr(pic1, pic2) / 100


def compress_frame(old: np.ndarray,
Expand Down

0 comments on commit b51dc00

Please sign in to comment.