From 5d1d9516b57b1919873d35db0037a4372e333d1a Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Tue, 10 Jan 2023 09:39:10 +0100 Subject: [PATCH] Add fixmes and format docstring --- cv_analysis/figure_detection/figures.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cv_analysis/figure_detection/figures.py b/cv_analysis/figure_detection/figures.py index b4897a7..b5468dd 100644 --- a/cv_analysis/figure_detection/figures.py +++ b/cv_analysis/figure_detection/figures.py @@ -5,22 +5,28 @@ from cv_analysis.utils.common import find_contours def detect_large_coherent_structures(image: np.array): - """Detects large coherent structures on an image. + """Detects large coherent structures in an image. Expects an image with binary color space (e.g. threshold applied). + Args: + image (np.array): Image to look for large coherent structures in. + Returns: - contours + list: List of contours. References: https://stackoverflow.com/questions/60259169/how-to-group-nearby-contours-in-opencv-python-zebra-crossing-detection """ assert len(image.shape) == 2 + # FIXME: Parameterize via factory dilate_kernel = cv2.getStructuringElement(cv2.MORPH_OPEN, (5, 5)) + # FIXME: Parameterize via factory dilate = cv2.dilate(image, dilate_kernel, iterations=4) - + # FIXME: Parameterize via factory close_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (20, 20)) - close = cv2.morphologyEx(dilate, cv2.MORPH_CLOSE, close_kernel, iterations=1) + # FIXME: Parameterize via factory + close = cv2.morphologyEx(dilate, cv2.MORPH_CLOSE, close_kernel, iterations=1) # TODO: Tweak iterations contours, _ = find_contours(close)