CreativeInquiry / PEmbroider

Embroidery Library for Processing
Other
458 stars 26 forks source link

tweaking image conversion to use other more robust methods #11

Closed danzeeeman closed 4 years ago

danzeeeman commented 4 years ago

I was playing around with the library and saw an issue with Image Conversion.

File Screen Shot 2020-06-09 at 8 47 16 AM

Output Screen Shot 2020-06-09 at 8 47 18 AM

I made some to make the internal of image use _stroke and hatchRaster rather than hard-coded to hatchParallel. Now the image conversion takes into account hatch modes and correctly hatches the images.

output after the corrections
Screen Shot 2020-06-09 at 10 41 27 AM

Screen Shot 2020-06-09 at 10 41 57 AM

Screen Shot 2020-06-09 at 10 49 29 AM

Screen Shot 2020-06-09 at 10 48 13 AM

golanlevin commented 4 years ago

Thanks @danzeeeman , I didn't know you were in here! I think the image conversion is still in a rough state (Lingdong told me to use inverted images, for example). @LingDong- , could you kindly comment on Dan's PR?

LingDong- commented 4 years ago

@golanlevin Yes I think @danzeeeman is right. I wrote image() way before developing all the raster techniques, so that function is still using old vector hatching and doesn't respond to hatchMode().

The reason the holes are gone in the first image is that hatchParallel() does not deal with holes, another vector algo called hatchParallelComplex() does (which is still written way after image()). But to use that we need to expose the API to identify holes in the findContours() algorithm. So I think switching to raster backend is the best move (all the other operations now defaults to raster)

@danzeeeman glad you figured out my code! If I were to update it I would have done the same way :)

Let's merge it!

P.S. @golanlevin, the inverted images and the rough state are more related to HatchSpine. I think image() was working pretty ok for images without holes, and now with Dan's PR it should be even more robust

@danzeeeman I'll probably add another if statement to have it respond to FORCE_VECTOR and FORCE_RASTER

EDIT: Sorry just saw your newer commit and saw you switched to my hatchRaster() which handles all that. Great

danzeeeman commented 4 years ago

cool I'll merge it