Page 1 of 1
Using -format to get and/or work on a sequence of pixels?
Posted: 2009-06-17T09:16:03-07:00
by pitosalas
Lets say I have a 1x100 pixel image called scanline.tif
I would like to use a convert -format ... form to output (to stdout) a list of the pixels (in any form -- what I need is the coordinate and the red color value, but I can parse that out myself.)
I played with a lot of the options (-format as well as the -fx stuff) and I can't see how to do it.
I see that I can convert the whole thing to a text format but then a file is written which I would prefer not.
Thanks!
Pito
Re: Using -format to get and/or work on a sequence of pixels?
Posted: 2009-06-17T09:28:03-07:00
by fmw42
First 10 red pixels in rose: image (values between 0 and 1).
convert rose:[10x1+0+0] -channel red -separate -fx "debug(u)" null:
ROSE[0,0].red: u=0.188235
ROSE[1,0].red: u=0.196078
ROSE[2,0].red: u=0.211765
ROSE[3,0].red: u=0.219608
ROSE[4,0].red: u=0.227451
ROSE[5,0].red: u=0.223529
ROSE[6,0].red: u=0.219608
ROSE[7,0].red: u=0.223529
ROSE[8,0].red: u=0.219608
ROSE[9,0].red: u=0.219608
see fx debugging at
http://www.imagemagick.org/Usage/transform/#fx_escapes
Re: Using -format to get and/or work on a sequence of pixels?
Posted: 2009-06-17T12:14:09-07:00
by pitosalas
Thanks!!
By the way, although the doc says so, it appears to me that mogrify doesn't accept -fx:
$ mogrify slither.tif -channel red -separate -fx "debug(u)"
mogrify: unrecognized option `-fx' @ mogrify.c/MogrifyImageCommand/4563.
(one of many variations I tried.)
Am I missing it again?
Pito
Re: Using -format to get and/or work on a sequence of pixels?
Posted: 2009-06-17T22:23:14-07:00
by anthony
The easiest way is txt:
See Im Examples, Files, Special Formats, Txt
txt
http://www.imagemagick.org/Usage/files/#txt
As -fx is a list operator, in that it will replace ALL the images in the current image list with the one resulting image. "mogrify" does not accept a list operator by its defination as it only deals with ONE image at a time.
You can use txt: though...
mogrify -format txt images....
That will create a Enumerated Pixel Image Text File (.txt) for every image given.