implemented Frequency Domain Image Blur Measure (review required)
This commit is contained in:
parent
9c3b03c845
commit
50d022380b
16
imgrate.py
16
imgrate.py
@ -1,11 +1,20 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import cv2
|
import cv2
|
||||||
|
import numpy as np
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
|
||||||
def laplacian_variance(image):
|
def laplacian_variance(image):
|
||||||
grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
return cv2.Laplacian(image, cv2.CV_64F).var()
|
||||||
return cv2.Laplacian(grayscale, 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__':
|
if __name__ == '__main__':
|
||||||
@ -14,5 +23,6 @@ if __name__ == '__main__':
|
|||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
image = cv2.imread(args.images[0])
|
image = cv2.imread(args.images[0])
|
||||||
|
grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||||
|
|
||||||
print(laplacian_variance(image))
|
print(fdibm(grayscale))
|
Loading…
Reference in New Issue
Block a user