How can I extract an object (Signature) from a white background image (A4 Paper) taken using a mobile camera in C#/.NET and crop it if possible?
I am trying ImageMagick library, but the out put is not 100% correct, I tried to manipulate the values without luck:
string GetSignature(string signature) {
string withoutBackground = "signature_no_bg.png";
using (var image = new MagickImage(signature))
{
image.Transparent(MagickColors.White);
// -alpha set
image.Alpha(AlphaOption.Set);
// -channel RGBA (don't think you need this)
// -fuzz 50%
image.ColorFuzz = new Percentage(40);
// -fill none
image.Settings.FillColor = MagickColors.None;
// -floodfill +0+0 white
image.FloodFill(MagickColors.White, 0, 0);
image.Write(Server.MapPath(withoutBackground));
}
return withoutBackground;
}
Using the above code, the following image:
was converted to:
Another option was to https://www.remove.bg/tools-api , it worked perfectly but its a bit expensive.
Any suggestions to enhance my ImageMagick code or to use another kind of libraries?
I'm not experienced with ImageMagick, but I would try the following steps as a simple(st) alternative to filling:
You will have to try how well it performs on your own images though. You can also try to include some blurring on the greyscale image before thresholding against noise.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.