Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

cannot vectorize image with gradient background #28

Closed
jnweiger opened this issue Sep 4, 2018 · 9 comments
Closed

cannot vectorize image with gradient background #28

jnweiger opened this issue Sep 4, 2018 · 9 comments
Assignees

Comments

@jnweiger
Copy link
Member

jnweiger commented Sep 4, 2018

This leaf gives me a headache. All I can do currently is this:
grafik
Original image from #15 by @trader4300:

leaf-issue15

@jnweiger jnweiger self-assigned this Sep 4, 2018
@Moini
Copy link
Contributor

Moini commented Sep 4, 2018

It works with the rectangle option. Maybe it has to do with the background and the stroke color being uneven?
bildschirmfoto_2018-09-04_14-49-29

@jnweiger
Copy link
Member Author

jnweiger commented Sep 4, 2018

That is so cool! I added the cliprect for something completely different. And you solve a new problem with that. Love it! That is the workaround for that issue. :-)

It is definitly being fooled by the coloring of the background.

@Moini
Copy link
Contributor

Moini commented Sep 4, 2018

I don't know about the type of preprocessing you're doing - would being able to define a threshold for black/white help with this? Or maybe it could determine that from the image itself? The cream and white are quite different from the grey/black.... Just thinking out loud - I don't know at all how to do this, or if it would help.

@Moini
Copy link
Contributor

Moini commented Sep 4, 2018

(and yes, it is cool :))

@jnweiger
Copy link
Member Author

jnweiger commented Sep 4, 2018

Try this: python-2.7 with Pillow-5.1.0 or python-3.6 with Pillow-5.2.0

from PIL import Image, ImageOps
im = Image.open('leaf-issue15.jpg')
im = im.convert(mode='L', dither=None)
ImageOps.autocontrast(im, cutoff=2).show()

grafik

Wow, that looks like Pillow is misbehaving! No wonder poor autotrace has trouble thereafter!

@jnweiger
Copy link
Member Author

jnweiger commented Sep 4, 2018

@Moini
Copy link
Contributor

Moini commented Sep 5, 2018

Urghs! So the cutoff is actually the culprit... :/ How weird. Do you mean to add the functionality back in when the linked issue is solved (or check for version numbers?)

@jnweiger
Copy link
Member Author

jnweiger commented Sep 5, 2018

hmm, probably not worth it. cutoff=2 was more a safety idea than a necessity.

@Moini
Copy link
Contributor

Moini commented Sep 5, 2018

Okay, thanks!

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants