Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert simple image to .pes file #170

Open
christofidi opened this issue Mar 15, 2024 · 1 comment
Open

Cannot convert simple image to .pes file #170

christofidi opened this issue Mar 15, 2024 · 1 comment

Comments

@christofidi
Copy link

christofidi commented Mar 15, 2024

Hello,

Thank you very much for open-sourcing this amazing library! I am trying to convert the outline of a simple image to a .pes file. For example, if I take a simple image of a dog, I am trying to detect the edges first and then convert the filtered image to a .pes file. If the problem is that I am trying to stitch only the edges, then I could use a fill-in stitch as well. This is the code that I am using, but the image appears with too many stitches all over the place (that do resemble the initial image in some sense):

def convert_image_to_pes(image_array, pes_file):
# Create a new pattern
pattern = pyembroidery.EmbPattern()

# Iterate over the image array and add stitches
height, width = image_array.shape
for y in range(height):
    for x in range(width):
        if image_array[y, x] != 0:
            # Add a stitch at the current position with default color (black)
            pattern.add_stitch_absolute(pyembroidery.STITCH, x, y)

# Save the pattern to a PES file
pattern.write(pes_file)
print("Conversion successful!")

convert_image_to_pes(edges3, 'output.pes')

Do you maybe have any recommendations?

Cheers,

Georgia :)

@tatarize
Copy link
Contributor

Filling in an area should likely be done with a much more advanced algorithm. For example, Eulerian Fill, which is a lot easier than something like Tatsumi.

While built into vpype (which is also fine to use) see this implementation:
https://github.com/EmbroidePy/vpype-embroidery

See it with a combine image parser via this other utility:
https://github.com/tatarize/vpype-vectrace

107616955-da69ca80-6c03-11eb-81bb-4150f2f4fb5d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants