finding the RGB value of a pixel
finding the RGB value of a pixel
Is there a way to ask for the RGB values of a pixel at location X, Y?
Re: finding the RGB value of a pixel
What are you using? The command-line, PerlMagick, MagickCore, MagickWand, Magick++, iMagick? The answer depends on your interface to ImageMagick.Is there a way to ask for the RGB values of a pixel at location X, Y?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: finding the RGB value of a pixel
convert rose.png[1x1+10+10] txt:
# ImageMagick pixel enumeration: 1,1,65535,rgb
0,0: (18504,16448,14649) #484840403939 rgb(72,64,57)
or
convert rose.png[1x1+10+10] -format "%[fx:int(255*r)],%[fx:int(255*g)],%[fx:int(255*b)]" info:
72,64,57
# ImageMagick pixel enumeration: 1,1,65535,rgb
0,0: (18504,16448,14649) #484840403939 rgb(72,64,57)
or
convert rose.png[1x1+10+10] -format "%[fx:int(255*r)],%[fx:int(255*g)],%[fx:int(255*b)]" info:
72,64,57
Re: finding the RGB value of a pixel
I don't understand this [1x1+10+10]
What does this mean?
What does this mean?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: finding the RGB value of a pixel
It is a subsection of the image that is 1x1 pixel at offset x=10 and y=10 from the upper left corner.
see
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/files/#read_mods
you can also do it this way:
convert rose.png -format "%[fx:int(255*p{10,10}.r)],%[fx:int(255*p{10,10}.g)],%[fx:int(255*p{10,10}.b)]" info:
72,64,57
see
http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/Usage/transform/#fx_escapes
If you are on Windows, see
http://www.imagemagick.org/Usage/windows/
see
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/files/#read_mods
you can also do it this way:
convert rose.png -format "%[fx:int(255*p{10,10}.r)],%[fx:int(255*p{10,10}.g)],%[fx:int(255*p{10,10}.b)]" info:
72,64,57
see
http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/Usage/transform/#fx_escapes
If you are on Windows, see
http://www.imagemagick.org/Usage/windows/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: finding the RGB value of a pixel
Its a crop done immediateally after reading, before the image is added to the current image sequence in memory.drewvy wrote:I don't understand this [1x1+10+10]
Equivelent to
Code: Select all
convert rose.png -crop 1x1+10+10 txt:-
NOTE you may have to quote the square brackets as it is a 'shell meta-charcater'
so the original command should have been...
Code: Select all
convert rose.png'[1x1+10+10]' txt:-
Code: Select all
convert rose.png -format "%[pixel:p{10,10}]" info:
For more methdos and information see
IM Examples, Color Quantization and Dithering, Extracting Colors
http://www.imagemagick.org/Usage/quantize/#extract
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/