Method and device for character area identification

A method and a device for area identification are provided in the disclosure. The method includes: binarizing a text area including a row of characters; calculating a histogram in a vertical direction of the binarized text area, wherein the histogram includes abscissas of pixels in each column and corresponding accumulated values of foreground color pixels of the pixels in each column; and identifying a character area of each of one or more characters in the text area according to distribution information of the accumulated values.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is based upon and claims priority to Chinese Patent Application No. 201510726153.9, filed on Oct. 30, 2015, which is incorporated herein by reference in its entirety.

FIELD

The present disclosure generally relates to the field of image processing and, more particularly, to a method and a device for character area identification.

BACKGROUND

In the field of image processing, before identifying text in an image, a terminal may need to identify a character area corresponding to each character in the text, so as to identify the character.

A conventional method for character area identification may include removing a background in an image to extract a foreground image, identifying, with an edge enhancement technology, an edge of each character in the extracted foreground image, and determining a character area of each character according to the identified edge.

In the above solution, the determined character area may be inaccurate, since the edge enhancement technology may only provide a rough location estimation.

SUMMARY

According to a first aspect of the present disclosure, there is provided a method for character area identification, comprising: binarizing a text area including a row of characters; calculating a histogram in a vertical direction of the binarized text area, wherein the histogram includes abscissas of pixels in each column and corresponding accumulated values of foreground color pixels of the pixels in each column; and identifying a character area of each of one or more characters in the text area according to distribution information of the accumulated values.

According to a second aspect of the present disclosure, there is provided a device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to: binarize a text area including a row of characters; calculate a histogram in a vertical direction of the binarized text area, wherein the histogram includes abscissas of pixels in each column and corresponding accumulated values of foreground color pixels of the pixels in each column; and identify a character area of each of one or more characters in the text area according to distribution information of the accumulated values.

According to a third aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing instructions that, when executed by a processor, cause the processor to perform a method for character area identification, the method comprising: binarizing a text area including a row of characters; calculating a histogram in a vertical direction of the binarized text area, wherein the histogram includes abscissas of pixels in each column and corresponding accumulated values of foreground color pixels of the pixels in each column; and identifying a character area of each of one or more characters in the text area according to distribution information of the accumulated values.

It is to be understood that both the forgoing general description and the following detailed description are exemplary only, and are not restrictive of the present disclosure.

DETAILED DESCRIPTION

In exemplary embodiments, a text area may include any characters, such as Chinese characters, English letters, English words, numerals, symbols, etc., in a same row. The characters may be characters in any language. The text area may be a part of an image of an identification (ID), a part of a scanned image of article, or a part of an electronic document; and the present disclosure is not limited thereto. Further, a top edge of the text area may be between a top edge of the characters in the same row and a bottom edge of a second row of characters above that row. A bottom edge of the text area may be between a bottom edge of the characters in the same row and a top edge of a third row of characters below that row.

For example, as illustrated inFIG. 1, a text area may be an area11containing a citizen identity number in a same row on an identification card. A top edge of the text area is between I1and I2, and a bottom edge of the text area is between I3and I4.

In exemplary embodiments, the text area may include valid or invalid characters. A valid character may be a character that needs to be identified, and an invalid character may be a character that does not need to be identified. For example, as illustrated inFIG. 1, characters of the text area11may only include numbers “330421199012162834”, or may include the numbers and characters to the left of the numbers, for example, “Number330421199012162834.” In addition, a character area may refer to an area corresponding to a single character.

In exemplary embodiments, text and characters referred to in various embodiments of the disclosure may be numerals, letters, Chinese characters, pictures, or other contents of which a number of foreground color pixels is larger than a threshold in a calculated histogram as described below.

FIG. 2is a flow chart illustrating a method200for character area identification, according to an exemplary embodiment. As shown inFIG. 2, the method200may include following steps.

In step201, a text area may be binarized to obtain a binarized text area. The text area may include characters in a same row.

In step202, a histogram may be calculated in a vertical direction for the binarized text area. The histogram may include abscissas (e.g. x-axis values) of pixels in each column and corresponding accumulated values of foreground color pixels of the pixels in each column.

In step203, a character area of each of one or more characters in the text area may be identified, based on distribution information of the accumulated values in the histogram.

