1. An image processing apparatus comprising: a first storage portion that stores a plurality of patterns used for matching with edge portions of a linear image included in an input image, the patterns having respective different sizes, and each of the patterns being composed of a plurality of pixels and including a target pixel corresponding to a pixel to be deleted in the linear image; a selection portion that selects a pattern having a size according to a line width of a line thinning process to the linear image, from the patterns stored into the first storage portion; a pattern detection portion that matches the selected pattern with the linear image while shifting the selected pattern, and detects whether the selected pattern is matched with the linear image; and a deletion portion that, when it is detected that the selected pattern is matched with the linear image, deletes the pixel in the linear image corresponding to the target pixel in the selected pattern.