GIMP Script-fu

Artifact [b82b6b6687]
Login

Artifact b82b6b66877ce5c85306804c457bf477b82e0233:

Wiki page [sg-quantize] by saulgoode 2014-01-06 15:17:53.
D 2014-01-06T15:17:53.935
L sg-quantize
P 074286430e1fc61da4810f9215a4deab24156f52
U saulgoode
W 2774
<dl>
<dt><b>Command:</b> <dd>Quantize</dd></dt>
<dt><b>Menu:</b> <dd>"<Image>/Colors/Quantize..."</dd></dt>
<dt><b>PDB Name:</b> <dd>script-fu-sg-quantize</dd></dt>
<dt><b>Download:</b> <dd>[http://chiselapp.com/user/saulgoode/repository/script-fu/artifact/4805528bcf11458114083075808bca07b9769998|sg-quantize.scm] (after the page appears, click on the "Download" command)</dd></dt>
<dt><b>License:</b> <dd>[copyright|GPLv2+]</dd></dt>

<dt><b>Description:</b> <dd>This script will reduce the active layer to the specified number of colors (also works on layer masks and channels). An option is available for the amount of smoothing applied to the edges between colors (default is none). There is also a "Rounded?" option which produces a slightly different distribution of the colors, typically one more abstract. The final option, "Use selection as smoothing mask", will protect the selected region from smoothing; however, the entire layer is converted to the reduced color scheme. Finally, a "polygonal" option is available that attempts to straighten the edges between colors (dramatically affected by the amount of smoothing).

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/460/SSquantize.png" />
</center>

With no smoothing (the default setting), the effect on the layer is identical to converting to Indexed mode with the specified number of colors; however, this script has the advantage of not affecting other layers in the image. 

NOTE: The polygonal option can cause the script to run very slowly, especially with low values of smoothing.

Starting with the following image, courtesy of user Nachbarnebenan of the [http://forum.meetthegimp.org/index.php|Meet The GIMP forums]:

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/60/quant-orig.jpg" />
</center>

The default values will produce the following result (note that this is equivalent result to converting to Indexed Mode with 16 colors):

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/59/quant-nosmooth.jpg" />
</center>

And with a smoothing value of "3":
<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/62/quant-smooth3.jpg" />
</center>

And with the "Use selection as smoothing mask" option. Note how the selection around the hair protects it from smoothing, yet it is still converted to the limited color scheme. 
<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/58/quant-mask-selected.jpg" />
</center>

And finally, here is the result of using the polygonal option (and with a smoothing of "3").

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/61/quant-poly.jpg" />
</center>

</dd></dt>
</dl>

Z 7d2e1c124fc0d23ade6fd007a81a871a