Tiny helper module than can threshold an image and obtain its mask, and has a few helper functions like making the background transparent, and removing noise using connected components.
Install directly.
sudo pip3 install git+https://github.com/HelioStrike/threshold-image-maker.git
or
Clone and install.
git clone https://github.com/HelioStrike/threshold-image-maker
cd threshold-image-maker
sudo pip3 install .