[Solved] Get colors of the image edge
[Solved] Get colors of the image edge
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.
Last edited by vldvrfc on 2011-05-21T13:52:27-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Get colors of the image edge
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
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
Thank you.