How to change histogram stdout format
Posted: 2018-03-14T15:06:07-07:00
Hi All,
Trying to read the result of histogram analysis in python but running into issues based on the stdout formatting.
I run:
which gives me:
I can read this into python using space ( ' ' ) as a delimiter, however, this leads to issues with the last row where because the blue value (102) has 3 digits instead of 2 (like the rest of the blue values), there isn't a space and this breaks the file read.
Ideally I would like to format the stdout to use comma or tab separated values. OR just strip out the formatting and not add leading spaces in the case of a 1 or 2 digit value.
I've tried searching but only get results showing how to format image outputs, not histogram text stdout.
Thanks in advance!
-Sante
Trying to read the result of histogram analysis in python but running into issues based on the stdout formatting.
I run:
Code: Select all
convert pic_4.jpg -colors 256 -depth 8 -format "%c" histogram:info: | head -n 5 >> hist_4.txt
Code: Select all
705711: ( 37, 42, 35) #252A23 srgb(37,42,35)
562775: ( 39, 39, 41) #272729 srgb(39,39,41)
154348: ( 39, 42, 30) #272A1E srgb(39,42,30)
88998: ( 40, 41, 54) #282936 srgb(40,41,54)
5824: ( 40, 49,102) #283166 srgb(40,49,102)
Code: Select all
df = pd.read_table(filename, sep='\s+', header=None)
Ideally I would like to format the stdout to use comma or tab separated values. OR just strip out the formatting and not add leading spaces in the case of a 1 or 2 digit value.
I've tried searching but only get results showing how to format image outputs, not histogram text stdout.
Thanks in advance!
-Sante