Hi I am asking this with reference to this question Fuzzy flood fill in ImageMagic php - making a transparent image
#!/bin/bash
# Get size of original
sz=$(convert -format "%wx%h" phone.png info:)
# Floodfill background area with transparency
convert phone.png -fuzz 5% -fill none -draw 'color 0,0 floodfill' ObjectOnTransparent.png
# Extract alpha channel
convert ObjectOnTransparent.png -alpha extract Alpha.png
# Extract edges of alpha channel - experiment with thickness
convert Alpha.png -edge 1 AlphaEdges.png
# Get difference from background for all pixels
convert phone.png \( +clone -fill white -colorize 100% \) -compose difference -composite Diff.png
# Multiply edges with difference, so only edge pixels will have a chance of getting through to final mask
convert AlphaEdges.png Diff.png -compose multiply -composite EdgexDiff.png
# Extend Alpha by differences at edges
convert Alpha.png EdgexDiff.png -compose add -composite ReEdgedAlpha.png
# Apply new alpha to original image
convert phone.png \( ReEdgedAlpha.png -colorspace gray \) -compose copyopacity -composite RemaskedPhone.png
# Splat RemaskedPhone over red background
convert -size $sz xc:red RemaskedPhone.png -composite Result.png
I ran these scripts and it is running accurate on images with white background and it is producing clean edges, but I want to ask if there is any way that I can remove any color background from an image like this image https://ibb.co/BNWnNBs from which I want to remove the black color from corners of image like this https://ibb.co/x7nD8Vb.
Any help is appreciated thanks





