def main(image_path: str, resolution: float, row_sep: float):
    print(f'''Starting analysis.
''')
    print(f'Loading image {image_path}')
    image = cv.imread(image_path)
    if (image is None):
        raise ValueError(f'Unable to load image {image_path}')
    (h, w) = image.shape[:2]
    image_draw = image.copy()
    print(f'Image loaded. Size is {w}x{h} pixels.')
    print('Segmenting vegetation')
    veg_mask = veget.segment_vegetation(image)
    print('Detecting crop area')
    roi_poly = veget.detect_roi(veg_mask, row_sep=row_sep, resolution=resolution)
    cv.drawContours(image=image_draw, contours=[roi_poly], contourIdx=(- 1), color=(0, 0, 255), thickness=8, lineType=cv.LINE_AA)
    roi_mask = utils.poly_mask(roi_poly, veg_mask.shape[:2])
    veg_mask[(roi_mask == 0)] = 0
    print('Computing vegetation density map')
    density_map = veget.mask_density(veg_mask, roi_mask, resolution=resolution, cell_size=(8, 8))
    d_min = density_map.min()
    d_max = density_map.max()
    print(f'Vegetation density is range [{d_min:.3f}, {d_max:.3f}]')
    image_map = utils.array_image(density_map, colormap=cv.COLORMAP_JET)
    full_imshow('Crop field image', image_draw)
    full_imshow('Vegetation mask', veg_mask)
    full_imshow('Vegetation density map', image_map)
    print(f'''Analysis finished. Press any key to quit.
''')
    cv.waitKey(0)
    cv.destroyAllWindows()
def main(image_path: str, resolution: float, row_sep: float):
    print(f'Starting analysis.
')
    print(f'Loading image {image_path}')
    image = cv.imread(image_path)
    if (image is None):
        raise ValueError(f'Unable to load image {image_path}')
    (h, w) = image.shape[:2]
    image_draw = image.copy()
    print(f'Image loaded. Size is {w}x{h} pixels.')
    print('Segmenting vegetation')
    veg_mask = veget.segment_vegetation(image)
    print('Detecting crop area')
    roi_poly = veget.detect_roi(veg_mask, row_sep=row_sep, resolution=resolution)
    cv.drawContours(image=image_draw, contours=[roi_poly], contourIdx=(- 1), color=(0, 0, 255), thickness=8, lineType=cv.LINE_AA)
    roi_mask = utils.poly_mask(roi_poly, veg_mask.shape[:2])
    veg_mask[(roi_mask == 0)] = 0
    print('Computing vegetation density map')
    density_map = veget.mask_density(veg_mask, roi_mask, resolution=resolution, cell_size=(8, 8))
    d_min = density_map.min()
    d_max = density_map.max()
    print(f'Vegetation density is range [{d_min:.3f}, {d_max:.3f}]')
    image_map = utils.array_image(density_map, colormap=cv.COLORMAP_JET)
    full_imshow('Crop field image', image_draw)
    full_imshow('Vegetation mask', veg_mask)
    full_imshow('Vegetation density map', image_map)
    print(f'Analysis finished. Press any key to quit.
')
    cv.waitKey(0)
    cv.destroyAllWindows()