[In Development] Vectrize Plug in

I’ve spent the last months and effort,it able to make Imagetracer work as a Krita plugin.

Note: This plugin need, addict.py (it is dictionary extend library)
Please it into to pykrita folder if Vectrize plugin to make working.

Screenshot in the pykrita folder (partial)

スクリーンショット 2024-03-24 11.09.03

However, the operating speed was too slow to handle large images.
Recommend (v0.3) : Image size for 512 * 512px ,or less than 1024*1024px

Personally, I think this kind of processing is better suited for C++ than Python.
So I hope not close feature request of Image tracing.

Update HIstory (by Latest)

Execution time by my machine , 2.8 GHz Intel Core i5 (2014)
Probably get faster result by Modern PC.


v0.48 (2024/04/02)
Update and improve GUI
Add some support tool for shape editing
Add ToolTips
Add Krita built-in icon to some button,
Thanks to plug in dev tool!

Screenshot GUI comparison v0.40 and v0.48


v0.40 (2024/03/29)
Update Manual.html (Tips to reduce for sawtooth outline from selection)
Add ignore white pixel option, Add alpha fillter
Add pre-Alpha filter for Lasso draw mode


v0.35 (2024/03/27)
Add Lasso draw mode
Fillcolor as Forground Color and Bordercolor as Background color )


v0.3 (2024/03/23)
For speed up,it improved to code.
For example Unnessary function calls reduce and
moved a heavy process out from for-in loops.
Now in 400x400 pixel, Reduced time to 5 -7 sec
in 756x756 pixel, Reduced time 16 - 20sec

Screeenshot




v0.25 (2024/03/19)
Image reading x13 speed up!!!
Removed extra processing (flatten) caused long time for read data.
Used extend() instead of append(),and create 1Dimension List at initialize avoid not use flatten of list.
Now in 400x400 pixel, Reduced time from 256sec to 19sec

Screeenshot






v0.15 (----/–/–)
very slow ,Elapse 250sec for Tracing Simple 400 x 400 pixe
Implemented the functionality I wanted,and tried to speed up as much as do my best.l

Screenshot

very slow For example
i






スクリーンショット 2024-03-16 15.38.02


4 Likes

Tips

The result nothing appear

  • UseColors is 0 or 1 almost nothing appar.
  • If UseColors value is 1 - 7, it work Grayscale mode.
  • The setting of colorquantcycles = 0,it should be 1-3 value
  • If In the Line art mode, and strokewith value were 0,increase the value.
  • It possible that the pathes has generated on the out of canvas display area. (The vector objects can selectable)

What factors relate to better for quality?

  • For small image,Error threshold for Line (ltres) value to smaller (0.05 - 1.0)
  • For small image,Error threshold Q-Spline (qtres) value to larger (1.0 - 3.0)
  • For large image(800x800px),Error threshold for Line (ltres) value to smaller (5 - 30)
  • For large image(800x800px),Error threshold Q-Spline (qtres) value to larger (5 - 80)
  • Use colors (numberofcolors) to 16 - 64
  • Use Deterministic sampling(Good color reproduction)
  • Use Path filter(Suppressing unnecessary path objects generate)
  • Path omit 0 - 3
  • Even the same settings,it may get better results in repeat several times.

What factors relate to better for speed?

  • Use Pallalel layering(bit faster than sequantial )
  • Use Deterministic sampling
  • colorquantcycles = 1
  • Not use blur
  • Path omit 0 - 8
  • Apply to Selected rectangle area
  • Image size less than 756 x 756 px
  • Use colors (numberofcolors) to 2 - 7 for monochrome/black & white image

For make good corner and curves.

  • Uncheck Right Angle Enhance (This is workaround to the case that should be an acute angle becomes a curve)
Example of un-nessesary curve(screenshot )

error
(The line indicate by orange colored line)

What is better setting for vectrize?

  • Error threshold for Line (ltres) value to smaller (0.05)
  • Error threshold Q-Spline (qtres) value to larger (1.0-3.0)
  • Uncheck Right Angle Enhance
  • Use colors (numberofcolors) to 16 - 64
  • Use Deterministic sampling
  • colorquantcycles = 1
  • Image size less than 756 x 756 px

Too small result

  • Default tracing scale is 1 ( pixel: export vector size = 1:1),Both look similar
  • So,set scale parameter to 10 if you can see the difference of vector and pixel.

Get smooth curve from pixel

  • Error threshold for Line (ltres) value to smaller (0.05)
  • Error threshold Q-Spline (qtres) value to larger (1.0)

I want get grayscale result

  • Use colors (numberofcolors) parameter to less than 8 (1-7)

I want line art only,not want fill colors

  • Check Line art
  • Set Line Width to greater than 0

It wants to trace the wand selection area, but in result, not appear straight lines and curves, it only gives a sawtooth outline.

Sawtooth outline bothered me too.

  • Apply, Select → Smooth (from menu) x 4 times to the selection area before vectrize it

How it works? (v0.35,v0.40)

Trace mode (parthal selection):

Lasso draw mode

Tips(v0.48)



SupportTools (v0.48)

What should I do if I want to paste above or below a pinpoint-selected shape?
I also add shortcut button to krita command for faster to edit vector and shaps

Screen sample (Color picker) from pixel and vector color

Copy and paste of styles

6 Likes

Looks nice.
It could be interesting to code it in C++ as a native function, execution time will be quite faster than python :slight_smile:

Grum999

3 Likes

Thank you for comment!
The original author left detailed documentation about the algorithm.
That helped me many times.
How great would it be if it worked fast. :laughing:

I’m going to planned to for the plugin,a bit adjust UI/UX for the user who create vector shape,and clean-up code.