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) if __name__ == '__main__': args = scripts.get_args() logger = scripts.get_logger(quite=args.quite, debug=args.debug) x_okay, y_okay = [], [] x_blur, y_blur = [], [] for path in args.image_paths: for img_path in scripts.find_images(path): logger.debug('evaluating {0}'.format(img_path)) img = cv2.imread(img_path) if isinstance(img, numpy.ndarray): if args.testing: 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)
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) if __name__ == '__main__': args = scripts.get_args() logger = scripts.get_logger(quite=args.quite, debug=args.debug) x_okay, y_okay = [], [] x_blur, y_blur = [], [] for path in args.image_paths: for img_path in scripts.find_images(path): logger.debug('evaluating {0}'.format(img_path)) img = cv2.imread(img_path) if isinstance(img, numpy.ndarray): if args.testing: 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: 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) if __name__ == '__main__': args = scripts.get_args() logger = scripts.get_logger(quite=args.quite, debug=args.debug) args.image_paths = scripts.find_images(args.image_paths[0]) for image_path in args.image_paths: img_col = cv2.imread(image_path, 1) img_msk = process(img_col, args=args) if not args.display: scripts.display('img_col', img_col) scripts.display('img_msk', img_msk) scripts.display('img_skn', cv2.bitwise_and(img_col, img_col, mask=img_msk)) cv2.waitKey(1)