Getting a Posterize effect (GMIC example)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
newmountain
Posts: 2
Joined: 2019-02-19T06:47:03-07:00
Authentication code: 1152

Getting a Posterize effect (GMIC example)

Post by newmountain »

Hello,

I have had a look in the filter-library from GMIC: https://gmic.eu/gallery/
and find some nice filters that I would like to produce in ImageMagick 6.7.8-9

For example, the Posterize one on the URL above is really nice. Does anyone know which combination of convert options should create the same effect as that filter?

Overall, the filters of GMIC look better I think, would like to mimic many of them.

Any tips and help would be great.
Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Getting a Posterize effect (GMIC example)

Post by snibgo »

GMIC was born out of ImageMagick, but with a more logical syntax. Instead of settings that are used by operations, the operations take more arguments that correspond to the settings, and these are usually numbers. One dificulty is that this creates a load of numbers, and we need to know what they represent.

On the page you link, click on the image to see the GMIC command:

Code: Select all

Command: $ gmic lion.png fx_posterize 150,30,1,6,0,0,1,0 
So the GMIC operation is "fx_posterize", and there are 8 numeric arguments. The technical reference should explain the operation. Sadly, it doesn't give that operation. The tutorial doesn't seem to help either.

So we don't know if "fx_posterize" is a built-in command (and hence coded in C) or a custom command (like a script, built from more primitive operations).

We can ask for help:

Code: Select all

f:\web\im>%GMIC% help fx_posterize

  gmic: GREYC's Magic for Image Computing.

        Version 2.1.6 (pre-release #171130), Copyright (c) 2008-2017, David Tsch
umperle.
        (http://gmic.eu)

[gmic] Command 'fx_posterize' has no description. Try 'gmic -h' for global help.
Hmm, that doesn't help. (But this version of GMIC is quite old.)

We can try out the command:

Code: Select all

f:\web\im>%GMIC% toes.png fx_posterize 150,30,1,6,0,0,1,0
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'toes.png' at position 0 (1 image 267x233x1x3).
[gmic]-1./fx_posterize/*repeat/*local/ Split color and opacity parts of image [0
].
[gmic]-1./fx_posterize/*repeat/*local/*local/ Input copy of image [0] at positio
n 1 (1 image 267x233x1x3).
[gmic]-2./fx_posterize/*repeat/*local/*local/ Set local variable 'amp=150'.
[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Smooth image [1] anisotropical
ly, with amplitude 50, sharpness 0.3, anisotropy 1, alpha 1, sigma 2, dl 0.8, da
 30, precision 2, nearest-neighbor interpolation and fast approximation enabled.

[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Update local variable 'amp-=50
'->'100'.
[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Smooth image [1] anisotropical
ly, with amplitude 50, sharpness 0.3, anisotropy 1, alpha 1, sigma 2, dl 0.8, da
 30, precision 2, nearest-neighbor interpolation and fast approximation enabled.

[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Update local variable 'amp-=50
'->'50'.
[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Smooth image [1] anisotropical
ly, with amplitude 50, sharpness 0.3, anisotropy 1, alpha 1, sigma 2, dl 0.8, da
 30, precision 2, nearest-neighbor interpolation and fast approximation enabled.

[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Update local variable 'amp-=50
'->'50'.
[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Smooth image [1] anisotropical
ly, with amplitude 50, sharpness 0.3, anisotropy 1, alpha 1, sigma 2, dl 0.8, da
 30, precision 2, nearest-neighbor interpolation and fast approximation enabled.

[gmic]-2./fx_posterize/*repeat/*local/*local/*do/ Update local variable 'amp-=50
'->'0'.
[gmic]-2./fx_posterize/*repeat/*local/*local/ Apply joint bilateral filter on im
age [0], with guide image [1],  standard deviations (5,10) and sampling (0,0).
[gmic]-2./fx_posterize/*repeat/*local/*local/ Remove image [1] (1 image left).
[gmic]-1./fx_posterize/*repeat/*local/*local/ Convert color representation of im
age [0] from sRGB to linear RGB.
[gmic]-1./fx_posterize/*repeat/*local/*local/ Estimate colormap with 6 entries f
or image [0], by k-means method.
[gmic]-2./fx_posterize/*repeat/*local/*local/ Convert color representation of im
ages [0,1] from linear RGB to sRGB.
[gmic]-2./fx_posterize/*repeat/*local/*local/ Index values in image [0] by LUT [
1], with dithering level 0.
[gmic]-2./fx_posterize/*repeat/*local/*local/ Map LUT [1] on image [0], with dir
ichlet boundary conditions.
[gmic]-2./fx_posterize/*repeat/*local/*local/ Remove image [1] (1 image left).
[gmic]-1./fx_posterize/*repeat/*local/*local/*if/ Normalize image [0] in range [
0,255].
[gmic]-1./fx_posterize/*repeat/*local/ Append image [0] along the 'c'-axis, with
 alignment 0.
[gmic]-1./ Display image [0] = 'toes.png'.
[0] = 'toes.png':
  size = (267,233,1,3) [729 Kio of floats].
  data = (0,0,0,0,0,0,0,0,0,0,0,0,(...),0,0,0,0,0,0,0,0,0,0,0,0).
  min = 0, max = 0, mean = 0, std = 0, coords_min = (0,0,0,0), coords_max = (0,0
,0,0).
[gmic]-1./ End G'MIC interpreter.
This shows an image that seems to be totally black. The text output says "min = 0, max = 0, mean = 0", so yes, it is black. Hmm.

At this stage, I suggest you ask on the pixls.us forum. The GMIC author, David Tschumperlé, is a regular poster. Someone there might explain the 8 parameters, or point you towards relevant documentation.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Getting a Posterize effect (GMIC example)

Post by fmw42 »

Please do not double post. You have a post also in Consulting.
Post Reply