I am trying to remove the background of my suppliers products. He takes pictures with a studio showing his brand and contacts, which i can't show in my e-store.
I need to blur all the background including his logos and all the text he displays.
His images look like this:


and should end up like this:

this is the code i am using:
Code: Select all
convert ${IMGPATH}${IMGNAME} \( +clone -fx 'p{0,0}' \) -compose Difference -composite -fuzz 15% -modulate 100,10 +matte ${IMGPATH}${IMGNAME}_difference.png
convert ${IMGPATH}${IMGNAME}_difference.png -bordercolor white -border 1x1 -matte -fill none -fuzz 7% -draw 'matte 1,1 floodfill' -shave 1x1 ${IMGPATH}${IMGNAME}_removed_black.png
composite -compose Dst_Over -tile pattern:checkerboard ${IMGPATH}${IMGNAME}_removed_black.png ${IMGPATH}${IMGNAME}_removed_black_check.png
convert ${IMGPATH}${IMGNAME}_removed_black.png -channel matte -separate +matte ${IMGPATH}${IMGNAME}_matte.png
convert ${IMGPATH}${IMGNAME}_matte.png -negate -blur 0x1 ${IMGPATH}${IMGNAME}_matte-negated.png
convert ${IMGPATH}${IMGNAME}_matte.png -morphology Erode Diamond ${IMGPATH}${IMGNAME}_erode_matte.png
composite -compose CopyOpacity ${IMGPATH}${IMGNAME}_erode_matte.png ${IMGPATH}${IMGNAME} ${IMGPATH}${IMGNAME}_finished.png
convert ${IMGPATH}${IMGNAME}_finished.png -bordercolor white -border 1x1 -matte -fill none -fuzz ${THRESHOLD}% -draw 'matte 1,1 floodfill' -shave 1x1 ${IMGPATH}${IMGNAME}_final.png

The program is having difficult with the logos and shadows. The shadows are not trouble as the intention is to blur the background in the end so it won't be that noticable. but the logos are my problem.
Any help how to find blur the logos?