chsh2 / nijiGPen

An add-on of Blender focusing on Grease Pencil
GNU General Public License v3.0
220 stars 9 forks source link

Idea: Convert shape to line #3

Open b4zz4 opened 1 year ago

b4zz4 commented 1 year ago

It's an idea, but I don't really know how to create the program for this.

chsh2 commented 1 year ago

It looks like a useful feature that I am definitely interested in, but I may need to do some surveys first. So far, I cannot find an out-of-the-box solution. Clip Studio Paint has this function but it doesn't publish its algorithm. Its line width data cannot be exported as well. Inkscape can perform similar tasks with centerline trace, but it does not generate width data. There are also some deep-learning-based solutions in recent years but I haven't tried any of them yet.

chsh2 commented 1 year ago

The medial axis transformation method seems good for this operation: https://scikit-image.org/docs/stable/auto_examples/edges/plot_skeleton.html I will do some more investigations to see if it can be used for Grease Pencil.

b4zz4 commented 1 year ago

This is similar, I think imagick is usually a popular library. https://legacy.imagemagick.org/Usage/morphology/#thinning_skeleton

chsh2 commented 1 year ago

I integrated scikit-learn and implemented this operator in a new commit. The new version will be released in the next week. image

b4zz4 commented 1 year ago

I test it and it works perfectly

b4zz4 commented 1 year ago

You probably had this idea. But scikit posterizes images in a very intelligent way. Plans of color or value can be detected in addition to lines. For already painted drawings

chsh2 commented 1 year ago

You probably had this idea. But scikit posterizes images in a very intelligent way. Plans of color or value can be detected in addition to lines. For already painted drawings

About color images, one of my idea is to realize a similar effect like FotoSketcher. But given the ongoing tasks, I guess it may take 2~3 months before I can start this one. Later in this or next week, I may write down a long-term roadmap discussing the functions I have in mind which have not yet been implemented.

chsh2 commented 1 year ago

Maybe my efficiency is too low, but I finally started working on the color image import. I applied k-means to quantize the colors, and then used find_contours to convert them to GPencil paths. It should work well with flat style images, but for realistic photos there will be a loss. And the processing speed is kind of slow, which I cannot do much with.

Flat Color Export 2 Flat Color Export 1

b4zz4 commented 1 year ago

I would like an option to add material instead of colored vertices.

chsh2 commented 1 year ago

I would like an option to add material instead of colored vertices.

I added this option today. It should work for a single image, but I need to make more changes in the future to support videos better. Now different video frames may generate different colors, which lead to too many materials.

b4zz4 commented 1 year ago

Maybe you can create a unique palette for the whole video and generate associating the most similar color