We assess the benefit of including an image inpainting filter before passing damaged images into a classification neural network. We employ an appropriately modified Cahn-Hilliard equation as an image inpainting filter which is solved numerically with a finite-volume scheme exhibiting reduced computational cost and the properties of energy stability and boundedness. The benchmark dataset employed is Modified National Institute of Standards and Technology (MNIST) dataset, which consists of binary images of handwritten digits and is a standard dataset to validate image-processing methodologies. We train a neural network based on dense layers with MNIST, and subsequently we contaminate the test set with damages of different types and intensities. We then compare the prediction accuracy of the neural network with and without applying the Cahn-Hilliard filter to the damaged images test. Our results quantify the significant improvement of damaged-image prediction by applying the Cahn-Hilliard filter, which for specific damages can increase up to 50% and is advantageous for low to moderate damage. © 2021 The Authors.