Beispiel #1
0
def blur_detector(img_col, thresh=10, mask=False):
    assert isinstance(img_col, numpy.ndarray), 'img_col must be a numpy array'
    assert img_col.ndim == 3, 'img_col must be a color image ({0} dimensions currently)'.format(img_col.ndim)
    args = scripts.gen_args()
    args.thresh = thresh
    if mask:
        return FocusMask.blur_mask(img)
    else:
        return evaluate(img_col=img_col, args=args)
Beispiel #2
0
def blur_detector(img_col, thresh=10, mask=False):
    assert isinstance(img_col, numpy.ndarray), 'img_col must be a numpy array'
    assert img_col.ndim == 3, 'img_col must be a color image ({0} dimensions currently)'.format(img_col.ndim)
    args = scripts.gen_args()
    args.thresh = thresh
    if mask:
        return FocusMask.blur_mask(img)
    else:
        return evaluate(img_col=img_col, args=args)
Beispiel #3
0
                 scripts.display('dialog (blurry: Y?)', img)
                 blurry = False
                 if cv2.waitKey(0) in map(lambda i: ord(i), ['Y', 'y']):
                     blurry = True
                 x_axis = [1, 3, 5, 7, 9]
                 for x in x_axis:
                     img_mod = cv2.GaussianBlur(img, (x, x), 0)
                     y = evaluate(img_mod, args=args)[0]
                     if blurry:
                         x_blur.append(x)
                         y_blur.append(y)
                     else:
                         x_okay.append(x)
                         y_okay.append(y)
             elif args.mask:
                 msk, res, blurry = FocusMask.blur_mask(img)
                 img_msk = cv2.bitwise_and(img, img, mask=msk)
                 if args.display:
                     scripts.display('res', img_msk)
                     scripts.display('msk', msk)
                     scripts.display('img', img)
                     cv2.waitKey(0)
             else:
                 img_fft, result, val = evaluate(img, args=args)
                 logger.info('fft average of {0}'.format(result))
                 if args.display:
                     scripts.display('input', img)
                     scripts.display('img_fft', img_fft)
                     cv2.waitKey(0)
 if args.display and args.testing:
     import matplotlib.pyplot as plt
Beispiel #4
0
                 scripts.display('dialog (blurry: Y?)', img)
                 blurry = False
                 if cv2.waitKey(0) in map(lambda i: ord(i), ['Y', 'y']):
                     blurry = True
                 x_axis = [1, 3, 5, 7, 9]
                 for x in x_axis:
                     img_mod = cv2.GaussianBlur(img, (x, x), 0)
                     y = evaluate(img_mod, args=args)[0]
                     if blurry:
                         x_blur.append(x)
                         y_blur.append(y)
                     else:
                         x_okay.append(x)
                         y_okay.append(y)
             elif args.mask:
                 msk, res, blurry = FocusMask.blur_mask(img)
                 img_msk = cv2.bitwise_and(img, img, mask=msk)
                 if args.display:
                     scripts.display('res', img_msk)
                     scripts.display('msk', msk)
                     scripts.display('img', img)
                     cv2.waitKey(0)
             else:
                 img_fft, result, val = evaluate(img, args=args)
                 logger.info('fft average of {0}'.format(result))
                 if args.display:
                     scripts.display('input', img)
                     scripts.display('img_fft', img_fft)
                     cv2.waitKey(0)
 if args.display and args.testing:
     import matplotlib.pyplot as plt