It is currently 19 Sep 2021, 16:42

• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP
Sponsored content for World Food Program

Fill Average Color Script for GIMP to aid in doing Polygon Art

Share your Python Fu Scripts/plug-ins for GIMP here
tim
GL Blogger
1st Place
5533 Post(s)

Re: Fill Average Color Script for GIMP to aid in doing Polygon Art

Post#21 by tim » 14 Mar 2019, 19:25


Okay it's done, @LVB Please try version 3 (in post #1).

It'll allow you to do multiple selections, each continuous area of the multi-selection will have it's own average color.

more technical details: I found the logics in DivideTransBG.scm (break apart by alpha) script, the logic in code is to turn the multi-selection into a path, then from the path, each stroke will be a separate area, loop through all the strokes creating a temporary path that contains the single stroke and select it then apply the average color on that selection. Works like a charm.
aka Tin
World Food Program | Good Deeds Forum

         

LVB
Forum Member
74th Place
7 Post(s)

Post#22 by LVB » 14 Mar 2019, 22:42


Thank you Tim !!! works really nice, but it doesn’t fill the whole selection, it misses some pixels on the border. Do I have to adjust something else?
It’s like this, the black area is the selection and the gray one is the filled area.
Attachments
Selection.png
Selection.png # (2.95 KiB) Viewed 4038 times (Thumbnail | Recognize | Sq Tile | LNFI)
Result.png
Result.png # (3.73 KiB) Viewed 4038 times (Thumbnail | Recognize | Sq Tile | LNFI)
GIMP Learn rocks...

LVB
Forum Member
74th Place
7 Post(s)

Post#23 by LVB » 15 Mar 2019, 00:54


I think it’s the way the selection turns into a path, but I can’t find how to fix it
GIMP Learn rocks...

tim
GL Blogger
1st Place
5533 Post(s)

Post#24 by tim » 15 Mar 2019, 01:20


LVB wrote:
15 Mar 2019, 00:54
I think it’s the way the selection turns into a path, but I can’t find how to fix it
You're it has to do with the way the selection turns into a path. There is an advanced path to selection but that has way too many variables/options that I do not know how to use.

However, you can work around this by scaling up your image to 4 or 5 times it's size (using no interpolation), then work with that and scale it back down to it's original size (using no interpolation).

Let me know if the work around works for ya.
aka Tin
World Food Program | Good Deeds Forum

         

tim
GL Blogger
1st Place
5533 Post(s)

Post#25 by tim » 15 Mar 2019, 07:49


I think I might have came up with solution in version 4. See post #1.
What I do is I prompt you for a growth option in pixels, for your example use 2 pixels as input so that it'll try to grow the pathed selection by 2 pixels then intersect with original selection of multiple areas to get the exact selection of that area to the pixel accuracy.
Try it out and let me know.
aka Tin
World Food Program | Good Deeds Forum

         

LVB
Forum Member
74th Place
7 Post(s)

Post#26 by LVB » 15 Mar 2019, 19:58


Perfect !!!
I’ve been looking for a tool like this for many years, thank you so much !!!
You’re the best :award_trophy: :gimp_clap:
GIMP Learn rocks...

tim
GL Blogger
1st Place
5533 Post(s)

Post#27 by tim » 15 Mar 2019, 21:33


What is it are you using it for? Any chance you're making video games. Your sample looks like pixel art for a game of some sort.

PS: Your comment made my day... So glad you find it so useful.
aka Tin
World Food Program | Good Deeds Forum

         

tim
GL Blogger
1st Place
5533 Post(s)

Post#28 by tim » 09 Jun 2019, 02:48


version 5 updated for LVB for speed.

UPDATE: added version 6 which allows "Paint-brush intead of Edit-fill" option for speed since painting over selection with a large brush is much faster than using Edit-fill.

What took about an hour in version 4, takes about 15 minutes in version 5, and take only about 4 minutes in version 6 (in GIMP 2.10.8).

UPDATE: Version 7 should be the fastest since you can answer "NO" to dodging filled area, so that if you're just working with transparent selections there's no need for an extra subtract from alpha to selection call.
Up-ed the Maximum undo history cache to 32 Megabyte and version 7 ran in 2 minutes (GIMP 2.10.8).

DON'T be looking at or have the Undo History window opened as if that window is open it has to update that window with many steps and it slows down.
aka Tin
World Food Program | Good Deeds Forum

         

tim
GL Blogger
1st Place
5533 Post(s)

Post#29 by tim » 10 Jun 2019, 02:30


UPDATED: version 8 uses Edit-blend (gradient from same color to same color seems to be faster than other methods without delay).
Tested with new image (and flipped Source layer) so that we don't see speed because of caching or whatever it is that gave the false illusion of speed.

Findings: in GIMP 2.8, drawing methods such as paint-brush, pencil are faster than GIMP 2.10, If you script them in 2.10 (at least in 2.10.8, these methods have a long delay before they finish so it makes scripting using these methods repeatedly extremely slow). However when using gimp-edit-blend (gradient tool) to fill selection of one color (by blending same background to same foreground color) remains fast (much faster than pencil or paint-brush).
aka Tin
World Food Program | Good Deeds Forum

         

LVB
Forum Member
74th Place
7 Post(s)

Post#30 by LVB » 11 Jun 2019, 18:39


A tulip tiling portrait made with Tim’s fill average color script, an enlarged detail is shown at the bottom.
Version 8 runs amazingly fast, thank you Tim!!!
Attachments
TulipTilingPortrait_FillAverageColorScript.jpg
TulipTilingPortrait_FillAverageColorScript.jpg # (264.92 KiB) Viewed 3899 times (Thumbnail | Recognize | Sq Tile | LNFI)
GIMP Learn rocks...


GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply New Topic
  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 20 guests