Gimp-Forum.net
Count number of mosaic tiles occurencies per color - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Count number of mosaic tiles occurencies per color (/Thread-Count-number-of-mosaic-tiles-occurencies-per-color)



Count number of mosaic tiles occurencies per color - aquilinux - 01-14-2021

Hello, i'm trying to easy the process of making mosaic (real mosaics) from photos with the use of GIMP.
So far i have:

- Created a custom 37 colors palette of solid colors i use with mosaic tiles
- Created a Distort/Mosaic preset with the preferred mosaic settings (i use one color oper tile)
- Imported Image -> Distort Image -> Indexed image with palette colors (see attachment)

Now that i have a mosaic, how can i count the number of tiles i need per color (based on my palette)? (ex. 30 Black tiles, 57 Green tiles)


I'm familiar with basic programming but i'm no programmer.
Can anyone give me hints on this or does already exist a script/plugin/extension for this?



Thanks!


RE: Count number of mosaic tiles occurencies per color - rich2005 - 01-14-2021

There is probably a script already around for this. In the meantime, the old way is 
Convert your mosaic to Indexed mode with your 37 unique colours.
In the ColorMap dialogue select a colour.
The Histogram dialogue gives the number of selected pixels
Divide that by the image tile area in pixels to give a physical tile count.
---
..onto the next colour...

[attachment=5476]


RE: Count number of mosaic tiles occurencies per color - aquilinux - 01-14-2021

Very useful, thanks!
By the way, i see your mosaic is very neat while my mosaic is disturbed by white borders here and there despite using no tile spacing between tiles:

[attachment=5477]

Does it depends from the image source (mine being a photo) or from some filter/operation i'm not applying?

[attachment=5478]

Thanks indeed!


RE: Count number of mosaic tiles occurencies per color - rich2005 - 01-14-2021

I did not use the mosaic filter Wink As a demo I just used a regular RGB image, then applied Blur -> Pixelise to get the mosaic. Converted that to indexed with 37 colours, so all a bit of a fudge. There are other applications that will make a mosaic using a set of sub-images. The linux one is called metapixel.

Also a gmic filter picture-mosaic, just about to go off and try it.

edit: Ok tried it for the mosaic generation, not for counting tiles. Made a folder of coloured tiles, (10x10 pngs) and applied the gmic filter - example https://i.imgur.com/ln6Oa4C.jpg