Automating Brent's image preprocessing