GSoC19 : Vectorization of bitmaps

I will be updating about the progress of the project here :slight_smile:

2 Likes

Weekly progress(18-25 May):

  1. :heavy_check_mark: class RawBorderPoint
    main variable being TPoint m_position; We have synfig pointint that can replace Tpoint

  2. :heavy_check_mark: class RawBorder final : public std::vector
    main variable being TpointD We have synfig point that can replace TpointD

  3. :heavy_check_mark: class PixelEvaluator //this is a template class
    main variable being TRasterPT

  4. :heavy_check_mark: class Signaturemap
    main data being the functions

  • Signaturemap(const TRasterP &ras, int threshold) and
  • template <typename T> void readRasterData(const TRasterPT<T> &ras, int threshold);

Along with some other functions that directly or indirectly use data objects of mentioned classes
So in the next week, I will be focusing on creating Synfig equivalent of polygonizer
I appreciate any suggestions or improvements from anyone :slight_smile:

EDIT: I will be adding (:heavy_check_mark: ) to the one I have implemented.

3 Likes

Awesome! Keep up the good work! :slight_smile:

1 Like

I have this program maybe serves them of reference. It can work with flat colours.

https://git.tuxfamily.org/4232/quinema.git/tree/quinema-escalar


https://4232.cf/es/?s=quinema-escalar

@bazza thank you :slight_smile:
but this uses potrace however I am not using potrace(although It was an option) you can see the discussion on that here

1 Like

@KonstantinDmitriev I have implemented 2 classes(see edited comment).
Please have a look at https://github.com/synfig/synfig/issues/735#issuecomment-496266744
Thanks!

1 Like

Currently I’m stuck on the PixelEvaluator class. It uses pixel information and then decides whether it is can be categorized as a black pixel or a white one.

The problem is Synfig uses RGBA color scheme and Toonz uses RGBM color scheme so I’m not sure if can simply replace the A with M into the same formula.
I found that GIMP uses 5 different method for the same (in desaturate).
Out of them luminance is most accurate according to documentation. So I’m thinking of using it.

1 Like

Weekly progress(26 -1 June):

Thanks

3 Likes

Weekly Progress(2 - 8 June):

I appreciate any feedback! [^_^]
Thanks,
Ankit Dwivedi

2 Likes

Weekly Progress(9 - 15 June):

  • Rectified the errors present in centerlinepolygonizer
  • I was able to pass the output of centerlinepolygonizer to Toonz and got the output(which was rotated 90-degrees anticlockwise)
  • Fixed the rotated input error mentioned in the above point
  • Started the work on centerlineskeletonizer which is almost complete(at least the code is compiling successfully :p)
  • Will try to check the output of centerlineskeletonizer by passing it results to Toonz.
  • In the next week I look forward to making the centerlineskeletonizer working

That’s all for this week [^_^]
Would appreciate Suggestions and feedbacks

2 Likes

A comparison between the output of Skeletonizer from Toonz and Synfig can be seen here however the results are not exactly the same but of the same nature.

  • I need to cross check if I have made any silly error and cross verify them again(for this time I need to pass the output of synfig skeletonizer to toonz to see if the result is varied which I am still figuring out a way on how to do that).

  • Have started working on the next step which is creating the complete skeleton using joints and sequence from separate straight skeletons.

Thanks!
feedback and suggestions are always welcome

2 Likes

Weekly Progress(16 - 22 June):

  • This week I was able to complete the Skeletonizer that output a straight skeleton.
  • And then I started working on organizegraphs() which joins the straight skeletons into sequences and joints. And I was able to achieve the same
  • @KonstantinDmitriev helped me understand the concept of frame in calculating thickness ratio and that m_thicknessRatio = 1.0 in our case. (see discussion here)
  • The next step is storing the corresponding color for a sequence in the skeleton for which I the plan is to extract the original RGBA color from the bitmap layer and then apply the color as a “Stroke” ( as they say in Toonz) but we do not have strokes so Outline layer will be used.

