Page 1 of 1

how to sort the data histogram: descending?

Posted: 2010-06-17T12:37:48-07:00
by Nezar
Please, I'm sorry for my English - translated text translator

I need to sort the data histogram: descending
Ie from

Code: Select all

 15: (4, 4, 4.255) # 040404 rgba (4,4,4,1) 
         4: (7, 7, 7,255) # 070707 rgba (7,7,7,1) 
        20: (8, 8, 8.255) # 080808 grey3 
I need to get a txt file

Code: Select all

 20: (8, 8, 8.255) # 080808 grey3 
        15: (4, 4, 4.255) # 040404 rgba (4,4,4,1) 
         4: (7, 7, 7,255) # 070707 rgba (7,7,7,1) 
tried
convert tree.gif-format% c histogram: info: - | sort-r-k 1
fails
if you do so
convert tree.gif-format% c histogram: info: - | sort
some sort - but ascending

Please tell my how to solve the problem.

And another question
possible to derive a txt file only the maximum number of pixels of one color
for this example - 20

Re: how to sort the data histogram: descending?

Posted: 2010-06-17T14:50:56-07:00
by fmw42
You have not been careful about spaces:

try


convert tree.gif -format "%c" histogram:info:- | sort -r -k 1

422: ( 0,255,255) #00FFFF cyan
381: ( 50,205, 50) #32CD32 LimeGreen
126: ( 46,139, 87) #2E8B57 SeaGreen
59: (160, 82, 45) #A0522D sienna
20: (255,255, 0) #FFFF00 yellow
16: ( 0,128, 0) #008000 green


This will send to a file:


convert tree.gif -format "%c" histogram:info:- | sort -r -k 1 > sort.txt

This will give the first line from the sort with the largest count:


convert tree.gif -format "%c" histogram:info:- | sort -r -k 1 | head -n 1

422: ( 0,255,255) #00FFFF cyan



This will get just the count (and remove the leading spaces):

convert tree.gif -format "%c" histogram:info:- | sort -r -k 1 | head -n 1 | cut -d: -f 1 | sed 's/ //g'

422

Re: how to sort the data histogram: descending?

Posted: 2010-06-17T22:59:25-07:00
by Nezar
convert tree.gif -format "%c" histogram:info:- | sort -r -k 1
does not work and gives an error - input file is determined by the double

convert tree.gif -format "%c" histogram:info:- | sort -r -k 1 | head -n 1
also an error -
"head" is not an internal or external
command, operable program or batch file.


at varying - Windous 7
and convert.exe - 6.6.2

Re: how to sort the data histogram: descending?

Posted: 2010-06-17T23:17:39-07:00
by snibgo
These are operating system questions, not questions about ImageMagick.

In Windows, "help sort" will show you how to reverse the output ("/R").

Re: how to sort the data histogram: descending?

Posted: 2010-06-17T23:48:08-07:00
by Nezar
snibgo wrote:These are operating system questions, not questions about ImageMagick.

In Windows, "help sort" will show you how to reverse the output ("/R").
/R works! Thank you. I do not know what sort relates to the functions of Windows.
can recommend you the first line in it withdraw? )

Re: how to sort the data histogram: descending?

Posted: 2010-06-18T10:07:50-07:00
by fmw42
My commands above are for unix. Windows users see http://www.imagemagick.org/Usage/windows/