Is there any way of removing a white background and turning it into black in MATLAB?

Say i have this image:

![enter image description here](https://i.stack.imgur.com/5p4jV.jpg)

I get the following output when i apply the code suggested in the answer: Which isn't perfect

![enter image description here](https://i.stack.imgur.com/zWCXK.jpg)