# Revision history [back]

### How to fill closed contours of edged text in Python

Hi everyone!

I'm working on a project to convert handwritings into a plot from which I'll try to convert it into gcode. Here with Open CV I'm trying to find the best way to convert handwritings to Clear Plot.

Image original: I try to work in poor condition, hence the rotten quality of the paper:

After applying Candy edge i got this:

import cv2

import numpy as np

...

...

contours, hier = cv2.findContours(edgedImage.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

stencil = np.zeros(img.shape).astype(img.dtype)

color = [255, 255, 255]

# Fill out ALL Contours

for cnt in contours:

  cv2.fillPoly(stencil, cnt, color)


result = cv2.bitwise_and(img, stencil)

cv2.imwrite("result.jpg", result)

# Fill out ALL Contours

cv2.fillPoly(stencil, contours, color)

result = cv2.bitwise_and(img, stencil)

how am I supposed to get all the handwriting back, even the unclosed outlines?

 2 None supra56 943 ●9 ●6

### How to fill closed contours of edged text in Python

Hi everyone!

I'm working on a project to convert handwritings into a plot from which I'll try to convert it into gcode. Here with Open CV I'm trying to find the best way to convert handwritings to Clear Plot.

Image original: I try to work in poor condition, hence the rotten quality of the paper:

After applying Candy edge i got this:

> import cv2 cv2

> import numpy as np ... ... np

> ...

> ...

> contours, hier = cv2.findContours(edgedImage.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) cv2.CHAIN_APPROX_SIMPLE)

> stencil = np.zeros(img.shape).astype(img.dtype) np.zeros(img.shape).astype(img.dtype)

> color = [255, 255, 255] 255]

> \# Fill out ALL Contours

> for cnt in contours:

>       cv2.fillPoly(stencil, cnt, color)

> result = cv2.bitwise_and(img, stencil)

> cv2.imwrite("result.jpg", result)


# Fill out ALL Contours

for cnt in contours:

Contours:

 cv2.fillPoly(stencil, cnt, contours, color)

result = cv2.bitwise_and(img, stencil)


result = cv2.bitwise_and(img, stencil)

cv2.imwrite("result.jpg", result)

# Fill out ALL Contours

cv2.fillPoly(stencil, contours, color)

result = cv2.bitwise_and(img, stencil)

how am I supposed to get all the handwriting back, even the unclosed outlines?

### How to fill closed contours of edged text in Python

Hi everyone!

I'm working on a project to convert handwritings into a plot from which I'll try to convert it into gcode. Here with Open CV I'm trying to find the best way to convert handwritings to Clear Plot.

Image original: I try to work in poor condition, hence the rotten quality of the paper:

After applying Candy edge i got this:

>  import cv2

>  import numpy as np

> ...

> ...

> contours, hier = cv2.findContours(edgedImage.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

> stencil = np.zeros(img.shape).astype(img.dtype)

> color = [255, 255, 255]

> \# # Fill out ALL Contours

> for cnt in contours:

>       cv2.fillPoly(stencil, cnt, color)

> result = cv2.bitwise_and(img, stencil)

> cv2.imwrite("result.jpg", result)


# Fill out ALL Contours:

cv2.fillPoly(stencil, contours, color)

result = cv2.bitwise_and(img, stencil)


how am I supposed to get all the handwriting back, even the unclosed outlines?

### How to fill closed contours of edged text in Python

Hi everyone!

I'm working on a project to convert handwritings into a plot from which I'll try to convert it into gcode. Here with Open CV I'm trying to find the best way to convert handwritings to Clear Plot.

Image original: I try to work in poor condition, hence the rotten quality of the paper:

After applying Candy edge i got this:

 import cv2

import numpy as np

>  ...

>  ...

>  contours, hier = cv2.findContours(edgedImage.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

>  stencil = np.zeros(img.shape).astype(img.dtype)

>  color = [255, 255, 255]

>  # Fill out ALL Contours

>  for cnt in contours:

>        cv2.fillPoly(stencil, cnt, color)

>  result = cv2.bitwise_and(img, stencil)

>  cv2.imwrite("result.jpg", result)


# Fill out ALL Contours:

cv2.fillPoly(stencil, contours, color)

result = cv2.bitwise_and(img, stencil)


how am I supposed to get all the handwriting back, even the unclosed outlines?

### How to fill closed contours of edged text in Python

Hi everyone!

I'm working on a project to convert handwritings into a plot from which I'll try to convert it into gcode. Here with Open CV I'm trying to find the best way to convert handwritings to Clear Plot.

Image original: I try to work in poor condition, hence the rotten quality of the paper:

After applying Candy edge i got this:

 import cv2

import numpy as np

...

...

contours, hier = cv2.findContours(edgedImage.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

stencil = np.zeros(img.shape).astype(img.dtype)

color = [255, 255, 255]

# Fill out ALL Contours

for cnt in contours:

cv2.fillPoly(stencil, cnt, color)

result = cv2.bitwise_and(img, stencil)

cv2.imwrite("result.jpg", result)


# Fill out ALL Contours:

cv2.fillPoly(stencil, contours, color)

result = cv2.bitwise_and(img, stencil)


how am I supposed to get all the handwriting back, even the unclosed outlines?

 6 retagged sturkmen 6772 ●3 ●48 ●79 https://github.com/stu...

### How to fill closed contours of edged text in Python

Hi everyone!

I'm working on a project to convert handwritings into a plot from which I'll try to convert it into gcode. Here with Open CV I'm trying to find the best way to convert handwritings to Clear Plot.

Image original: I try to work in poor condition, hence the rotten quality of the paper:

After applying Candy edge i got this:

 import cv2

import numpy as np

...

...

contours, hier = cv2.findContours(edgedImage.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

stencil = np.zeros(img.shape).astype(img.dtype)

color = [255, 255, 255]

# Fill out ALL Contours

for cnt in contours:

cv2.fillPoly(stencil, cnt, color)

result = cv2.bitwise_and(img, stencil)

cv2.imwrite("result.jpg", result)


# Fill out ALL Contours:

cv2.fillPoly(stencil, contours, color)

result = cv2.bitwise_and(img, stencil)


how am I supposed to get all the handwriting back, even the unclosed outlines?