This can be done in different ways. Two ways are discussed here. These methods work best for high contrast images with distinct contours, like black drawing on white paper or a solid shape against an even coloured background. (Tips for more complex backgrounds will be added later.)
First, consider how many images you need to process?
If it is less than 10 images or so and you just want to do this a few times. Go to the Gimp section.
If it is more than 10 images and/or you're likely to do this many times, using Compositing in Blender is highly recommended. A tiny bit more complicated but you can elaborate more and more depending on your specific needs and edit hundreds of images at one time. Go to the Blender section.