The progress of this project can now be seen here
For people who want to get a quick insight into the centerline vectorization algorithm can see this comment.

Any suggestions or feedback are welcome :slight_smile:
Thank’s

3 Likes

Weekly Progress(23 - 29 June):

This was a slow week for me was stuck at understanding Toonz Color and PixelCM32. Finally got what we needed -> see the discussion here

That was all for this week, we had our 1st evaluation this week me and @AnishG both passed and are looking forward to achieving something fruitful for Synfig this summer :blush:
Thanks :slight_smile:

Any feedback is much appreciated.
Ankit Dwivedi

3 Likes

After @KonstantinDmitriev comment -> https://github.com/synfig/synfig/issues/849#issuecomment-507127492

It is clear that Step 5 which involves taking samples from image is only done with toonzRaster and not the normal Raster image type, which means we do not need this function(maybe in future if we want to preserve the sequence color then we can do this for raster images too).

Also in step 6: Toonz create TStrokes which are similar to outline layer in synfig and in step 7 it again does the following

Under step 7 apply stroke it again Check 
if(cm && ..) 
{
} 
else 
{ 
//Here it choose the closest to black palette color and apply them to all the strokes 
}

So we can skip step 7 too and simply apply black color to outline layers while creating?

2 Likes

Yes, this is ok to do that. Let’s leave coloring strokes as a bonus-task. Can you please fill an issue here so we will not forget abou it? :slight_smile:

2 Likes

Weekly Progress(29 June - 6 July):

In the next week, I am looking forward to completing the conversion including step 6, which is the most crucial phase because that will decide the final output outline layers. So I am hoping to achieve a working centerline converter without stroke colors.
That’s it for this weeks. Thanks [^_^]
Any suggestions are always welcome.

Ankit Dwivedi

3 Likes

Weekly Progress(7 July - 13 July):

  • I was able to complete centerlinetostrokes.cpp
  • In this week I tried converting from Toonz Strokes (which is based on bezier) to Synfig Outline (which uses hermite ) and was able to figure out the way to do that.
  • Created the function BezierToOutline
  • I started with step 8 tried my first attempt on displaying the output of Vectorization which was not successful (^_^)"

In the next week, I look forward to displaying the outline layers so I can know the outcome of Vectorization.
That’s all for this week. Suggestions are always appreciated.
Thanks
Ankit Dwivedi

3 Likes

Weekly Progress(14 - 20 July):

  • I was able to create outline layer this week after multiple attempts thanks to @KonstantinDmitriev
  • I fixed affine transformation
  • I was able to test if the control points being generated by synfig and toonz and found some issue which was later fixed. Now both generate almost the same control points
  • I attempted to create a group layer to encapsulate the outlines
  • I also noticed the outlines are too large to fit. The vertex points for bline are in thousands :confused:

That is all for this week. In the next week, I look forward to fitting the outlines and encapsulating them to a group.
Thank you. Suggestions are always welcome
Ankit Dwivedi

4 Likes

Weekly progress(21 - 27 July):

  • I was able to convert the test image got an output which was finally fitting into the drawing area.
  • I fixed the pixel size to the unit conversion problem
  • Found some problem with tangent creation and fixed that
  • This week the focus was wrapping vectorization into action and I already have started working on it. Apart from group creation code in perform() and deletion code in undo() everything looks good.

That was all for this week. In the next week, I look forward to make the Synfig action vectorization working. And fix some problems related to outline creation after vectorization if I complete the action.
Feedback is always appreciated.
Ankit Dwivedi

4 Likes

Weekly progress(28 July - 3 August):
This week I made significant improvement but encounterd a major issue

In the upcoming week, I will be working to find the error which is causing the unexpected result and also fixing outline issues.
Thank you!
Any feedback and suggestions are always appreciated

4 Likes