Flutter threshold grayscale image not for display

Solution for Flutter threshold grayscale image not for display
is Given Below:

I am developing a text reader for accessibility with google_ml_kit. I can get the image and use the image library to grayscale and invert the image. What I need to do now is threshold the image but the solutions I find searching is all to do with color filtering and displaying in widgets. What I need to do is take the grayscaled and inverted image and threshold it before I pass it to the google_ml_kit text extraction. I do not find a threshold function in the image library so what is the best way to do this. I do not want to use opencv since it is not null safety yet and increases the size of the app.

Thank you for any help or suggestions.