В Imagemagick 6 вы можете сделать следующее, чтобы изолировать "kelloggs".
fill back to replace everything but the red color
fill white to replace the red color
convert kellogg.jpg -fuzz 15% \
-fill black +opaque "rgb(240,0,0)" \
-fill white -opaque "rgb(240,0,0)" \
result.png
Для вашей "Мэгги"изображение, это немного сложнее, так как у вас есть желтый для" Мэгги "и желтый в другом месте.
fill yellow color to replace the white in the corners
fill yellow color to replace black
floodfill the outside yellow with black
fill black to replace everything but yellow
fill white to replace yellow
convert maggie.jpg \
-fuzz 15% -fill "rgb(254,242,0)" -opaque white \
-fuzz 20% -fill "rgb(254,242,0)" -opaque black \
-fuzz 15% -fill black -draw "color 10,10 floodfill" -alpha off \
-fuzz 15% -fill black +opaque "rgb(254,242,0)" \
-fuzz 15% -fill white -opaque "rgb(254,242,0)" \
result2.png
Но товарный знак остался.Чтобы удалить это, мы добавляем обработку подключенных компонентов, чтобы отфильтровать наименьшие белые области.
convert maggie.jpg \
-fuzz 15% -fill "rgb(254,242,0)" -opaque white \
-fuzz 20% -fill "rgb(254,242,0)" -opaque black \
-fuzz 15% -fill black -draw "color 10,10 floodfill" -alpha off \
-fuzz 15% -fill black +opaque "rgb(254,242,0)" \
-fuzz 15% -fill white -opaque "rgb(254,242,0)" \
-define connected-components:area-threshold=50 \
-define connected-components:mean-color=true \
-connected-components 4 \
result3.png