The method200for text area identification described above can improve an accuracy of text area identification, by calculating the histogram in the vertical direction for the binarized text area and identifying the character area of each of the characters in the text area according to the distribution information in the histogram. As a result, the character area of each of the characters may be accurately identified according to the distribution information of the accumulated values of the foreground color pixels in the histogram.

FIG. 3Ais a flow chart illustrating a method300afor character area identification, according to an exemplary embodiment. As shown inFIG. 3, the method300amay include following steps.

In step301, a text area may be binarized to obtain a binarized text area. The text area may include characters in a same row.

In some embodiments, a terminal may preprocess the text area by operations such as denoising, filtering, abstraction of an edge, and the like, and binarize the preprocessed text area.

Binarization may include comparing grey scale values of pixels in the text area with a predetermined grey scale value, dividing the pixels in the text area into two groups: a first group of pixels each with a grey scale value larger than the predetermined grey scale value and a second group of pixels each with a grey scale value smaller than the predetermined grey scale value, and rendering the two groups of pixels in the text area with two different colors, such as black and white, to obtain a binarized text area, as shown inFIG. 3B. Pixels in a foreground may be called foreground color pixels, e.g., white pixels inFIG. 3B, and pixels in a background may be called background color pixels, e.g., black pixels inFIG. 3B.

In step302, a histogram may be calculated in a vertical direction for the binarized text area. The histogram may include abscissas of pixels in each column and corresponding accumulated values of foreground color pixels of the pixels in each column.

The histogram may be calculated in the vertical direction after the binarization of the text area. The horizontal direction of the histogram may represent the abscissas of pixels in each column, and the vertical direction of the histogram may represent an accumulated value of a number of the foreground color pixels of the pixels in each column. The foreground color pixels may refer to pixels in a white area of the binarized text area, with respect to background color pixels. For example, the terminal may calculate the histogram.FIG. 3Cis a schematic diagram illustrating a histogram calculated as described, according to an exemplary embodiment.

In step303, a plurality of sets of abscissas may be determined according to distribution information of the accumulated values in the histogram.

In step303a, a third abscissa may be identified in the histogram according to distribution information of the accumulated values.

The third abscissa may be an abscissa in the histogram corresponding to a left edge of a character area of a first valid character of a row of characters, or an abscissa in the histogram corresponding to a right edge of a character area of a last valid character of a row of characters.

For example, as illustrated inFIG. 3E, an identified third abscissa may be the abscissa X1in the histogram corresponding to a left edge of the first valid character “3”, or the abscissa X2corresponding to a right edge of the last valid character “4”.

In step303b, the plurality of sets of abscissas are obtained by searching from the third abscissa in a predetermined direction and based on the distribution information of the accumulated values.

After identifying the third abscissa, the terminal may search, from the third abscissa, in the predetermined direction and based on the distribution information of the accumulated value to obtain the plurality of sets of abscissas. For example, when the third abscissa corresponds to a left edge of a character area of a first valid character, the predetermined direction is towards right, and when the third abscissa corresponds to a right edge of a character area of a last valid character, the predetermined direction is towards left.

A number of the sets of the abscissas may correspond to a number of valid characters in the text area, and each set of abscissas may include a first abscissa corresponding to a left edge of a character area of a valid character and a second abscissa corresponding to the right edge of the character area. That is, each set of abscissas may include a first abscissa and a second abscissa to the right of and adjacent to the first abscissa. Accumulated values respectively corresponding to the first abscissa and an adjacent abscissa to the right of the first abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the first abscissa may be smaller than a second threshold. In addition, accumulated values respectively corresponding to the second abscissa and an adjacent abscissa to the left of the second abscissa may be larger than the first threshold, and an accumulated value corresponding to an adjacent abscissa to the right of the second abscissa may be smaller than the second threshold.

For example, the terminal may identify each of the sets of abscissas as shown inFIG. 3Fwith the first abscissa being x1and the second abscissa being x2.FIG. 3Fis only an exemplary illustration showing several identified sets of abscissas, and in practice more sets of abscissas may be included; and the present disclosure is not limited thereto.

The above first threshold and second threshold may have relatively small numerical values. For example, the first threshold and second threshold may have numerical values slightly more than 0. In some embodiments, the first threshold may be 0 and the second threshold may have a numerical value approximate to 0. Further, in some embodiments, the accumulated values respectively corresponding to the first abscissa and the next abscissa to the right side of the first abscissa may not equal to 0, the accumulated value corresponding to the next abscissa to the left of the first abscissa may equal to 0, the accumulated values respectively corresponding to the second abscissa and the next abscissa to the left of the second abscissa may not equal to 0, and the accumulated value corresponding to the next abscissa to the right of the second abscissa may equal to 0.

In step304, for each of the determined sets of abscissas, a pixel column where the first abscissa is located may be identified as a left edge of a character area, and a pixel column where the second abscissa is located may be identified as a right edge of the character area.

The method300for text area identification described above can improve an accuracy of text area identification, by calculating the histogram in the vertical direction for the binarized text area and identifying the character area of each of the characters in the text area according to the distribution information in the histogram. As a result, the character area of each of the characters may be accurately identified according to the distribution information of the accumulated values of the foreground color pixels in the histogram.

In the embodiment shown inFIG. 3A, if the characters within the text area include both valid and invalid characters and a first distance between a valid character and an invalid character is larger than a second distance between two adjacent valid characters, step303amay include following steps.

From a predetermined abscissa in the histogram and towards left, the terminal may search for and obtain a first interval having a width larger than the second distance, and determine an abscissa, to the right of the interval and having an accumulated value of foreground color pixels larger than the first threshold, to be the third abscissa.

The predetermined abscissa may be an abscissa among a predetermined range, which is a mapping range in the histogram corresponding to the valid characters in the text area. For example, as illustrated inFIG. 3E, the predetermined range is the range [X1, X2]. In some embodiments, the predetermined range may be set according to an empirical value. Further, the accumulated values of foreground color pixels in the interval may be smaller than the second threshold.

Taking the citizen identity card number inFIG. 1as an example, the predetermined abscissa may correspond to a middle location in a horizontal direction of an identity card, since, by empirical knowledge of the card, the citizen identity number spans cross the middle location. For example,FIG. 3Gillustrates a width of the text area being an overall width of the identity card, and the predetermined abscissa may be X0. The terminal may conduct the search from X0and in the direction towards left. Since the first distance between two adjacent numerals is much smaller than the second distance between the word “number” and the first numeral “3” in the citizen identity card number, after determining an interval d larger than the second distance, the terminal may determine an abscissa X1to the right of the interval d and having an accumulated value of foreground color pixels larger than the first threshold as the third abscissa.

Similarly, the terminal may look up, starting with the predetermined abscissa and in a direction towards right, and after determining an interval larger than the second distance, determine an abscissa to the left of the interval and having an accumulated value of foreground color pixels larger than the first threshold as the third abscissa. In one embodiment with reference toFIG. 3A, if all characters in the text area are valid characters, step303amay include following steps.

After calculating the histogram for the binarized text area, the terminal may determine an abscissa A on the left side of the histogram and having an accumulated value of foreground color pixels larger than the first threshold as an abscissas corresponding to a first valid character. The terminal then may determine the abscissa A as the third abscissa.

For example, referring toFIG. 3H, the terminal may determine X1as the third abscissa.

Similarly, an abscissa B on the right side of the histogram and having an accumulated value of foreground color pixels larger than the first threshold may be determined as an abscissas corresponding to a last valid character. Therefore, the terminal then may determine the abscissa B as the third abscissa. Still referring toFIG. 3H, the terminal may determine X2as the third abscissa.

In the embodiment shown inFIG. 3A, after the terminal calculates the third abscissa as described above, if the calculated third abscissa corresponds to the left edge of the character area of a first valid character of a row of characters, step303bmay include steps401-404described inFIG. 4.

In step401, for an ithset of abscissas and from the first abscissa within the ithset of abscissas in the histogram, a fourth abscissa may be searched for and obtained towards right of the first abscissa.

In some embodiments, i, larger than or equal to 1, and smaller than or equal to n, may be a positive integer with an initial value of 1, and n may be a number of valid characters. For example with reference to the citizen identity card number, the number of valid characters is 18.

Additionally, the first abscissa in the first set of abscissas may be the third abscissa. Accumulated values respectively corresponding to the fourth abscissa and an adjacent abscissa to the left side of the fourth abscissa may be larger than the first threshold, and an accumulated value corresponding to an abscissa to the right of the fourth abscissa may be smaller than the second threshold.

Taking i=1 as an example, since the first abscissa x1in the first set of abscissas may be the third abscissa X1, the terminal may search from X1in the histogram and in a direction towards right, to determine and obtain a first fourth abscissa.

In step402, the fourth abscissa may be determined as the second abscissa of the ithset of abscissa.

In step403, if i is less than n, from the fourth abscissa in the histogram, a fifth abscissa may be searched for and obtained in a direction towards right.

If i is less than n, the terminal may determine that there may be at least one unidentified valid character to the right. At the point, the terminal may search, from an abscissa in the histogram corresponding to a right edge of the currently determined valid character and towards right, an abscissa corresponding to a left edge of a next valid character area.

In some embodiments, the terminal may search for and obtain, from the fourth abscissa and towards right, a first fifth abscissa. Accumulated values respectively corresponding to the fifth abscissa and an adjacent abscissa to the right of the fifth abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the fifth abscissa may be smaller than a second threshold.

In step404, set i=i+1, the fifth abscissa may be determined as the first abscissa of the ithset of abscissas.

The terminal may determine the fifth abscissa as the abscissa in the histogram corresponding to the left edge of the next valid character area. In some embodiments, the terminal may set i=i+1, and determine the fifth abscissa as the first abscissa within the ithset of abscissas.

The terminal may continue to search in the direction towards right, to determine a set of abscissas corresponding to valid character areas according to the above method.

In the embodiment shown inFIG. 3A, after the terminal calculates the third abscissa as described above, if the calculated third abscissa corresponds to a right edge of a character area, step303bmay include steps501-504as illustrated inFIG. 5.

In step501, for a jthset of abscissas, from a second abscissa of the jthset of abscissas in the histogram, a sixth abscissa may be searched for and obtained in a direction towards left.

Accumulated values respectively corresponding to the sixth abscissa and an adjacent abscissa to the right of the sixth abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the sixth abscissa may be smaller than a second threshold. j, larger than or equal to 1, and smaller than or equal to n, may be a positive integer whose initial value is n, and n may be a number of valid characters, and a second abscissa within the nthset of abscissas may be the third abscissa.

In step502, the sixth abscissa may be determined as the first abscissa of the jthset of abscissas.

In step503, if j>0, from the sixth abscissa in the histogram, a seventh abscissa may be searched for and obtained in the direction towards left. Accumulated values respectively corresponding to the seventh abscissa and an adjacent abscissa to the left of the seventh abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the seventh abscissa may be smaller than a second threshold.

In step504, set j to j−1, the seventh abscissa may be determined as a second abscissa within the jthset of abscissas.

Steps501-504may be similar to steps401-404. A different between them may be that the method provided in steps401-404includes a search from left to right, while the method provided in steps501-504includes a search from right to left.

Based on the above-provided embodiments, referring toFIG. 6, before binarizing the text area to obtain the binarized text area, the terminal may further perform following steps.

In step601, a target image area may be binarized to obtain a binarized target image area.

The target image area may include a plurality of rows of characters.

Step601may be similar to step301in the above embodiment.

In step602, a horizontal histogram may be calculated in a horizontal direction for the binarized target image area. The horizontal histogram may include ordinates of pixels in each row and an accumulated value of foreground color pixels of the pixels in each row.

Step602may be similar to step302in the above embodiment. A difference between them may be that in step302the histogram may be calculated in the vertical direction for the binarized text area, while in step602the histogram may be calculated in the horizontal direction for a binarized target image area.

In step603, a plurality of sets of ordinates may be determined according to distribution information of accumulated values in the horizontal histogram, and each set of ordinates may include a first ordinate and a second ordinate located below the first ordinate. For each set of ordinates, a pixel row where the first ordinate located may be determined as an upper edge of a corresponding row of characters, and a pixel row where the second ordinate located may be determined as a lower edge of the corresponding row of characters.

After calculating the horizontal histogram, the terminal may determine the sets of ordinates according to the distribution information of accumulated values in the histogram, and then identify an area for the each row according to each of the sets of ordinates.

The step may be similar to the embodiments described above, e.g., steps of determining the sets of abscissas according to the distribution information of accumulated values in the vertical histogram, and then determining the left edge and the right edge of each character according to each of the sets of abscissas. Details may be referred to the above embodiments.

Accumulated values respectively corresponding to the first ordinate and an adjacent ordinate below the first ordinate may be larger than a first threshold, and an accumulated value corresponding to an adjacent ordinate above the first ordinate may be smaller than a second threshold, and accumulated values respectively corresponding to the second ordinate and an adjacent ordinate above the second ordinate may be larger than the first threshold, and an accumulated value corresponding to an adjacent ordinate below the second ordinate may be smaller than the second threshold.

