Created
April 6, 2019 19:25
Naive function that checks to see if a specific pixel is part of a green letterbox bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RED_BOUNDARY="50" # less than | |
GREEN_BOUNDARY="250" # greater than | |
BLUE_BOUNDARY="20" # less than | |
# Usage: check_for_green_bar x-coord y-coord gravity | |
# Returns: 0 if pixel is bright green, 1 if pixel is not | |
function check_for_green_bar { | |
color=$(convert thumbnail-gbc.jpg -crop "1x1+${1}+${2}" -gravity "${3}" txt:- | grep -oE 'srgb\(.+\)' | grep -oE '[0-9,]+') | |
found_red=$(echo $color | grep -oE '^[0-9]+') | |
found_green=$(echo $color | sed -E s/[0-9]+,// | grep -oE '^[0-9]+') | |
found_blue=$(echo $color | sed -E s/[0-9]+,[0-9]+,// | grep -oE '^[0-9]+') | |
if [[ ($found_red -le $RED_BOUNDARY ) && ($found_green -ge $GREEN_BOUNDARY) && ($found_blue -le $BLUE_BOUNDARY) ]]; | |
then | |
echo 0 | |
else | |
echo 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment