Exemple #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)
Exemple #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)
Exemple #3
0
def process(image, save=False, display=False, args=None, segment=False):
    assert isinstance(image, numpy.ndarray)
    if not args:
        args = scripts.gen_args()
    else:
        assert isinstance(args, argparse.Namespace), "args must be an argparse.Namespace"
    args.save = save
    args.display = display
    detector = SkinDetector(args)
    if segment:
        slic = SpeedySuperPixels.SuperContour()
        skin = numpy.zeros(image.shape, dtype=image.dtype)
        for roi, contour in slic.process(image):
            pxl = cv2.bitwise_and(image, image, mask=contour)
            msk = detector.process(pxl)
            ret = msk.sum() / contour.sum()
            if ret > 0.8:
                skin = numpy.min(255, cv2.add(skin, contour))
        return skin
    else:
        return detector.process(image)
Exemple #4
0
def process(image, save=False, display=False, args=None, segment=False):
    assert isinstance(image, numpy.ndarray)
    if not args:
        args = scripts.gen_args()
    else:
        assert isinstance(args, argparse.Namespace), 'args must be an argparse.Namespace'
    args.save = save
    args.display = display
    detector = SkinDetector(args)
    if segment:
        slic = SpeedySuperPixels.SuperContour()
        skin = numpy.zeros(image.shape, dtype=image.dtype)
        for roi, contour in slic.process(image):
            pxl = cv2.bitwise_and(image, image, mask=contour)
            msk = detector.process(pxl)
            ret = msk.sum()/contour.sum()
            if ret > 0.8:
                skin = numpy.min(255, cv2.add(skin, contour))
        return skin
    else:
        return detector.process(image)