1. Field of Invention
The present invention relates to a method of processing a digital image, and particularly to a method extracting a textual area in a digital image.
2. Related Art
A content enriched digital image typically comprises figure areas, textual areas, continuous pictorial areas and the like. In processing such a digital image, different areas are generally processed in individual manners corresponding thereto. To enable all the areas in the digital image to be recognized, the figure areas and the textual areas are often endowed with clear edges, particularly for the textual areas, so that they can be discriminated for some specific uses. However, portions other than the edges of the figure and textual areas are not critically demanded since they may be presented in a not very clear result. On the other hand, images in the pictorial areas are quite demanding since they should be presented very clearly. In an application of printing the digital image using a carbon powder mode, the digital image is wholly weakened and thus the figure, textual and pictorial areas are all concurrently weakened. At this time, the presented effect of the pictorial areas is inclined to be insufficient and the edges of the figure and textual areas may lack sharpened or higher contrasts.
While being printed by use of a digital photostat, an original document is first scanned and then processed by a scanning unit in the digital photostat. After it has been processed, the original document is conversed into a grey-leveled or RGB-formatted image. Next, the image is further processed by, for example, the drivein a single bit or multi-bit manner. If the digital photostat is a color photostat, a screening step has to be executed to converse the 8-bit grey-leveled or colorful digital image to a 1-bit or multi-bit digital image. Before this screening step is performed, a color matching step is required to be conducted. Some photostats perform the above screening function through a periodic matrix while the other photostats eliminate a moir effect by using an error diffusion. Although halftones presented through executing the screening function may benefit to processing an original image having continuous tones therein, the edges of the textual areas and the figure areas becomes smoother, i.e., the edges are smoothened, thus not clear enough.
Therefore, there is a need created to provide a method of automatically discriminating a range of a textual area in a digtial image so that the textual or figure area may be processed separately and endowed with clear and sharp edges while a pictorial area, having continuous tones and halftones in the digital image, may be filtered and smoothened and a smoother pictorial area may be obtained.
In view of the shortcomings encountered in the prior arts, it is an object of the present invention to provide a method of extracting a textual area in a digital image so that the extracted textual area may be separately processed.
To achieve the above object, the method of extracting a textual area in a digital image according to the present invention comprises the steps of: scanning the digital image and obtaining a lightness thereof, smoothing and filtering the digital image, dividing the digital image into a plurality of blocks, computing a number of edges, each having a higher contrast in the corresponding block in a horizontal direction and a vertical direction, and determining a plurality of textual blocks out of the plurality of blocks in the digital image.
With the method of extracting a textual area in a digital image, differences between associated pixels are relied on, which provides extraction of simple textual areas. Also, the method may reduce the cost of extracting textual areas while promoting correctness of marking the texutal areas concurrently.
The detailed description and principle of the present invention will be given in the following with reference to the attached drawings.
The invention will become more fully understood from the detailed description given hereinbelow illustration only, and thus doesn't limit the present invention, wherein:
The present invetion provides a method of extracting a textual area in a digital image and a flowchart of the method illustrated in
Referring to
Next, an embodiment of the method of extracting a textual area in a digital image will be described and a flowchart thereof is illustrated in
First, scanning the digital image and obtaining a lightness thereof (step 2010). If the digital image scanned is a single-colored image, the step of obtaining the lightness of the digital image may be omitted. Otherwise, the lightness of the colorful digital image is required to be obtained and by virtue of the lightness the colorful digital image is conversed into a grey-leveled image. If the image is in a traditional RGB format, the lightness of the image is
Lightness=R*0.30+G*0.59+B*0.11.
In case other formats are being used, the image may be conversed into having an RGB format and then the lightness thereof may be obtained through the above formulation with respect to the lightness. Algorithms for transforming an image from the RGB color space to other color spaces, such as YcbCr and Lab color spaces, are numerous and may be computed through an associated fomuation or through looking up an associated 3-D table.
Then, the digial image is subject to a pre-process. That is, each pixel in the digital image is smoothened and filtered in the pre-process (step 2020) so that adjustment errors resulting from processing over the tones in the digital image are elminated. It is to be noted that this smoothing process may not have an effect on the original digital image. In this embodiment, the so-called Gauss filter is used as a smoothing filter as desired, to perform the smoothing function.
Next, the digital image is divided into a plurality of blocks (step 2030). Each of the divided blocks comprises N×N pixels, wherein N may be 10, 16, 32 or 64. In this embodiment, N=10 is chosen. Referring to
For each block, a number of edges, each having a higher contrast in a horizontal direction and a vertical direction, is computed. Succeeding to the edge computation, a first benchmark value is used in determing if the current block is a textual block. The mentioned edge is defined as a pixel unit, which is either a positive peak pixel(grey level bigger than adjacent pixel in left side and right side when in horizontal direction or grey level bigger than adjacent pixel in up side and down side when in vertical direction), or a negative peak pixel(grey level smaller than adjacent pixel in left side and right side when in horizontal direction or grey level smaller than adjacent pixel in up side and down side when in vertical direction), if it is a positive peak pixel, its grey level difference with the adjacent negative peak pixel in left side(horizontal direction) or up side(vertical direction) must be significient, if it is a negative peak pixel, its grey level difference with the adjacent positive peak pixel in left side(horizontal direction) or up side(vertical direction) must also be significient. If the current block has a greater number of edges, the current block is determined as a textual block.
In determining or computing the number of edges for the example above, pixel values in the current block are differentiated (step 2040) and the differentiated result is shown in
Then, pixels having an alternated sign in the differentied result are determined, as shown in
When the sign of a current number in the block with differented values presented turns to a negative number from a positive number, the current number is marked as a positive peak when the sum of the continuous positive numbers prior to the current number is greater than or equal to 70 (step 2080). On the other hand, when the sign of a current number in the differentiated information turns to a positive number from a negative number, the current number is marked as a negative peak when the sum of the continuous negative numbers prior to the current number is smaller than or equal to −70 (step 2090). Namely, the sums of the continuous positive numbers and negative numbers are compared in their absolute values with 70 respectively. Then, making a marking operation according to the comparison results and the block with the marks made are shown in
The real computation and comparison of the numbers in the block with differented values presented is shown in
Then, the sum of the numbers of the positive peaks and the negative peaks are computed (step 2100). In the vertial direction of the 10×10-pixels block, the number sequences are differentiated in a similar manner as that conducted over the horizontal number sequence in the block. The number of positive and negative peaks in the horizontal and vertical directions are computed as a total sum (step 2110). According to the total sum, if the number of the positive and negative peaks in the horizontal and vertical directions is greater, then a second benchmark value is determined (step 2120). In this embodiment, the second benchmark value is chosen as 40. If the total sum are greater or equal to 40, the current block is determined and remarked as a textual block (step 2130).
The approach decribed above is made for the plurality of blocks in the digital image, all the textual blocks in the digital image may be located and marked and the textual areas may also be known. With the textual areas in the digital image located, the textual blocks may be made with particular processes, such as smoothing, filling, sawtooth elimination and the like, with which the texts corresponding to the textual areas may be presented more clearly and the digital image may be enhanced with its presented effect. In enhancing the presented effect of the textual areas, an exemplary implementation may be used as is shown in
While embodiments and applications of this invention have been shown and described, it would be apparent to those skilled in the art having the benefit of this disclosure that more modifications than mentioned above are possible without departing from the inventive concepts herein. The invention, therefore, is not to be restricted except in the spirit of the appended claims and their equivalents.