You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm Ankit Dwivedi a CSE Student. I'm a contributor at Synfig. I was a part of NjackWOC 18 at Synfig.
I would like to work for the project https://synfig-docs-dev.readthedocs.io/en/latest/gsoc/2019/ideas.html#vectorization-of-bitmaps
As this is something I personally feel is an important feature that Synfig must-have. Even when I'm working for graphic design I encounter a situation where I have to vectorize the raster image to increase the quality and reduce the size.
On my initial research, I found that potrace can be a good option. Inkscape uses potrace to convert the raster image to vector and I have tried that feature. I would love to have any suggestions and comments from the project mentor @blackwarthog and @morevnaproject
Hope to have an exciting summer 😊
From my point of view, the vectorization algorithm of OpenToonz works better, because it identifies separate lines and outputs strokes (result = many separate Outline Layers). This is good for further editing vectorized image.
The Potrace tool outputs singles region layer (result = single Region Layer), which is not very comfortable for editing. On the other hand, I believe integration with Potrace might be easier to implement (but I might be wrong).
The Potrace tool outputs singles region layer (result = single Region Layer), which is not very comfortable for editing. On the other hand, I believe integration with Potrace might be easier to implement (but I might be wrong).
Well.. yes it seems easy to integrate potrace with synfig that's because it is documented and being used by several other projects. However, on trying myself, I found opentoonz is better and have more accuracy and options.
On finding about the algorithm they use I was unable to directly find any algorithm mentioned anywhere which they use for the raster to vector conversion. Sadly I found no developer documentation for opentoonz :( This means I need to analyze the process and identify the necessary steps which are required so I will let you know after I investigate further.
@morevnaproject Also can you please let me know how much work to be done before gsoc start? I am asking this in regards to point no 2 under the gsoc application faq.
Show evidence of past experience or achievements related to the proposal.
What is the priority of this project?
I hope I have not chosen the least priority project 😓
On finding about the algorithm they use I was unable to directly find any algorithm mentioned anywhere which they use for the raster to vector conversion. Sadly I found no developer documentation for opentoonz :( This means I need to analyze the process and identify the necessary steps which are required so I will let you know after I investigate further.
git grep "Convert to Vectors" in opentoonz sources dir gives me:
...
toonz/sources/toonz/mainwindow.cpp: createMenuLevelAction(MI_ConvertToVectors, tr("Convert to Vectors..."), "");
...
So, name of the action is MI_ConvertToVectors. So I did git grep MI_ConvertToVectors and got this:
stuff/profiles/layouts/rooms/Default/menubar_template.xml: <command>MI_ConvertToVectors</command>
stuff/profiles/layouts/rooms/StudioGhibli/menubar_template.xml: <command>MI_ConvertToVectors</command>
stuff/profiles/layouts/rooms/StudioGhibli/room4_menubar.xml: <command>MI_ConvertToVectors</command>
stuff/profiles/layouts/shortcuts/defopentoonz.ini:MI_ConvertToVectors=
stuff/profiles/layouts/shortcuts/otadobe.ini:MI_ConvertToVectors=
stuff/profiles/layouts/shortcuts/otharmony.ini:MI_ConvertToVectors=
stuff/profiles/layouts/shortcuts/otretas.ini:MI_ConvertToVectors=
toonz/sources/toonz/castselection.cpp: // enableCommand(m_browser, MI_ConvertToVectors, &CastBrowser::vectorize);
toonz/sources/toonz/castviewer.cpp: // MI_ConvertToVectors se sono stati selezionati solo livelli non vettoriali
toonz/sources/toonz/castviewer.cpp: menu->addAction(cm->getAction(MI_ConvertToVectors));
toonz/sources/toonz/mainwindow.cpp: createMenuLevelAction(MI_ConvertToVectors, tr("Convert to Vectors..."), "");
toonz/sources/toonz/menubar.cpp: addMenuItem(levelsMenu, MI_ConvertToVectors);
toonz/sources/toonz/menubar.cpp: addMenuItem(levelMenu, MI_ConvertToVectors);
toonz/sources/toonz/menubarcommandids.h:#define MI_ConvertToVectors "MI_ConvertToVectors"
toonz/sources/toonz/vectorizerpopup.cpp: MI_ConvertToVectors);
So, I believe it is good to start looking in toonz/sources/toonz/vectorizerpopup.cpp.
Also can you please let me know how much work to be done before gsoc start? I am asking this in regards to point no 2 under the gsoc application faq - "Show evidence of past experience or achievements related to the proposal."
About achievements related to proposal I would like to see the following:
One feature, which is related to adding a new item in Layer's right-click menu. I think "Edit in External Tool" Options #516 is a very good candidate for that.
If we will choose to go with OpenToonz, then I ask you to describe in your project proposal the main logic of vectorization code. This shouldn't be a detailed description - just show me an understanding where (in which files/functions) the main logic is coded. ^__^
What is the priority of this project?
I hope I have not chosen the least priority project
The priority of project doesn't plays any role when we choosing who will participate in our GSoC activities. When choosing students we are looking at:
How many code contributions student has done to Synfig.
How complex those contributions are.
How many of his/her contributions are related to his proposal (or does he/she has a previous experience with related topics).
Also other things we consider:
If contributor has experience with other projects.
EDIT : I guess it is related to multithreading, in java also there is run() and start() function I have done multithreading in java not C++ but it's quite similar I guess.
@morevnaproject As I got your mail so I verified that there is a crash in case of using the outlinevectorizer method.
To compare "opentoonz" and "opentoonz morevna" I installed both on same Windows 10.
Also, I used the same file. On converting to vector( outlinevectorizer ) using "opentoonz" it ran successfully, however, "opentoonz morevna" crashed. So I can confirm the crash is only in morevna edition and not on original opentoonz :/
I am comparing both codebase to know what is the possible reason. Is morevna edition using the tnewoutlinevectorizer.cpp ? The crash was supposed to fix by opentoonz/pull/2057
I am comparing both codebase to know what is the possible reason. Is morevna edition using the tnewoutlinevectorizer.cpp ? The crash was supposed to fix by opentoonz/pull/2057
Please consider, that OpenToonz Morevna Edition doesn't includes all features/fixes of official OpenToonz 1.3. Actually, OpenToonz Morevna Edition 1.3 has only features of official OpenToonz 1.2.1 + our additions (Assistants, Color selector, etc.). This might be the reason why this happens.
@morevnaproject the configuration input dialog for opentoonz(centerline) looks like this
Are we going to create the same options dialog or there are some changes required?
And in the centerline algorithm, the first step in processing anti-aliased images so I am starting with the pre-processing part when the layer is anti-aliased.
see toonz/sources/toonzlib/Naa2TlvConverter.cpp
Will push the changes on a new branch in my repository.
Will keep you updated on what I am working on [^_^]
It would be nice to have progressbar so user can see how the process is going. But this is not critical at the moment. I suggest to add it after you get vectorization working.
If yes then what will be the synfig equivalent of frame?
Also according to Toonz documentation
Thickness Calibration Start: and End: calibrates the vector stroke thickness defined according to the Threshold value; a low value will reduce the stroke thickness preserving its integrity. A different value inserted in the Start / End field determines an animation of the thickness along the length of the level.
Then why are they using frame to calculate the thickness ratio?
I apprciate any pointer @blackwarthog@ice0
The meaning of this formula is to take a value from [0;1] segment and find its relative position on another segment [m_cThicknessRatioFirst; m_cThicknessRatioLast].
Thickness Calibration Start: and End: calibrates the vector stroke thickness ...; ... A different value inserted in the Start / End field determines an animation of the thickness along the length of the level.
The last sentence is important. Actually I was not aware that Start / End fields has that meaning.
I have made some tests - yes, it actually allows to "animate" stroke width when vectorization is done for a sequence of images.
The last sentence is important. Actually, I was not aware that Start / End fields have that meaning.
I have made some tests - yes, it actually allows to "animate" stroke width when vectorization is done for a sequence of images.
I will keep thinking on that and will post more.
Okay @morevnaproject I will be testing the skeletonizer output today and will start working on
Next step - organizeGraphs(skeletons, globals);
The raw skeleton data obtained from StraightSkeletonizer class need to be grouped in joints and sequences before proceeding further
Now need to start thinking how to represent the output that is because the steps after organizeGraphs(skeletons, globals); involves TStroke and TVectorImageP
Okay, here is how I understood it. The frame variable in this function is a frame number from timeline. But it is represented by value from [0; 1] range, where 0 is first frame of all selected frames and 1 is last frame.
As it is inconvenient to keep track of every step and some important comments can be lost which contain steps that are currently not top priority but should be implemented later on.
Hence it is better to keep track from milestone now.
So let me brief you about the algorithm for centerlinevectorization from Toonz and where I am
step-1 If the source is a full-color non-antialiased image so this needs to be processed this is currently not implementedsee here
step 2 - centerlinepolygonizer
Extracts a polygonal, minimal yet faithful representation of image contours
Contours polygons (see here )
step 3 - centerlineskeletonizer
The process of skeletonization reduces all objects in an image to lines, without changing the essential structure of the image. (see here)
step 4 - organizeGraphs
The raw skeleton data obtained from StraightSkeletonizer class need to be grouped in joints and sequences before proceding further (In progress)
step 5
Take samples of image colors to associate each sequence to its corresponding palette color
step 6
Converts each forward or single Sequence of the image in its corresponding Stroke.
step 7
Take samples of image colors to associate each stroke to its corresponding palette color.
step 8
copy/apply the strokes to an empty vector image and return the vector image after further adjustments
Activity
morevnaproject commentedon Mar 2, 2019
Just want to put a project description here:
From my point of view, the vectorization algorithm of OpenToonz works better, because it identifies separate lines and outputs strokes (result = many separate Outline Layers). This is good for further editing vectorized image.
Demo - https://youtu.be/QkpeR72fOzY
The Potrace tool outputs singles region layer (result = single Region Layer), which is not very comfortable for editing. On the other hand, I believe integration with Potrace might be easier to implement (but I might be wrong).
ankit-kumar-dwivedi commentedon Mar 3, 2019
Well.. yes it seems easy to integrate potrace with synfig that's because it is documented and being used by several other projects. However, on trying myself, I found opentoonz is better and have more accuracy and options.
On finding about the algorithm they use I was unable to directly find any algorithm mentioned anywhere which they use for the raster to vector conversion. Sadly I found no developer documentation for opentoonz :( This means I need to analyze the process and identify the necessary steps which are required so I will let you know after I investigate further.
@morevnaproject Also can you please let me know how much work to be done before gsoc start? I am asking this in regards to point no 2 under the gsoc application faq.
Show evidence of past experience or achievements related to the proposal.What is the priority of this project?
I hope I have not chosen the least priority project 😓
morevnaproject commentedon Mar 3, 2019
git grep "Convert to Vectors"inopentoonzsources dir gives me:So, name of the action is
MI_ConvertToVectors. So I didgit grep MI_ConvertToVectorsand got this:So, I believe it is good to start looking in
toonz/sources/toonz/vectorizerpopup.cpp.About achievements related to proposal I would like to see the following:
The priority of project doesn't plays any role when we choosing who will participate in our GSoC activities. When choosing students we are looking at:
Also other things we consider:
ankit-kumar-dwivedi commentedon Mar 17, 2019
@morevnaproject I have few things to ask regarding opentoonz codebase should I ask here or mail you?
morevnaproject commentedon Mar 17, 2019
@ankit-kumar-dwivedi It's better to ask here. It's possible @blackwarthog might want to join our discussion. ^__^
ankit-kumar-dwivedi commentedon Mar 17, 2019
@morevnaproject okay
I needed to ask that the function doVectorize (which is calling vCore.vectorize(..some args..) where the actual thing is happening)
is responsible for raster to vector which is defined in vectorizerpopup.h/cpp
https://github.com/ankit-kumar-dwivedi/opentoonz/blob/bcc4cf8c2922ff7de541d6eb715f6ff3dde63f86/toonz/sources/toonz/vectorizerpopup.cpp#L212-L226
and is called in
https://github.com/ankit-kumar-dwivedi/opentoonz/blob/bcc4cf8c2922ff7de541d6eb715f6ff3dde63f86/toonz/sources/toonz/vectorizerpopup.cpp#L304
which in turn is called in run()
then why?? start() is called and not run() when convert button is pressed 😕
https://github.com/ankit-kumar-dwivedi/opentoonz/blob/bcc4cf8c2922ff7de541d6eb715f6ff3dde63f86/toonz/sources/toonz/vectorizerpopup.cpp#L970
EDIT : I guess it is related to multithreading, in java also there is run() and start() function I have done multithreading in java not C++ but it's quite similar I guess.
morevnaproject commentedon Mar 18, 2019
As you can see from https://github.com/ankit-kumar-dwivedi/opentoonz/blob/bcc4cf8c2922ff7de541d6eb715f6ff3dde63f86/toonz/sources/toonz/vectorizerpopup.h#L265 Vectorizer class is based on QThread class.
From QT documentation - https://doc.qt.io/qt-5/qthread.html#start -
^__^
ankit-kumar-dwivedi commentedon Mar 20, 2019
@morevnaproject As I got your mail so I verified that there is a crash in case of using the outlinevectorizer method.
Also, I used the same file. On converting to vector( outlinevectorizer ) using "opentoonz" it ran successfully, however, "opentoonz morevna" crashed. So I can confirm the crash is only in morevna edition and not on original opentoonz :/
I am comparing both codebase to know what is the possible reason. Is morevna edition using the tnewoutlinevectorizer.cpp ? The crash was supposed to fix by opentoonz/pull/2057
morevnaproject commentedon Mar 21, 2019
@ankit-kumar-dwivedi The fix of opentoonz/opentoonz#2057 is included into Morevna Edition 1.3.
Please consider, that OpenToonz Morevna Edition doesn't includes all features/fixes of official OpenToonz 1.3. Actually, OpenToonz Morevna Edition 1.3 has only features of official OpenToonz 1.2.1 + our additions (Assistants, Color selector, etc.). This might be the reason why this happens.
ankit-kumar-dwivedi commentedon Mar 24, 2019
@morevnaproject I have mailed you my pre proposal please suggest any changes and let me know your thoughts on it (^_^)
ankit-kumar-dwivedi commentedon Apr 8, 2019
@morevnaproject this feature is intended to be only for gui?
morevnaproject commentedon Apr 8, 2019
Yes!
ankit-kumar-dwivedi commentedon Apr 11, 2019
@morevnaproject the configuration input dialog for opentoonz(centerline) looks like this

Are we going to create the same options dialog or there are some changes required?
And in the centerline algorithm, the first step in processing anti-aliased images so I am starting with the pre-processing part when the layer is anti-aliased.
see toonz/sources/toonzlib/Naa2TlvConverter.cpp
Will push the changes on a new branch in my repository.
Will keep you updated on what I am working on [^_^]
70 remaining items
morevnaproject commentedon Jun 14, 2019
It would be nice to have progressbar so user can see how the process is going. But this is not critical at the moment. I suggest to add it after you get vectorization working.
ankit-kumar-dwivedi commentedon Jun 15, 2019
@morevnaproject You will be glad to know this is fixed :)
also, can you or @blackwarthog help me understand what is this
framein the following lines of code.https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonzlib/vectorizerparameters.cpp#L234
ankit-kumar-dwivedi commentedon Jun 17, 2019
@morevnaproject just making sure you have read it :)
ankit-kumar-dwivedi commentedon Jun 17, 2019
@morevnaproject is there any submission format for the evaluation?
ankit-kumar-dwivedi commentedon Jun 18, 2019
@morevnaproject I found that