In step604, the step of binarizing the text area to obtain the binarized text area may be performed for a kthrow of characters, k is a positive integer larger than or equal to 1, and smaller than or equal to m, and m may be a total number of the identified rows.

After identifying all rows of characters in step603, the terminal may perform the step of binarizing the text area to obtain the binarized text area for each of the rows.

As such, the terminal may identify the character areas of valid characters in each row in the target image area.

In some embodiments, the terminal may determine the text area according to the horizontal histogram. In some other embodiments, the terminal may determine the text area by other methods. For example, the terminal may obtain the text area by an image positioning technology. Taking the citizen identity card as an example, since the citizen identity card number may be located at a relatively fixed position and relatively far from an address and a picture, the terminal may directly locate the bottom ⅕ area of the card image as the text area.

FIG. 7is a block diagram illustrating a device700for character area identification, according to an exemplary embodiment. As shown inFIG. 7, the device700may include a first binarization module710, a first calculation module720, and an area identification module730.

The first binarization module710may be configured to binarize a text area to obtain a binarized text area. The text area may include a plurality of characters in a same row.

The first calculation module720may be configured to calculate a histogram in a vertical direction for the binarized text area. The histogram may include abscissas of pixels in each column and an accumulated value of foreground color pixels of the pixels in the each column.

The area identification module730may be configured to identify a character area of each of one or more characters in the text area, based on distribution information of the accumulated value in the histogram.

The method for text area identification described above can improve an accuracy of text area identification, by calculating the histogram in the vertical direction for the binarized text area and identifying the character area of each of the characters in the text area according to the distribution information in the histogram. As a result, the character area of each of the characters may be accurately identified according to the distribution information of the accumulated value of the foreground color pixels in the histogram.

FIG. 8is a block diagram illustrating a device800for character area identification, according to an exemplary embodiment. As shown inFIG. 8, the device800may include a first binarization module810, a first calculation module820, and an area identification module830.

The first binarization module810may be configured to binarize a text area to obtain a binarized text area. The text area may include a plurality of characters in a same row.

In some embodiments, the first binarization module810may preprocess the text area by, for example, denoising, filtering, abstraction of an edge, and the like, and binarize the preprocessed text area.

Binarization may include comparing grey scale values of pixels in the text area with a predetermined grey scale value, dividing the pixels in the text area into two groups: a first group of pixels each with a grey scale value larger than the predetermined grey scale value and a second group of pixels each with a grey scale value smaller than the predetermined grey scale value, and rendering the two groups of pixels in the text area with two different colors, such as black and white, to obtain a binarized text area.

The first calculation module820may be configured to calculate a histogram in a vertical direction for the binarized text area. The histogram may include abscissas of pixels in each column and an accumulated value of foreground color pixels of the pixels in the each column.

After the first binarization module810binarizes the text area, the first calculation module820may calculate the histogram in the vertical direction. The horizontal direction of the histogram may represent the abscissas of the pixels in the each column, and the vertical direction of the histogram may represent an accumulated value of a number of the foreground color pixels of the pixels in the each column, The foreground color pixels may refer to pixels in a white area of the binarized text area, with respect to background color pixels.

The area identification module830may be configured to identify a character area of each of one or more characters in the text area, according to distribution information of accumulated values in the histogram.

In an embodiment, the area identification module830may include a coordinate determination sub-module831and an area identification sub-module832.

The coordinate determination sub-module831may be configured to determine a plurality of sets of abscissas, according to the distribution information of accumulated values in the histogram. Each set of abscissas may include a first abscissa and a second abscissa to the right of and closest to the first abscissa. Accumulated values respectively corresponding to the first abscissa and an adjacent abscissa to the right of the first abscissa may be larger than a first threshold, and a next accumulated value corresponding to an adjacent abscissa to the left of the first abscissa may be smaller than a second threshold. In addition, accumulated values respectively corresponding to the second abscissa and an adjacent abscissa to the left of the second abscissa may be larger than the first threshold, and a next accumulated value corresponding to an adjacent abscissa to the right of the second abscissa may be smaller than the second threshold.

The area identification sub-module832may be configured to, for each set of abscissas, determine a pixel column where the first abscissa is located as a left edge of a character area and a pixel column where the second abscissa is located as a right edge of the character area.

Additionally, the coordinate determination sub-module831may include a coordinate identification sub-module831aand a coordinate search sub-module831b.

The coordinate identification sub-module831amay be configured to identify a third abscissa in the histogram according to the distribution information of accumulated values. The third abscissa may be an abscissa in the histogram corresponding to a left edge of a character area of a first valid character among a row of characters, or an abscissa in the histogram corresponding to a right edge of a character area of a last valid character among the row of characters.

The coordinate search sub-module831bmay be configured to search for and obtain, from the third abscissa, in a predetermined direction and based on the distribution information of accumulated values, a plurality of sets of abscissas.

After the coordinate identification sub-module831aidentifies the third abscissa, the coordinate search sub-module831bmay search for and obtain, from the third abscissa, in the predetermined direction, and based on the distribution information of accumulated values, the sets of abscissas. If the third abscissa corresponds to the left edge of the character area of the first valid character, the predetermined direction is towards right, and if the third abscissa corresponds to the right edge of the character area of the last valid character, the predetermined direction is towards left.

A number of sets of the abscissas may correspond to the number of valid characters in the text area, e.g., each set of abscissas may include a first abscissa corresponding to a left edge of a character area of a valid character and a second abscissa corresponding to a right edge of the character area. That is, the each set of abscissas may include the first abscissa and the second abscissa located next right to the first abscissa. Accumulated values respectively corresponding to the first abscissa and an adjacent abscissa to the right of the first abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the first abscissa may be smaller than a second threshold. Accumulated values respectively corresponding to the second abscissa and an adjacent abscissa to the left of the second abscissa may be larger than the first threshold, and an accumulated value corresponding to an adjacent abscissa to the right of the second abscissa may be smaller than the second threshold.

The first threshold and second threshold may have relatively small numerical values. For example, the first threshold and second threshold may have numerical values slightly more than 0. In some embodiments, the first threshold may be 0 and the second threshold may have a numerical value approximate to 0. Further, the accumulated values respectively corresponding to the first abscissa and the next abscissa to the right of the first abscissa may not equal to 0, and the accumulated value corresponding to the next abscissa to the left side of the first abscissa may equal to 0. The accumulated values respectively corresponding to the second abscissa and the next abscissa to the left of the second abscissa may not equal to 0, and the accumulated value corresponding to the abscissa to the right of the second abscissa may equal to 0.

In some embodiments, the third abscissa may correspond to the left edge of the character area of the first character of the row of characters.

The coordinate search sub-module831bmay be further configured to search for and obtain, from the first abscissa within an ithset of abscissas in the histogram and towards right, a fourth abscissa. Accumulated values respectively corresponding to the fourth abscissa and an adjacent abscissa to the left of the fourth abscissa may be larger than a first threshold, and an accumulated value corresponding to an abscissa to the right of the fourth abscissa may be smaller than a second threshold. i, larger than or equal to 1, and smaller than or equal to n, may be a positive integer whose initial value is 1, and n may be a number of valid characters in the row of characters, and the first abscissa within the first set of abscissas may be the third abscissa.

The coordinate search sub-module831bmay be further configured to determine the fourth abscissa to be the second abscissa within the ithset of abscissas.

The coordinate search sub-module831bmay be further configured to search for and obtain, from the fourth abscissa in the histogram and towards right, a fifth abscissa, if i is less than n. Accumulated values respectively corresponding to the fifth abscissa and an adjacent abscissa to the right of the fifth abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the fifth abscissa may be smaller than a second threshold.

The coordinate search sub-module831bmay be further configured to set i=i+1 and determine the fifth abscissa to be the first abscissa of the ithset of abscissas.

The coordinate search sub-module831bmay determine the obtained abscissa to be the abscissa in the histogram corresponding to the left edge of the character area of the next valid character. In some embodiments, the coordinate search sub-module831bmay set i=i+1, and determine the fifth abscissa to be the first abscissa of the ithset of abscissas.

The coordinate search sub-module831bmay continue searching towards right to determine a set of abscissas corresponding to the character area of each of the valid characters according to the above method.

In some embodiments, the third abscissa may correspond to a right edge of the character area of the last valid character among the row of characters.

The coordinate search sub-module831bmay be further configured to perform the following operations: searching for and obtaining, from a second abscissa within a jthset of abscissas in the histogram and towards left, a sixth abscissa, and determining the sixth abscissa as the first abscissa within the jthset of abscissas. Accumulated values respectively corresponding to the sixth abscissa and an adjacent abscissa to the right of the sixth abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the sixth abscissa may be smaller than a second threshold. j, larger than or equal to 1, and smaller than or equal to n, may be a positive integer whose initial value is n, and n is a number of valid characters in a row of characters. The second abscissa within the nthset of abscissas may be the third abscissa.

The coordinate search sub-module831bmay be further configured to search for and obtain, from the sixth abscissa in the histogram and towards left, a seventh abscissa, if j is more than 0. Accumulated values respectively corresponding to the seventh abscissa and an adjacent abscissa to the left of the seventh abscissa may be larger than a first threshold, and an accumulated value corresponding to an adjacent abscissa to the left of the seventh abscissa may be smaller than a second threshold, and j, larger than or equal to 1, and smaller or equal to n, may be a positive integer whose initial value is n.

The coordinate search sub-module831bmay be further configured to set j to j−1 and determine the seventh abscissa as the second abscissa within the jthset of abscissas.

In some embodiments, the third abscissa may correspond to a left edge of the character area of the first valid character among a row of characters.

If the third abscissa corresponds to a right edge of the character area of the last valid character among the row of characters, the coordinate search sub-module831bmay perform similar steps as those described above with respect to the third abscissa corresponding to a left edge of the character area of the first valid character.

If the characters include both valid and invalid characters and a first distance between a valid and an invalid character is larger than a second distance between two adjacent valid characters, the coordinate identification sub-module831amay be configured to search for and obtain, from a predetermined abscissa in the histogram and towards left, a first interval of which a width is larger than the second distance, and determine an abscissa to the right of the interval and having an accumulated value of foreground color pixels larger than the first threshold to be the third abscissa. The predetermined abscissa may belong to a predetermined range set according to an empirical value, and an accumulated value of foreground color pixels in the interval may be smaller than a second threshold.

In some embodiments, if all characters in the text area are valid characters, the coordinate identification sub-module831amay be configured to determine a first one of abscissas on a left side of the histogram and having an accumulated value of foreground color pixels larger than the first threshold as the third abscissas.

In some embodiments, if the characters include both valid and invalid characters, and if the first distance between a valid character and an invalid character is larger than a second distance between two adjacent valid characters, the coordinate identification sub-module831amay be configured to search for and obtain, from a predetermined abscissa in the histogram and towards left, a first interval of which a width is larger than the second distance, and determine an abscissa to the right of the interval and having an accumulated value of foreground color pixels larger than the first threshold as the third abscissa.

The predetermined abscissa may be in a predetermined range, which is a mapping range in the histogram corresponding to the valid characters in the text area.

Similarly, the coordinate identification sub-module831amay search for and determine, from the predetermined abscissa and towards right, and after obtaining an interval larger than the second distance, an abscissa located on the left side of the interval and having an accumulated value of foreground color pixels larger than the first threshold as the third abscissa.

In some embodiments, if the characters are all valid characters, and after calculating the histogram for the binarized text area, the coordinate identification sub-module831amay determine a first one of abscissas on a left side of the histogram and having an accumulated value of foreground color pixels larger than the first threshold to correspond to the first valid character and to be the third abscissa.

In some embodiments, the third abscissa may correspond to a right edge of a character area of a last valid character among a row of characters.

If the characters include both valid and invalid characters and a first distance between a valid and an invalid character is larger than a second distance between two adjacent valid characters, the coordinate identification sub-module831amay be configured to search for and obtain, from a predetermined abscissa in the histogram and towards right, an interval of which a width is larger than the second distance, and determine an abscissa located on the left side of the interval and having an accumulated value of foreground color pixels larger than the first threshold to be the third abscissa. The predetermined abscissa may belong to a predetermined range set according to an empirical value, and an accumulated value of foreground color pixels in the interval may be smaller than a second threshold.

In some embodiments, if the characters are all valid characters, the coordinate identification sub-module831amay be configured to determine a first one of abscissas on the right side of the histogram, of which the accumulated value of foreground color pixels is larger than the first threshold, as the third abscissas.

If the third abscissa corresponds to a right edge of the character area of the last valid character among a row of characters, the coordinate identification sub-module831amay perform similar steps described above with reference to the third abscissa corresponding to the left edge of the character area of the first valid character.

In some embodiments, the device800may further include a second binarization module840, a second calculation module850, and an edge determination module860.

The second binarization module840may be configured to binarize a target image area to obtain a binarized target image area.

The target image area may be an area including a plurality of rows of characters.

