pixelsort criteria on command line

Newbie here, so please be gentle.

I can’t work out how to specify sorting criteria on the command line, despite much trial and error.

I’ve started to explore pixelsorting using the G’MIC GIMP plug-in and would now like to replicate the results using the Linux command line. The documentation is minimal, and I cannot work out how to specify the sorting criterion. (I don’t need to mask so am ignoring this option.)

gmic input.jpg +pixelsort[0] -,x,[-1]

This produces an image sorted in the x dimension but on what basis? I don’t understand how to take the documentation syntax sorting_criterion=mask=(undefined) and turn it into usable code on the command line. For example,

gmic input.jpg +pixelsort[0] -,x,[-1],[Red]

generates an undefined label Red` error, as do all my other trial-and-error attempts.

Can anyone demystify how to set sorting criteria on the command line? I’d like to sort on any of Red, Green, Blue, Hue, Luminance, etc … all the values that appear in the Plug-in’s drop-down Criterion menu.

(Is there a way of displaying the G’MIC code that the plug-in is running?)

Thanks

No worry, here, we are gentle “by default” :kissing_heart:

If no sorting criterion is set, the command pixelsort by default uses the sum of values of all channels (so for a RGB image, the sorting criterion is R+G+B).
This should be mentioned in the reference documentation by the way.

If you want, e.g. to use only the red channel for the sorting criterion, then you can write:

gmic sp colorful +channels[-1] 0 name[-1] Red pixelsort[-2] -,x,[Red] rm[Red]

that can be also written as (with shortcuts):

gmic sp colorful +channels. 0 pixelsort.. -,x,. rm.

For Green and Blue, just replace +channels. 0 by +channels. 1 and +channels. 2.
For the Hue:

gmic sp colorful +rgb2hsv. channels. 0 pixelsort.. -,x,. rm.

For the Luminance:

gmic sp colorful +luminance pixelsort.. -,x,. rm.

Also, you may find easier to use the plug-in “Copy Command to Clipboard” button, that copies the G’MIC command invoked by the plug-in for a certain filter, to the clipboard :

Her for instance, it gives me:

fx_pixelsort 1,0,6,1,0,100,0,0,0

So you can write:

gmic input.jpg fx_pixelsort 1,0,6,1,0,100,0,0,0 output output.jpg
2 Likes

Thank you, @David_Tschumperle, for your very detailed reply. It answers all my questions … and was very gentle too :slight_smile:

Thanks!

1 Like