Skip to content
Discussion options

You must be logged in to vote

You can use OpenCV for finding closed contours. First draw the image and then apply CV algorithms on the output. Here, you can use:

    param = {"show_hatch": 0, "hatch_pattern": 0}
    fig = plt.figure()
    ax = fig.add_axes([0, 0, 1, 1])
    ctx = RenderContext(doc)
    ctx.current_layout.set_colors(bg="#FFFFFFFF")
    out = MatplotlibBackend(ax, params=param)
    Frontend(ctx, out).draw_layout(doc.modelspace())

    canvas = FigureCanvas(fig)
    canvas.draw()
    graph_image = np.array(fig.canvas.get_renderer()._renderer)
    # convert to gray
    imgGray = cv2.cvtColor(graph_image, cv2.COLOR_BGR2GRAY)
    # binary threshold
    img = cv2.threshold(imgGray, 127, 255, cv2.THRESH_BINAR…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jkraehling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants