Page 1 of 1

How to Write Histogram to Text File?

Posted: 2008-07-11T03:35:03-07:00
by stowball
How do you write the histogram of an image to a text file?

Taking the examples in the docs...

Code: Select all

convert  tree.gif  -format %c histogram:info:-
shows the histogram, which is 6 different colours on 6 lines, however, using

Code: Select all

convert  tree.gif  -format %c histogram:info:- file.txt
creates a 1026 line file, containing a line for each pixel in the 32x32 image.

Can somebody enlighten me please?

Thanks

Matt

Re: How to Write Histogram to Text File?

Posted: 2008-07-11T09:22:24-07:00
by fmw42
convert tree.gif -format %c histogram:info:- >2 file.txt

Re: How to Write Histogram to Text File?

Posted: 2008-07-11T14:30:40-07:00
by stowball
Thanks!

I had to remove the "2" though - was that a typo?

Code: Select all

convert tree.gif -format %c histogram:info:- > file.txt

Re: How to Write Histogram to Text File?

Posted: 2008-07-11T14:57:40-07:00
by fmw42
Not a typo. The >2 was needed on my Mac OSX (unix) environment and does not work without the 2. Are you on Window? or some other Linux?

Re: How to Write Histogram to Text File?

Posted: 2008-07-11T16:17:31-07:00
by stowball
Hmm. I'm on Windows. Interesting.

Re: How to Write Histogram to Text File?

Posted: 2008-07-11T16:49:06-07:00
by fmw42
actually I believe more properly on unix it should be

convert tree.gif -format %c histogram:info:- 2>&1 file.txt

Re: How to Write Histogram to Text File?

Posted: 2008-07-11T16:58:55-07:00
by el_supremo
I tried that on my WIn XP system and the output does get sent to standard output whereas on the Mac (and Linux?) it would appear that it gets sent to standard error.

Pete

Re: How to Write Histogram to Text File?

Posted: 2008-07-11T17:19:36-07:00
by stowball
fmw42 wrote:actually I believe more properly on unix it should be

convert tree.gif -format %c histogram:info:- 2>&1 file.txt
Trying this on Windows gave me a 90000 line pixel enumeration file.

I think I'll stick with what I have for the time being.

Thanks guys.

Re: How to Write Histogram to Text File?

Posted: 2008-07-13T18:51:47-07:00
by anthony
Or even better, write it directly to the file, rather than tto stdout/stderr (the meaning of ther '-')

Code: Select all

convert  tree.gif  -format %c histogram:info:file.txt