weightin the line https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonz/vectorizerpopup.cpp#L366is actually frame which is passed to centerlineconfiguration. Is this frame same as the frame in image below??
If yes then what will be the synfig equivalent of frame?
Also according to Toonz documentation
Then why are they using frame to calculate the thickness ratio?
I apprciate any pointer @blackwarthog @ice0
morevnaproject commentedon Jun 19, 2019
@ankit-kumar-dwivedi Hi! Let's take a look at this formula from https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonzlib/vectorizerparameters.cpp#L234 -
The meaning of this formula is to take a value from
[0;1]segment and find its relative position on another segment[m_cThicknessRatioFirst; m_cThicknessRatioLast].frameis a value from[0;1]segment. This is confirmed by code that you referenced -https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonz/vectorizerpopup.cpp#L364-L366
The last sentence is important. Actually I was not aware that Start / End fields has that meaning.
I have made some tests - yes, it actually allows to "animate" stroke width when vectorization is done for a sequence of images.
I will keep thinking on that and will post more.
morevnaproject commentedon Jun 19, 2019
As I understand from https://google.github.io/gsocguides/mentor/evaluations:
The evaluation guidelines should be provided online by Google at specified times with deadlines.
morevnaproject commentedon Jun 19, 2019
Examples of the questions that may be asked during evaluations - https://developers.google.com/open-source/gsoc/help/evaluations
ankit-kumar-dwivedi commentedon Jun 19, 2019
Okay @morevnaproject I will be testing the skeletonizer output today and will start working on
Next step -
organizeGraphs(skeletons, globals);Now need to start thinking how to represent the output that is because the steps after
organizeGraphs(skeletons, globals);involves TStroke and TVectorImagePmorevnaproject commentedon Jun 19, 2019
Okay, here is how I understood it. The
framevariable in this function is a frame number from timeline. But it is represented by value from [0; 1] range, where0is first frame of all selected frames and1is last frame.This is done in two steps:
(1) - frame number transformed into value from [0;1] range. See lines here - https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonz/vectorizerpopup.cpp#L336-L337 - and here - https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonz/vectorizerpopup.cpp#L362-L363
(2) Then this value is passed to
VectorizerParameters::getCenterlineConfigurationfunction and it calculates thickness multiplier that should be applied at current frame - https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonzlib/vectorizerparameters.cpp#L233-L234This way, when user has multiple frames selected for vectorization, the thickness can be animated.
So, after we understood the meaning of this functionality, let's answer the question - do we need that in Synfig?
No.
In Synfig we can control (and animate) outline thickness using Outline Grow parameter of group - https://wiki.synfig.org/Group_Layer#Outline_Grow_Parameter
So, it' is ok to assume that
conf.m_thicknessRatiovariable always =1.0(at https://github.com/morevnaproject/opentoonz/blob/ac3067fb0cdbdcbc4f7fca959cf0d6c212586fb4/toonz/sources/toonzlib/vectorizerparameters.cpp#L233-L234 ).ankit-kumar-dwivedi commentedon Jun 21, 2019
As it is inconvenient to keep track of every step and some important comments can be lost which contain steps that are currently not top priority but should be implemented later on.
Hence it is better to keep track from milestone now.
So let me brief you about the algorithm for centerlinevectorization from Toonz and where I am
step-1 If the source is a full-color non-antialiased image so this needs to be processed
this is currently not implemented see here
step 2 - centerlinepolygonizer
Extracts a polygonal, minimal yet faithful representation of image contours
Contours polygons (see here )
step 3 - centerlineskeletonizer
The process of skeletonization reduces all objects in an image to lines, without changing the essential structure of the image. (see here)
Further steps are following and have their own issue in the milestone
step 4 - organizeGraphs
The raw skeleton data obtained from StraightSkeletonizer class need to be grouped in joints and sequences before proceding further (In progress)
step 5
Take samples of image colors to associate each sequence to its corresponding palette color
step 6
Converts each forward or single Sequence of the image in its corresponding Stroke.
step 7
Take samples of image colors to associate each stroke to its corresponding palette color.
step 8
copy/apply the strokes to an empty vector image and return the vector image after further adjustments
Further misc adjustments