Looking for a filter

I have been started 5 days ago to Python and OpenCV. Im trying to build a drawing bot with multiple colors. But fills every single pixel slowly. I need to transform every line’s witdh to max 2 pixels or something like that. So it will not fill big area(draw only outlines). Is any OpenCV filter can do that?

Not clear what do you want to achieve. Some image might help
Maybe you are looking for dilate morphological filter?

image_2021-10-13_090927
Filter should draw only outlines on at same color area

Use the Sobel filter:

sobel_v = cv2.Sobel(im,cv2.CV_32F,0,1,ksize=3)
sobel_h = cv2.Sobel(im,cv2.CV_32F,1,0,ksize=3)
sobel_mask = ((abs(sobel_v)+abs(sobel_h))>50).astype(numpy.uint8)
result = im*sobel_mask

Heart

1 Like

Thank you so much <3

By the way should i use erosion to made lines bigger or what?
I tried but got full black result

Sorry, I made a small error recopying the final code. The third line should be (add the “abs”):

sobel_mask = ((abs(sobel_v)+abs(sobel_h))>50).astype(numpy.uint8)

(corrected in previous post)

To make the lines thicker, increase the ksize parameter of the Sobel filter.

1 Like