Not a python answer, but you still might find this interesting. If you don't it is all free, so please forgive me.
I have a solution for C# that is pretty useful for things Paint.Net is bad at, like using the paint bucket tool when it can't figure out where the borders are.
My site https://pixeldatabase.net uses a language I invented called Bitmap Query Language, or BQL for short. If you know SQL for SQL Server, you are 80% of the way to BQL.
The Nuget package that powers this is located here:
Nuget: DataJuggler.PixelDatabase
https://github.com/DataJuggler/PixelDatabase
The BQL that does the same as clicking the Paint Bucket tool in Paint.Net, but better because it fills in the little gaps:
Update
Set Color Black
Where
Total < 450
Result:

The way BQL works is first all the criteria is applied, and in this case all the pixels that have a total < or equal to 450 *, where total equals the sum of Red + Green + Blue.
- For simplicity less than (<) is the same as less than or equal to.

The background areas all have a total of in the 500's and up, so the query only affects the dark areas.
If you want to not include the extra little black area on the right, just add this:
X < 168
This does the same thing as the first query, but it only affects the pixels that are 168 or less.

And the last thing I will show you, is if you want to remove the background after the previous query:
Hide
Total > 20
And this will get rid of any pixels that have a total value of 20 or higher:

It looks white here because this page is white.
I have used Paint.Net for 15 years, and to me BQL is what images need.
Sorry to post here if it offends anyone, I just think I created something super neat, but maybe like all my other ideas, I am the only one that likes it.