implemented Frequency Domain Image Blur Measure (review required)

This commit is contained in:
Kjistóf 2018-01-01 21:49:00 +01:00
parent 9c3b03c845
commit 50d022380b

View File

@ -1,11 +1,20 @@
#!/usr/bin/env python3
import cv2
import numpy as np
from argparse import ArgumentParser
def laplacian_variance(image):
grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
return cv2.Laplacian(grayscale, cv2.CV_64F).var()
return cv2.Laplacian(image, cv2.CV_64F).var()
def fdibm(image):
F = np.fft.fft2(image)
Fcentered = np.fft.fftshift(F)
Fabs = np.abs(Fcentered)
Fmax = Fabs.max()
Th = np.count_nonzero(Fabs > Fmax/1000)
return Th / (F.shape[0] * F.shape[1])
if __name__ == '__main__':
@ -14,5 +23,6 @@ if __name__ == '__main__':
args = ap.parse_args()
image = cv2.imread(args.images[0])
grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
print(laplacian_variance(image))
print(fdibm(grayscale))