If you convert those areas to transparency, then user snibgo has a hole-filling script. See
http://im.snibgo.com/fillholespri.htm and
http://im.snibgo.com/fillholes.htm
Alternately, you can do a fuzzy floodfill at each region
Code: Select all
convert image -fuzz XX% -fill somecolor -draw "color x,y floodfill" resultimage
where XX% determines how much tolerance to use to fill the region located at x,y and somecolor is your desired background color (they tan color in your image). See
http://www.imagemagick.org/Usage/draw/#color
Another way is to make the image into a binary mask and use connected components to label each isolated region and then discard those regions, which will be the larger ones. The use the filtered mask to recolor those regions with your tan background color. See
http://magick.imagemagick.org/script/co ... onents.php
This is a very simple way, but leaves a small border around the regions. It simply gets the average color of your image. Then creates a mask by thresholding and uses the mask to recolor the black parts of the image. Unix syntax.
Code: Select all
color=`convert Nominal_20151207_103630_000098.jpg -scale 1x1 -format "%[pixel:u.p{0,0}]" info:`
convert Nominal_20151207_103630_000098.jpg \
\( -clone 0 -fill "$color" -colorize 100 \) \
\( -clone 0 -threshold 35% -negate \) \
-compose over -composite result.jpg
Please always provide your IM version and platform when asking questions, since syntax may vary.