Note for Windows Users All these utilities is available under Windows, including a BASH shell, using the
cygwin package.
Okay you want an array, try this in unix command
First get the PGM output as one number per line (after striping of the header)
Code: Select all
convert rose:[10x10+0+0] -colorspace gray -compress none -depth 8 PGM:- |
tail -n +4 | tr -s ' \012' '\012'
Now make it 10 numbers per row...
Code: Select all
47 48 51 52 52 52 50 51 50 50
46 47 49 50 51 50 49 51 51 51
44 44 47 47 45 46 45 46 45 46
45 45 45 45 43 43 43 43 44 44
46 46 46 46 43 43 42 39 42 43
47 47 48 49 49 48 46 43 43 42
50 51 51 54 54 52 50 47 49 46
55 55 56 58 61 60 59 56 56 54
56 57 61 63 64 66 65 65 65 62
54 55 60 64 66 68 68 69 68 63
this will let you adjust the number of columns. the number is 8 * pixels_per_row
If you don't mind the data 'transposed' diagonally you can use a VERY old command
called pr
Code: Select all
47 46 44 45 46 47 50 55 56 54
48 47 44 45 46 47 51 55 57 55
51 49 47 45 46 48 51 56 61 60
52 50 47 45 46 49 54 58 63 64
52 51 45 43 43 49 54 61 64 66
52 50 46 43 43 48 52 60 66 68
50 49 45 43 42 46 50 59 65 68
51 51 46 43 39 43 47 56 65 69
50 51 45 44 42 43 49 56 65 68
50 51 46 44 43 42 46 54 62 63
the first number in pr is number of 'lines' (image width as image is transposed)
the second the number of columns per line (image height)
You could transpose the image before outputting so 'pr' can transpose back correctly.
Code: Select all
convert rose:[10x10+0+0] -colorspace gray -transpose -compress none -depth 8 PGM:- |
tail -n +4 | tr -s ' \012' '\012' | pr -t -10 -l10
Code: Select all
47 48 51 52 52 52 50 51 50 50
46 47 49 50 51 50 49 51 51 51
44 44 47 47 45 46 45 46 45 46
45 45 45 45 43 43 43 43 44 44
46 46 46 46 43 43 42 39 42 43
47 47 48 49 49 48 46 43 43 42
50 51 51 54 54 52 50 47 49 46
55 55 56 58 61 60 59 56 56 54
56 57 61 63 64 66 65 65 65 62
54 55 60 64 66 68 68 69 68 63
Their are lots of solutions in UNIX. Basically because UNIX has been around longer and comes of the days before fancy iterative graphics!