Page 1 of 1

[Solved] Get colors of the image edge

Posted: 2011-05-21T08:39:44-07:00
by vldvrfc
Image

I need 4 colors, which are closest to left, top, right, bottom. (In this image, the colors I need are green, orange, blue, gray.)

Thanks.

Re: Get colors of the image edge

Posted: 2011-05-21T10:08:55-07:00
by fmw42
trim the bound of white, then convert the first and last rows and columns to text format and then filter out all white pixels, and keep only one return value (unless you want all non-white values along the edges?)

In unix this would be:

convert Z1UPu.gif -trim +repage Z1UPu_trim.gif

convert Z1UPu_trim.gif -gravity north -crop x1+0+0 txt:- | tail -n +2 | grep -m 1 -v "white"
81,0: (255,102, 0) #FF6600 rgb(255,102,0)

convert Z1UPu_trim.gif -gravity east -crop 1x+0+0 txt:- | tail -n +2 | grep -m 1 -v "white"
0,56: ( 0, 0,255) #0000FF blue

convert Z1UPu_trim.gif -gravity south -crop x1+0+0 txt:- | tail -n +2 | grep -m 1 -v "white"
83,0: (128,128,128) #808080 fractal

convert Z1UPu_trim.gif -gravity west -crop 1x+0+0 txt:- | tail -n +2 | grep -m 1 -v "white"
0,53: ( 0,255, 0) #00FF00 lime

If on Windows, then you need to review http://www.imagemagick.org/Usage/windows/ or get one of the Windows users to help deal with the unix, tail and grep and pipes

Re: Get colors of the image edge

Posted: 2011-05-21T13:51:36-07:00
by vldvrfc
Thank you. :D