There may be more efficient ways of doing it but, this is the way I 've cobble together. This code will get the color information for a pixel at 200x200 in an image called bud.jpg. The printed result looks like this: Color(0.129, 0.145, 0.186, 1.000)
Hope this helps.....
coreimage = ximport("coreimage") x = 200 y = 200 canvas = coreimage.canvas(150,150) l = canvas.append("bud.jpg", w= 800) p = l.pixels() clr = p.get_pixel(x,y) print clr
size(400, 400)
colors = ximport("colors")
coreimage = ximport("coreimage")
canvas = coreimage.canvas(400, 400)
layer = canvas.layer("imageName.png")
pixel = layer.pixels()
pColor = pixel.get_pixel(x, y)
I'd also like to know about this -
The coreimage .get_pixel method returns a Color() object.
I'd like to test if that Color() is black, I guess using the .is_black property from the Colors library.
How would I go about doing this? I'm a newb, can't work out how to use the Color() that .get_pixel returns with the .is_black property from the Colors library.
Adding to the example above, you can do:
print colors.color(pColor).is_black
I'm trying to get a color from an image file.For example I have a grey image with rgb values (128,128,128).
If I use the get_pixel command it comes up with a value of Color(0.565, 0.565, 0.565, 1.000).
I expected to get Color(0.5, 0.5, 0.5,1.000)
All colors seem to come out much brighter than in the original image. What am I doing wrong?
get the color of a pixel
Posted by ilmeditafuga on Feb 16, 2010HI!
I am a newbie and I try to get a color from a pixel of my image.
I am sorry if is not a great question but I doesnt found how to.
M.