The second binarization module840may be similar to the first binarization module810.

The second calculation module850may be configured to calculate a horizontal histogram in a horizontal direction for a binarized target image area. The horizontal histogram may include ordinates of pixels in each row and an accumulated value of foreground color pixels of the pixels in the each row.

The second calculation module850may be similar to the first calculation module820, and a difference between them may be that the first calculation module820may calculate the histogram in the vertical direction for the binarized text area, while the second calculation module850may calculate the histogram in the horizontal direction for a binarized target image area.

The edge determination module860may be configured to determine a plurality of sets of ordinates, according to distribution information of accumulated values in the histogram, and each set of ordinates may include a first ordinate and a second ordinate located below the first ordinate. For each set of ordinates, the row of pixels where the first ordinate locates may be determined as an upper edge of a row of characters, and the row of pixels where the second ordinate locates may be determined as a lower edge of a row of characters. Accumulated values respectively corresponding to the first ordinate and an adjacent next ordinate below the first ordinate may be larger than a first threshold, and an accumulated value corresponding to an adjacent ordinate above the first ordinate may be smaller than a second threshold, and accumulated values respectively corresponding to the second ordinate and an adjacent ordinate above the second ordinate may be larger than the first threshold, and an accumulated value corresponding to an adjacent ordinate below the second ordinate may be smaller than the second threshold.

After calculating the horizontal histogram in the horizontal direction, the edge determination module860may determine the sets of ordinates according to the distribution information of accumulated values in the histogram, and identify an area for each row according to each of the sets of ordinates.

The first binarization module810may be further configured to binarize a kthrow of characters to obtain a binarized text area, k is a positive integer larger than or equal to 1, and smaller than or equal to m, and m is a total number of the identified rows.

As such, the device800may identify a character area of each valid character in each row of the target image area.

The method for text area identification described above can improve an accuracy of text area identification, by calculating the histogram in the vertical direction for the binarized text area and identifying the character area of each of the characters in the text area according to the distribution information in the histogram. As a result, the character area of each of the characters may be accurately identified according to the distribution information of the accumulated values of the foreground color pixels in the histogram.

FIG. 9is a block diagram illustrating a device900for character area identification, according to an exemplary embodiment. For example, the device900may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a gaming console, a tablet, a medical device, exercise equipment, a personal digital assistant, and the like.

Referring toFIG. 9, the device900may include one or more of the following components: a processing component902, a memory904, a power component906, a multimedia component908, an audio component910, an input/output (I/O) interface912, a sensor component914, and a communication component916.

The processing component902may control overall operations of the device900, such as the operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component902may include one or more processors918to execute instructions to perform all or part of the steps in the above described methods. Moreover, the processing component902may include one or more modules which facilitate the interaction between the processing component902and other components. For instance, the processing component902may include a multimedia module to facilitate the interaction between the multimedia component908and the processing component902.

The power component906may provide power to various components of the device900. The power component906may include a power management system, one or more power sources, and any other components associated with the generation, management, and distribution of power for the device900.

The audio component910may be configured to output and/or input audio signals. For example, the audio component910includes a microphone (“MIC”) configured to receive an external audio signal, when the device900is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may be further stored in the memory904or transmitted via the communication component916. In some embodiments, the audio component910may further include a speaker to output audio signals.

The I/O interface912may provide an interface between the processing component902and peripheral interface modules, the peripheral interface modules being, for example, a keyboard, a click wheel, buttons, and the like. The buttons may include a home button, a volume button, a starting button, and a locking button.

The sensor component914may include one or more sensors to provide status assessments of various aspects of the device900. For instance, the sensor component914may detect an open/closed status of the device900, relative positioning of components (e.g., the display and the keypad, of the device900), a change in position of the device900or a component of the device900, a presence or absence of user contact with the device900, an orientation or an acceleration/deceleration of the device900, and a change in temperature of the device900. The sensor component914may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor component914may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component914may also include an accelerometer sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure. This application is intended to cover any variations, uses, or adaptations of the invention following the general principles thereof and including such departures from the present disclosure as come within known or customary practice in the art. The specification and embodiments are merely considered to be exemplary and the substantive scope and spirit of the disclosure is limited only by the appended claims.

It will be appreciated that the disclosure is not limited to the exact structure as described above and shown in the figures, but can have various modification and alternations without departing from the scope of the disclosure. The scope of the disclosure is limited only by the appended claims.