Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Color Detection in Bash…
- I stumbled upon this article about Color Detection in Scans…
- http://virantha.com/2014/03/30/images-color-and-blank-detection/
- It's written in Python… I thought it my be quite handsome to have the same idea as bash script… and as usual I build a 1-liner.
- Needed: Imagemagicks 'convert', sed, awk & cat – you always need a cat ;)
- cat Name_a_picture.png | convert - -colors 8 -depth 8 -format %c histogram:info:- | sed -e 's/\((\|)\)/_/g' -e 's/ //g' -e 's/_/ /g' | awk '{print $1" "$2}' | sort -t : -k 1 -g -r | awk '{print $2}' | sed -e 's/,/ /g' | awk -F' ' 'function abs(x){return ((x < 0.0) ? -x : x)} {if (((abs($3-$2)+abs($3-$1)+abs($2-$1))/3) > 20) print "Color found."}'
- …grumpy…
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement