1. A method implemented in a data processing apparatus for recognizing an input document image as a table, pure text, or flowchart, the document image being a binary image where each pixel is a background pixel having a background pixel value or a content pixel having a content pixel value, the method comprising: (a) calculating a side profile of the image for each of a top, bottom, left and right sides, each side profile being, for each pixel position along that side of the document image, a distance from that side to a first content pixel along a direction perpendicular to that side; (b) calculating a boundary removal size N corresponding to each side based on line widths at a plurality of pixel positions along that side using content pixels closest to that side; (c) for each side, removing a boundary of the size N from the document image by setting N consecutive pixels, starting from the first content pixel and going in the direction perpendicular to that side, to the background pixel value, to generate a boundary-removed image for that side; (d) re-calculating a side profile for each of the top, bottom, left and right sides using the boundary-removed image for that side; (e) based on a comparison of the side profiles and the re-calculated side profiles of some or all of the sides, recognizing the input document image as a table, pure text, a flowchart, or none of them.