WO2022166865A1 - 一种文字图像的阴影消除方法、装置及电子设备 - Google Patents

一种文字图像的阴影消除方法、装置及电子设备 Download PDF

Info

Publication number
WO2022166865A1
WO2022166865A1 PCT/CN2022/074888 CN2022074888W WO2022166865A1 WO 2022166865 A1 WO2022166865 A1 WO 2022166865A1 CN 2022074888 W CN2022074888 W CN 2022074888W WO 2022166865 A1 WO2022166865 A1 WO 2022166865A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
grayscale
text
grayscale image
shadow
Prior art date
Application number
PCT/CN2022/074888
Other languages
English (en)
French (fr)
Inventor
邓元策
Original Assignee
瞬联软件科技(北京)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 瞬联软件科技(北京)有限公司 filed Critical 瞬联软件科技(北京)有限公司
Publication of WO2022166865A1 publication Critical patent/WO2022166865A1/zh
Priority to US18/446,446 priority Critical patent/US20230386002A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/77Retouching; Inpainting; Scratch removal
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/73Deblurring; Sharpening
    • G06T5/75Unsharp masking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/40Image enhancement or restoration using histogram techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • G06T5/94Dynamic range modification of images or parts thereof based on local image properties, e.g. for local contrast enhancement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30176Document

Definitions

  • the invention relates to a method for eliminating shadows of text images, a corresponding shadow eliminating device and electronic equipment, and belongs to the technical field of image processing.
  • the text image captured may be different in brightness and darkness, or even have large shadows, due to the blocking of the shooting device itself or other objects.
  • the captured text images will have different image brightness and darkness, and there will be shadows occluded.
  • FIG. 1 A typical situation is shown in Figure 1.
  • the picture is at night, when there is a single light source in the room, the text image obtained by shooting the text print with a photographing device, the effect of directly printing the text image may be as shown in Figure 2, the part covered by shadows content is completely lost.
  • This kind of text image seriously affects the reading effect of browsing and printing, and even some information is lost because it cannot be recognized.
  • the primary technical problem to be solved by the present invention is to provide a method for eliminating shadows of text images.
  • a method for removing shadows from text images comprising the following steps:
  • the background-enhanced shadow area in the second grayscale image and the non-shadow area in the first grayscale image are fused to obtain a text image after shadow removal.
  • the following steps are included:
  • the text image to be processed is obtained by screening at least one text image.
  • the text image to be processed is obtained by screening at least one text image, including the following sub-steps:
  • a text image whose shadow area area is larger than a preset area threshold is selected from at least one text image as the text image to be processed.
  • the text image to be processed is obtained by screening at least one text image, including the following sub-steps:
  • the text image whose area ratio is greater than the preset ratio threshold is selected from at least one text image as the text image to be processed.
  • histogram statistics and convex height sorting processing are performed on the first grayscale image to determine the background grayscale segmentation threshold of the first grayscale image and the text grayscale segmentation in the shadow area of the first grayscale image.
  • Threshold including the following sub-steps:
  • n is a preset positive integer.
  • performing histogram statistics on the first grayscale image includes the following sub-steps:
  • the first-order difference and symbol judgment method are used to obtain the first-order difference symbol sequence in for The i-th element of , 1D represents the first-order difference;
  • the calculation of the convex interval includes the calculation of the left convex interval and the right convex interval; wherein, the left convex interval is from the extreme value position to the position of the previous higher extreme value or the starting position of the signal ;
  • the right convex interval is the position of the extreme value to the position of the next higher extreme value or the end position of the signal;
  • the starting position ⁇ L of the left convex interval and the ending position ⁇ R of the right convex interval are It is calculated as follows:
  • the operator is to find the minimum value of the sequence ⁇ in the interval [a, b];
  • the n grayscale intervals with the largest convex height are extracted, and the background grayscale segmentation threshold of the first grayscale image and the text grayscale segmentation threshold in the shadow area of the first grayscale image are determined, including the following subsections: step:
  • is the preset offset of the segmentation threshold.
  • performing background enhancement on the first grayscale image to obtain the second grayscale image includes the following sub-steps:
  • a second grayscale image that determines background enhancement and preserves text within shadow areas in
  • the shadow elimination method further includes the following sub-steps:
  • the background grayscale segmentation threshold and the text grayscale segmentation threshold are processed to obtain a shadow area mask representation and a non-shadow area mask representation respectively, including the following sub-steps:
  • the third grayscale image is subjected to smooth filtering processing in the spatial domain, and then binarized to obtain a mask representation of the non-shaded area;
  • the background-enhanced shadow area in the second grayscale image and the non-shadow area in the first grayscale image are fused to obtain shadow removal.
  • the background-enhanced shadow area in the second grayscale image and the non-shadow area in the first grayscale image are fused to obtain a text image after shadow removal.
  • a device for eliminating shadows of text images comprising:
  • a grayscale image conversion unit which is used to convert the text image to be processed into a first grayscale image
  • the grayscale segmentation threshold determination unit is used to perform histogram statistics and convex height sorting processing on the first grayscale image, and determine the background grayscale segmentation threshold of the first grayscale image and the threshold value in the shadow area of the first grayscale image. Text grayscale segmentation threshold;
  • a mask representation determination unit used for processing the background grayscale segmentation threshold and the text grayscale segmentation threshold, to obtain a shadow area mask representation and a non-shadow area mask representation respectively;
  • a background enhancement unit configured to perform background enhancement on the first grayscale image to obtain a second grayscale image
  • an area fusion unit configured to perform fusion processing on the background-enhanced shadow area in the second grayscale image and the non-shadow area in the first grayscale image according to the shadow area mask representation and the non-shadow area mask representation to obtain shadows The image of the text after elimination.
  • an electronic device comprising a processor and a memory, the processor is coupled with the memory, and is used for executing programs or instructions in the memory, so that the electronic device can realize the The method described in the first aspect above.
  • a computer-readable storage medium is provided, and instructions are stored on the readable storage medium, and when the readable storage medium is run on a computer, the computer can be implemented as described in the first aspect above. Methods.
  • a computer program product comprising instructions, which, when executed on a computer, cause the computer to implement the method described in the first aspect above.
  • the present invention can convert the text image to be processed into a first grayscale image; perform histogram statistics and convex height sorting processing on the first grayscale image to determine the background grayscale of the first grayscale image.
  • the segmentation threshold and the text grayscale segmentation threshold in the shadow area of the first grayscale image; the background grayscale segmentation threshold and the text grayscale segmentation threshold are processed to obtain a shadow area mask representation and a non-shadow area mask representation respectively Carry out background enhancement to the first grayscale image to obtain a second grayscale image; according to the shadow area mask representation and the non-shadow area mask representation, the shadow area and the first grayscale image of the background enhancement in the second grayscale image
  • the non-shaded areas in the image are fused to obtain the text image after the shadow is removed.
  • FIG. 1 is a schematic diagram of an image obtained by photographing a file with a photographing device in the prior art
  • FIG. 2 is a schematic diagram of the effect of printing an image obtained by photographing a file by a photographing device in the prior art
  • Fig. 3 is a flow chart 1 of a method for eliminating shadows of text images according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of an application environment according to an embodiment of the present invention.
  • FIG. 5 is a second flowchart of a method for removing shadows from text images according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of an example of calculating the convex height of a statistical curve of a histogram in an embodiment of the present invention
  • FIG. 7 is a schematic diagram of the result of performing shadow area elimination using an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a device for removing shadows from text images according to an embodiment of the present invention.
  • FIG. 9 is an exemplary diagram of an electronic device for implementing an embodiment of the present invention.
  • the text image in the present invention is not limited to the literal expression in the narrow sense, including but not limited to images with various information such as text, symbols, numbers, etc.
  • the images are all suitable for the shadow removal method of the present invention.
  • the embodiment of the present invention first provides a method for eliminating shadows of text images, which at least includes the following steps:
  • Step S101 Convert the text image to be processed into a first grayscale image.
  • Step S102 Perform histogram statistics and convex height sorting processing on the first grayscale image to determine a background grayscale segmentation threshold of the first grayscale image and a text grayscale segmentation threshold in the shadow area of the first grayscale image.
  • Step S103 Process the background grayscale segmentation threshold and the text grayscale segmentation threshold to obtain a mask representation of a shaded area and a mask representation of a non-shaded area, respectively.
  • Step S104 Perform background enhancement on the first grayscale image to obtain a second grayscale image.
  • Step S105 Perform fusion processing on the background-enhanced shadow area in the second grayscale image and the non-shadow area in the first grayscale image according to the shadow area mask representation and the non-shadow area mask representation to obtain a shadow-eliminated area. Text image.
  • FIG. 4 a user holds a mobile phone 201 and wants to shoot a file 202 , but it faces away from the light source 203 , so the user’s mobile phone 201 blocks the light source 203 , and a shadow 204 left by the mobile phone 201 appears on the file 202 .
  • the embodiment shown in FIG. 5 will provide a method for removing shadows from text images, which is used for the scene shown in FIG. 4 .
  • an embodiment of the present invention further provides a method for removing shadows from text images, including:
  • Step S301 Obtain at least one text image, and determine the shadow area information of each text image.
  • the electronic device that executes the shadow removal method for text images may be an image acquisition device, such as a mobile phone, a camera, etc., or a back-end processing device, such as a computer for image processing, a server, etc., But not limited to this.
  • the determination of the shadow area information of each text image can be realized by the grayscale information of the text image.
  • the grayscale distribution of the entire image is mainly concentrated in two parts, and The difference between the two gray values is large, the area with larger gray value is the background area, and the area with smaller gray value is the text area.
  • the grayscale distribution is obviously concentrated in multiple parts, it can be determined that there is a shadow area in the text image.
  • Step S302 According to the shaded area information of each text image, the text image to be processed is obtained by screening at least one text image.
  • this step S302 can be implemented in any of the following manners, for example:
  • a text image whose shadow area area is greater than a preset area threshold is selected from at least one text image as the text image to be processed. That is, when the shadow area of some text images is small (for example, smaller than the area threshold), the small shadow area may not affect the browsing and printing of text information, and no processing is required. However, when the shadow area of some text images is large (for example, larger than the area threshold), the large shadow area may affect the browsing and printing of text information, so it is regarded as the text image to be processed. In this way, the problem of wasting computing resources caused by processing all the text and images can be avoided.
  • the text image whose area ratio is greater than a preset ratio threshold is selected from at least one text image as the text image to be processed. That is, when the shadow area of some text images is small (for example, the area ratio of the shadow area to the entire image is less than the ratio threshold), the small shadow area may not affect the browsing and printing of text information, and no processing is required. However, when the shadow area of some text images is large (for example, the proportion of the shadow area to the entire image is greater than the ratio threshold), the large shadow area may affect the browsing and printing of text information, and it will be treated as pending processing. text image. In this way, the problem of wasting computing resources caused by processing all the text and images can be avoided.
  • Step S303 Convert the text image to be processed into a first grayscale image.
  • this step S303 can be implemented in the following manner, for example:
  • the text image to be processed is D o .
  • the dimension of the data matrix D o corresponding to the text image to be processed is set to be m ⁇ n ⁇ 3, where m and n are the pixels corresponding to the height and width of the image respectively. number of points.
  • the text image D o to be processed is represented by the data of three color channels of r/g/b, and its dimensions are all m ⁇ n. Convert the color image to the first grayscale image as follows:
  • R, G, B are the red, green and blue components in the original color image Do, and the relationship between the value of each element of the matrix and the original color image is as follows
  • r (i,j) , g (i,j) and b (i,j) represent the elements of the i-th row and the j-th column in the R/G/B matrix, respectively.
  • Step S304 Perform histogram statistics on the first grayscale image.
  • this step S304 can be implemented in the following manner:
  • the first-order difference and symbol judgment method are used to obtain the first-order difference symbol sequence in for the ith element of ;
  • Step S305 Calculate the convex height of each grayscale interval after the histogram statistics, and sort the convex heights.
  • this step S305 can be implemented in the following manner:
  • the calculation of the convex interval includes the calculation of the left convex interval and the right convex interval; wherein, the left convex interval is from the extreme value position to the position of the previous higher extreme value or the starting position of the signal ;
  • the right convex interval is the position of the extreme value to the position of the next higher extreme value or the end position of the signal;
  • the operator is to find the minimum value of the sequence ⁇ in the interval [a, b];
  • Step S306 Extract the n grayscale intervals with the largest convex height, and determine the background grayscale segmentation threshold of the first grayscale image and the text grayscale segmentation threshold in the shadow area of the first grayscale image.
  • n is a preset positive integer. It is recommended that n be 4. Of course, it can also be 3 or 5.
  • this step S306 can be implemented in the following manner:
  • is a preset offset of the segmentation threshold, which is an adjustable parameter, and can take a value of 50, for example.
  • Step S307 Process the background grayscale segmentation threshold and the text grayscale segmentation threshold to obtain a mask representation of a shaded area and a mask representation of a non-shaded area, respectively.
  • this step S307 can be implemented in the following manner:
  • the third grayscale image Perform the smoothing filtering in the spatial domain, and then perform the binarization processing to obtain the mask representation of the non-shaded area in,
  • is a two-dimensional convolution operator
  • P is a preset filter coefficient of spatial filtering, dimension ⁇ , in the embodiment of the present invention, it is mainly used to smooth the edge and eliminate the “island” grayscale peak in the area, so it can generally be Use a normalized unidimensional matrix, that is, the unidirectional matrix needs to be multiplied by 1/( ⁇ ).
  • the dimension of the filter coefficient matrix is an adjustable parameter.
  • Step S308 Perform background enhancement on the first grayscale image to obtain a second grayscale image.
  • this step S308 can be implemented in the following manner:
  • a second grayscale image that determines background enhancement and preserves text within shadow areas in
  • Step S309 Perform shadow boundary enhancement on the first grayscale image to obtain a third grayscale image
  • Step S310 Perform fusion processing on the background-enhanced shadow area in the second grayscale image and the non-shadow area in the first grayscale image according to the shadow area mask representation and the non-shadow area mask representation to obtain the shadow-eliminated area. Text image.
  • this step S310 may be implemented in the following manner:
  • Fusion processing is performed on the background-enhanced shadow area in the second grayscale image and the non-shadow area in the first grayscale image to obtain a text image after shadow removal in,
  • an embodiment of the present invention also provides a device for removing shadows from text images, including:
  • the grayscale image conversion unit 41 is configured to convert the text image to be processed into a first grayscale image.
  • the grayscale segmentation threshold determination unit 42 is configured to perform histogram statistics and convex height sorting processing on the first grayscale image, and determine the background grayscale segmentation threshold of the first grayscale image and the shadow area of the first grayscale image.
  • the text grayscale segmentation threshold is configured to perform histogram statistics and convex height sorting processing on the first grayscale image, and determine the background grayscale segmentation threshold of the first grayscale image and the shadow area of the first grayscale image.
  • the mask representation determination unit 43 is configured to process the background grayscale segmentation threshold and the text grayscale segmentation threshold to obtain a mask representation of a shaded area and a mask representation of a non-shaded area, respectively.
  • the background enhancement unit 44 is configured to perform background enhancement on the first grayscale image to obtain a second grayscale image.
  • the region fusion unit 45 is configured to perform fusion processing on the background-enhanced shadow region in the second grayscale image and the non-shadow region in the first grayscale image according to the shadow region mask representation and the non-shadow region mask representation to obtain Text image after shadow removal.
  • an embodiment of the present invention further provides an electronic device, including a processor and a memory, the processor is coupled to the memory, and is used for executing a program or an instruction in the memory, so that the electronic device can realize the above-mentioned FIG. 3 or the method described in Figure 5.
  • the electronic device includes at least a processor and a memory, and may further include a communication component, a sensor component, a power supply component, a multimedia component and an input/output interface according to actual needs.
  • the memory, the communication component, the sensor component, the power supply component, the multimedia component and the input/output interface are all connected with the processor.
  • the memory can be static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, etc.
  • the processor can be a central processing unit (CPU), a graphics processing unit (GPU), a field programmable logic gate array (FPGA), an application specific integrated circuit (ASIC), a digital signal processing ( DSP) chips, etc.
  • CPU central processing unit
  • GPU graphics processing unit
  • FPGA field programmable logic gate array
  • ASIC application specific integrated circuit
  • DSP digital signal processing
  • an embodiment of the present invention further provides a computer-readable storage medium, where instructions are stored on the readable storage medium, and when the readable storage medium runs on a computer, the computer is made to execute the above-mentioned FIG. 3 or FIG. 5 . method.
  • an embodiment of the present invention also provides a computer program product containing instructions, which, when executed on a computer, causes the computer to execute the method described in FIG. 3 or FIG. 5 above.
  • the method, device and electronic device for eliminating shadows of text images can convert the text image to be processed into a first grayscale image; perform histogram statistics and convex height sorting processing on the first grayscale image, Determine the background grayscale segmentation threshold of the first grayscale image and the text grayscale segmentation threshold in the shadow area of the first grayscale image; process the background grayscale segmentation threshold and the text grayscale segmentation threshold to obtain shadow areas respectively.
  • Mask representation and non-shaded area mask representation perform background enhancement on the first grayscale image to obtain a second grayscale image;
  • the background-enhanced shadow area and the non-shadow area in the first grayscale image are fused to obtain a text image after shadow removal.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Image Processing (AREA)

Abstract

本发明公开了一种文字图像的阴影消除方法、装置及电子设备。该方法包括如下步骤:将待处理的文字图像转化为第一灰度图像;对第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;对背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示;对第一灰度图像进行背景增强,得到第二灰度图像;根据阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。

Description

一种文字图像的阴影消除方法、装置及电子设备 技术领域
本发明涉及一种文字图像的阴影消除方法,同时涉及相应的阴影消除装置及电子设备,属于图像处理技术领域。
背景技术
随着信息技术和数码相机、手机等拍摄设备的普及,在工作或者生活中,人们经常使用拍摄设备,例如具备拍摄功能的手机、平板电脑或数码相机等拍摄文字图像(如书本、报纸、文本打印件等),然后直接存储,或者打印出来、发邮件、通过即时通信软件等分享给他人,让信息共享变得更加便利。
目前,在使用拍摄设备进行拍摄的过程中,在某些场景下可能因为拍摄设备自身或者其他物体遮挡的缘故,导致拍摄出来的文字图像明暗不一,甚至有大片的阴影。特别是夜间,在室内存在单一光源照明、拍摄设备没有打开闪光灯的情况下,所拍摄的文字图像会出现图像明暗不一、存在阴影遮挡的情况。
典型情况如图1所示。图示为夜间,在室内存在单一光源照明的情况下,用拍摄设备拍摄文本打印件所得到的文字图像,将该文字图像直接打印出的效果可能会如图2所示,被阴影遮挡的部分的内容完全丢失。这种文字图像严重影响浏览和打印出来的阅读效果,甚至因为无法识别,导致部分信息丢失。
发明内容
本发明所要解决的首要技术问题在于提供一种文字图像的阴影消除方法。
本发明所要解决的另一技术问题在于提供一种文字图像的阴影消除装置及相应的电子设备。
为了实现上述目的,本发明采用下述技术方案:
根据本发明实施例的第一方面,提供一种文字图像的阴影消除方法,包括如下步骤:
将待处理的文字图像转化为第一灰度图像;
对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;
对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示;
对第一灰度图像进行背景增强,得到第二灰度图像;
根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
其中较优地,在将待处理的文字图像转化为第一灰度图像之前,包括如下步骤:
获得至少一幅文字图像,确定各幅文字图像的阴影区域信息;
根据各幅文字图像的阴影区域信息,从至少一幅文字图像中筛选得到待处理的文字图像。
其中较优地,所述根据各幅文字图像的阴影区域信息,从至少一幅文字图像中筛选得到待处理的文字图像,包括如下子步骤:
根据各幅文字图像的阴影区域面积,从至少一幅文字图像中筛选阴影区域面积大于预先设置的面积阈值的文字图像,作为待处理的文字图像。
其中较优地,所述根据各幅文字图像的阴影区域信息,从至少一幅文字图像中筛选得到待处理的文字图像,包括如下子步骤:
根据各幅文字图像的阴影区域占整幅图像的面积比例,从至少一幅文字图像中筛选面积比例大于预先设置的比例阈值的文字图像作为待处理的文字图像。
其中较优地,对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值,包括如下子步骤:
对所述第一灰度图像进行直方图统计;
计算直方图统计后每个灰度区间的凸高度,并对凸高度进行排序;
提取凸高度最大的n个灰度区间,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;其中,n 为预先设置的正整数。
其中较优地,对所述第一灰度图像进行直方图统计,包括如下子步骤:
将所述第一灰度图像中的所有元素通过直方图统计的方式进行分布估计,形成分布估计序列
Figure PCTCN2022074888-appb-000001
确定分布估计序列
Figure PCTCN2022074888-appb-000002
中各元素对应的分布概率密度λ k;其中,
Figure PCTCN2022074888-appb-000003
其中λ k为分布估计序列
Figure PCTCN2022074888-appb-000004
的第k个元素对应的分布概率密度;θ k为落入区间[(k-1)*ρ,k*ρ]的取值数;Θ为所述第一灰度图像的元素个数;ρ为统计间隔,ρ=255/Z,Z为预先设置的统计区间总数;
根据各元素对应的分布概率密度λ k,使用一阶差分和符号判断方法,得到一阶差分符号序列
Figure PCTCN2022074888-appb-000005
其中
Figure PCTCN2022074888-appb-000006
Figure PCTCN2022074888-appb-000007
的第i个元素,1D表示一阶差分;其中,
Figure PCTCN2022074888-appb-000008
根据
Figure PCTCN2022074888-appb-000009
中的元素
Figure PCTCN2022074888-appb-000010
计算二阶差分极值标记序列
Figure PCTCN2022074888-appb-000011
其中
Figure PCTCN2022074888-appb-000012
Figure PCTCN2022074888-appb-000013
第j个元素,2D表示二阶差分;其中,
Figure PCTCN2022074888-appb-000014
其中较优地,计算直方图统计后每个灰度区间的凸高度,并对凸高度进行排序,包括如下子步骤:
确定分布估计序列
Figure PCTCN2022074888-appb-000015
对应的凸高度序列H;其中,凸高度序列H的长度和分布估计序列
Figure PCTCN2022074888-appb-000016
的二阶差分极值标记序列
Figure PCTCN2022074888-appb-000017
相同,且在序列
Figure PCTCN2022074888-appb-000018
为零的位置上,凸高度序列H对应的值也为零;
对分布估计序列
Figure PCTCN2022074888-appb-000019
中二阶差分极值标记序列非零位置上的元素
Figure PCTCN2022074888-appb-000020
计算其对应的凸区间以及凸高度;其中,凸区间的计算包括左凸区间和右凸区间的计算;其中,左凸区间为极值位置到上一个更高极值所在位置或信号起始位置;右凸区间为极值位置到下一个更高极值所在位置或信号结束位置;
对于满足其对应位置上二阶差分极值标记序列的值非零的元素λ t,0≤t≤Z-2,其左凸区间的起始位置α L和右凸区间的结束位置α R的计算方式如下:
Figure PCTCN2022074888-appb-000021
确定元素λ t的左凸区间和右凸区间分别为[α L,t]和[t,α R];
计算左凸区间和右凸区间内的最小值的较大值作为凸高度的参考点λ ref
Figure PCTCN2022074888-appb-000022
其中,
Figure PCTCN2022074888-appb-000023
算符为求序列ψ在区间[a,b]中的最小值;
确定元素λ t对应的凸高度为:
Η t=λ tref
对凸高度序列H进行排序。
其中较优地,所述提取凸高度最大的n个灰度区间,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值,包括如下子步骤:
从凸高度序列H中从大到小取出n个元素,对应的索引依次为{τ 012,…,τ n-1},分别取出分布估计序列
Figure PCTCN2022074888-appb-000024
对应位置上的值,确定第一灰度图像的背景灰度分割阈值μ b和第一灰度图像的阴影区域内的文字灰度分割阈值μ st;其中,
Figure PCTCN2022074888-appb-000025
其中,Δ为分割阈值的预设偏移量。
其中较优地,所述对第一灰度图像进行背景增强,得到第二灰度图像,包括如下子步骤:
确定背景增强并保留阴影区域内的文字的第二灰度图像
Figure PCTCN2022074888-appb-000026
其中,
Figure PCTCN2022074888-appb-000027
其中
Figure PCTCN2022074888-appb-000028
Figure PCTCN2022074888-appb-000029
分别是第二灰度图像
Figure PCTCN2022074888-appb-000030
和第一灰度图像D g第i行第j列的元素。
其中较优地,所述阴影消除方法还包括如下子步骤:
对第一灰度图像进行阴影边界增强,得到第三灰度图像
Figure PCTCN2022074888-appb-000031
其中,
Figure PCTCN2022074888-appb-000032
Figure PCTCN2022074888-appb-000033
是第三灰度图像
Figure PCTCN2022074888-appb-000034
第i行第j列的元素。
其中较优地,对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示,包括如下子步骤:
对第三灰度图像进行空间域的平滑滤波处理,之后进行二值化处理得到非阴影区域的掩膜表示;
对非阴影区域的掩膜表示的灰度值进行翻转,获得阴影区域的掩膜表示。
其中较优地,根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像,包括如下子步骤:
将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
根据本发明实施例的第二方面,提供一种文字图像的阴影消除装置,包括:
灰度图像转化单元,用于将待处理的文字图像转化为第一灰度图像;
灰度分割阈值确定单元,用于对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;
掩膜表示确定单元,用于对所述背景灰度分割阈值和文字灰度分 割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示;
背景增强单元,用于对第一灰度图像进行背景增强,得到第二灰度图像;
区域融合单元,用于根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
根据本发明实施例的第三方面,提供一种电子设备,包括处理器和存储器,所述处理器与存储器耦合,用于执行所述存储器中的程序或指令,以使所述电子设备实现如上述第一方面所述的方法。
根据本发明实施例的第四方面,提供一种计算机可读存储介质,所述可读存储介质上存储有指令,当其在计算机上运行时,使得所述计算机实现如上述第一方面所述的方法。
根据本发明实施例的第五方面,提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得所述计算机实现如上述第一方面所述的方法。
与现有技术相比较,本发明能够将待处理的文字图像转化为第一灰度图像;对第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示;对第一灰度图像进行背景增强,得到第二灰度图像;根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。通过本发明实施例,可以获得阴影消除后的文字图像,避免文字图像中被阴影遮挡的部分内容完全丢失的情况,提升浏览或打印的阅读效果。
附图说明
图1为现有技术中,用拍摄设备拍摄文件所得到的图像的示意图;
图2为现有技术中,将拍摄设备拍摄文件所得到的图像进行打印的效果示意图;
图3为本发明实施例提供的一种文字图像的阴影消除方法的流程 图一;
图4为本发明实施例的应用环境示意图;
图5为本发明实施例提供的一种文字图像的阴影消除方法的流程图二;
图6为本发明实施例中,直方图统计曲线的凸高度计算示例示意图;
图7为采用本发明实施例进行阴影区域消除的结果示意图;
图8为本发明实施例提供的一种文字图像的阴影消除装置的结构示意图;
图9为用于实施本发明实施例的电子设备的示例图。
具体实施方式
下面结合附图和具体实施例对本发明的技术内容做进一步的详细说明。
首先强调的是,本发明中的文字图像不限于狭义的字面表达意思,其包括但不限于具有文字、符号、数字等各种各样信息的图像,只要出现明暗不一,阴影遮挡等情况的图像均适用于本发明的阴影消除方法。
为了避免通过拍摄设备拍摄图像时,在存在阴影遮挡的情况下,所得到的图像存在一大块阴影,影响最终图像的质量,特别是将图像在电子设备上进行浏览以及将图像打印时,图像清晰度较差,甚至造成图形、文字等丢失的情况,如图3所示,本发明实施例首先提供一种文字图像的阴影消除方法,至少包括如下的步骤:
步骤S101:将待处理的文字图像转化为第一灰度图像。
步骤S102:对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值。
步骤S103:对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示。
步骤S104:对第一灰度图像进行背景增强,得到第二灰度图像。
步骤S105:根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域 进行融合处理,获得阴影消除后的文字图像。
为了使本领域的技术人员更好的了解本发明,下面结合具体的应用环境,列举一个更为详细的实施例。如图4所示,用户手持手机201想要拍摄一个文件202,但是其背对光源203,因此用户的手机201挡住了光源203,在文件202上出现了一个手机201留下的阴影204。图5所示的实施例将提供一种文字图像的阴影消除方法,用来针对如图4所示的场景。
此处,如图5所示,本发明实施例进一步提供一种文字图像的阴影消除方法,包括:
步骤S301:获得至少一幅文字图像,确定各幅文字图像的阴影区域信息。
此处,需要说明的是,执行本文字图像的阴影消除方法的电子设备可以是图像采集装置,例如手机、照相机等,还可以是后端处理装置,例如用于图像处理的计算机,服务器等,但不仅局限于此。而确定各幅文字图像的阴影区域信息可以是通过文字图像的灰度信息实现的,一般情况下,若文字图像不存在阴影区域,则整幅图像的灰度分布主要集中在两个部分,且两者灰度值差异较大,灰度值较大区域为背景区域,灰度值较小区域为文字区域。当灰度分布明显集中在多个部分时,可以确定该文字图像存在阴影区域。
步骤S302:根据各幅文字图像的阴影区域信息,从至少一幅文字图像中筛选得到待处理的文字图像。
此处,该步骤S302可以采用如下任意一种方式实现,例如:
根据各幅文字图像的阴影区域面积,从至少一幅文字图像中筛选阴影区域面积大于预先设置的面积阈值的文字图像作为待处理的文字图像。即在某些文字图像的阴影区域面积较小时(例如小于面积阈值),该较小的阴影区域可能并不影响文字信息的浏览和打印,则无需进行处理。而在某些文字图像的阴影区域面积较大时(例如大于面积阈值),该较大的阴影区域可能影响文字信息的浏览和打印,则将其作为待处理的文字图像。这样可以避免全量的文字图像都进行处理,而造成的浪费计算资源的问题。
或者,根据各幅文字图像的阴影区域占整幅图像的面积比例,从 至少一幅文字图像中筛选面积比例大于预先设置的比例阈值的文字图像作为待处理的文字图像。即在某些文字图像的阴影区域面积较小时(例如阴影区域占整幅图像的面积比例小于比例阈值),该较小的阴影区域可能并不影响文字信息的浏览和打印,则无需进行处理。而在某些文字图像的阴影区域面积较大时(例如阴影区域占整幅图像的面积比例大于比例阈值),该较大的阴影区域可能影响文字信息的浏览和打印,则将其作为待处理的文字图像。这样可以避免全量的文字图像都进行处理,而造成的浪费计算资源的问题。
步骤S303:将待处理的文字图像转化为第一灰度图像。
此处,该步骤S303可以采用如下方式实现,例如:
首先该待处理的文字图像为D o,一般情况下,设定待处理的文字图像对应数据矩阵D o的维度为m×n×3,其中m和n分别为图像的高度和宽度对应的像素点的个数。一般而言,待处理的文字图像D o由r/g/b三个颜色通道的数据表示,其维度都为m×n。按下式将彩色图像转化为第一灰度图像:
D g=0.2989*R+0.5870*G+0.1140*B
其中,R、G、B为原彩色图像D o中的红色、绿色以及蓝色分量,其矩阵各个元素取值和原彩色图像关系如下
Figure PCTCN2022074888-appb-000035
其中r (i,j),g (i,j)和b (i,j)分别表示R/G/B矩阵中的第i行第j列的元素。
步骤S304:对第一灰度图像进行直方图统计。
此处,该步骤S304可以采用如下方式实现:
将第一灰度图像中的所有元素通过直方图统计的方式进行分布估计,形成分布估计序列
Figure PCTCN2022074888-appb-000036
确定分布估计序列
Figure PCTCN2022074888-appb-000037
中各元素对应的分布概率密度λ k;其中,
Figure PCTCN2022074888-appb-000038
其中λ k为分布估计序列
Figure PCTCN2022074888-appb-000039
的第k个元素对应的分布概率密度;θ k为落入区间[(k-1)*ρ,k*ρ]的取值数;Θ为所述第一灰度图像D g的元素个数,满足Θ=m×n;ρ为统计间隔,ρ=255/Z,Z为预先设置的统计区间总数,例如可以为125;
根据各元素对应的分布概率密度λ k,使用一阶差分和符号判断方法,得到一阶差分符号序列
Figure PCTCN2022074888-appb-000040
其中
Figure PCTCN2022074888-appb-000041
Figure PCTCN2022074888-appb-000042
的第i个元素;其中,
Figure PCTCN2022074888-appb-000043
根据
Figure PCTCN2022074888-appb-000044
中的元素
Figure PCTCN2022074888-appb-000045
计算二阶差分极值标记序列
Figure PCTCN2022074888-appb-000046
其中
Figure PCTCN2022074888-appb-000047
Figure PCTCN2022074888-appb-000048
第j个元素;其中,
Figure PCTCN2022074888-appb-000049
步骤S305:计算直方图统计后每个灰度区间的凸高度,并对凸高度进行排序。
此处,该步骤S305可以采用如下方式实现:
确定分布估计序列
Figure PCTCN2022074888-appb-000050
对应的凸高度序列H;其中,凸高度序列H的长度和分布估计序列
Figure PCTCN2022074888-appb-000051
的二阶差分极值标记序列
Figure PCTCN2022074888-appb-000052
相同,且在序列
Figure PCTCN2022074888-appb-000053
为零的位置上,凸高度序列H对应的值也为零。
对分布估计序列
Figure PCTCN2022074888-appb-000054
中二阶差分极值标记序列非零位置上的元素
Figure PCTCN2022074888-appb-000055
计算其对应的凸区间以及凸高度;其中,凸区间的计算包括左凸区间和右凸区间的计算;其中,左凸区间为极值位置到上一个更高极值所在位置或信号起始位置;右凸区间为极值位置到下一个更高极值所在位置或信号结束位置;
对于满足其对应位置上二阶差分极值序列的值非零的元素λ t,0≤t≤Z-2,其左凸区间的起始位置α L和右凸区间的结束位置α R的计算方式如下:
Figure PCTCN2022074888-appb-000056
Figure PCTCN2022074888-appb-000057
确定满足其对应位置上二阶差分极值序列的值非零的元素λ t的左凸区间和右凸区间分别为[α L,t]和[t,α R];
计算左凸区间和右凸区间内的最小值的较大值作为凸高度的参考点λ ref
Figure PCTCN2022074888-appb-000058
其中,
Figure PCTCN2022074888-appb-000059
算符为求序列ψ在区间[a,b]中的最小值;
确定元素λ t对应的凸高度为:
Η t=λ tref
对凸高度序列H进行排序。
步骤S306:提取凸高度最大的n个灰度区间,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值。
其中,n为预先设置的正整数,推荐n取值为4,当然也可以取值为3或5等。
此处,该步骤S306可以采用如下方式实现:
从凸高度序列H中从大到小取出n个元素,对应的索引依次为{τ 012,…,τ n-1},例如当n=4时,对应的索引依次为{τ 0123},分别取出分布估计序列
Figure PCTCN2022074888-appb-000060
对应位置上的值,确定第一灰度图像的背景灰度分割阈值μ b和第一灰度图像的阴影区域内的文字灰度分割阈值μ st;其中,
Figure PCTCN2022074888-appb-000061
其中,Δ为分割阈值的预设偏移量,属于可调参数,例如可以取值50。
步骤S307:对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示。
此处,该步骤S307可以采用如下方式实现:
为了获得更平滑的阴影区域,对第三灰度图像
Figure PCTCN2022074888-appb-000062
进行空间域的平滑滤波处理,之后进行二值化处理得到非阴影区域的掩膜表示
Figure PCTCN2022074888-appb-000063
其中,
Figure PCTCN2022074888-appb-000064
其中,
Figure PCTCN2022074888-appb-000065
为二维卷积运算符;P为预先设置的空间滤波的滤波器系数,维度σ×ω,本发明实施例中主要用来平滑边缘和消除区域内的 “孤岛”灰度尖峰,所以一般可以使用归一化的幺矩阵,即幺矩阵需要乘以1/(σ×ω)。滤波器系数矩阵的维度为可调参数,本发明实施例中一般使用σ=ω=10,
Figure PCTCN2022074888-appb-000066
为图像二值化算子;
对非阴影区域的掩膜表示
Figure PCTCN2022074888-appb-000067
的灰度值进行翻转,获得阴影区域的掩膜表示
Figure PCTCN2022074888-appb-000068
其中,
Figure PCTCN2022074888-appb-000069
其中1表示和
Figure PCTCN2022074888-appb-000070
同维度的幺矩阵。
步骤S308:对第一灰度图像进行背景增强,得到第二灰度图像。
此处,该步骤S308可以采用如下方式实现:
确定背景增强并保留阴影区域内的文字的第二灰度图像
Figure PCTCN2022074888-appb-000071
其中,
Figure PCTCN2022074888-appb-000072
其中
Figure PCTCN2022074888-appb-000073
Figure PCTCN2022074888-appb-000074
分别是第二灰度图像
Figure PCTCN2022074888-appb-000075
和第一灰度图像D g第i行第j列的元素。
步骤S309:对第一灰度图像进行阴影边界增强,得到第三灰度图像
Figure PCTCN2022074888-appb-000076
其中,
Figure PCTCN2022074888-appb-000077
其中
Figure PCTCN2022074888-appb-000078
是第三灰度图像
Figure PCTCN2022074888-appb-000079
第i行第j列的元素。
步骤S310:根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
此处,该步骤S310可以采用如下方式实现:
将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像
Figure PCTCN2022074888-appb-000080
其中,
Figure PCTCN2022074888-appb-000081
通过上述步骤S301至步骤S310,本方案实施例进行了仿真处理,过程如下:
如图1和图4所示,在室内存在单一光源照明并且拍摄设备没有打开闪光灯的情况下,图像上存在大量阴影区域。阴影区域内的文字已经难以辨认。如果直接对原图进行二值化,如图2所示,阴影区域内的文字信息完全丢失。根据本发明所提供的实施例,首先对灰度化的图像进行直方图统计。然后计算每个灰度区间的凸高度,如图6所示,提取凸高度最大的4个灰度区间作为后续阴影区域文字和背景的灰度参考值。然后,通过灰度值的阈值分割,空间平滑滤波和二值化,分别获得阴影区域和非阴影区域的掩膜表示。最后基于掩膜表示将背景增强的阴影区域和原灰度图像的非阴影区域进行融合,并通过二值化均衡整体的灰度平衡,最终得到祛除阴影后的文字图像。通过本方法实施例处理后,如图7所示,阴影区域基本被消除,并且文字没有被明显破坏,文字甚至比图2更加清晰可见。
另外,如图8所示,本发明实施例还提供一种文字图像的阴影消除装置,包括:
灰度图像转化单元41,用于将待处理的文字图像转化为第一灰度图像。
灰度分割阈值确定单元42,用于对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值。
掩膜表示确定单元43,用于对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示。
背景增强单元44,用于对第一灰度图像进行背景增强,得到第二灰度图像。
区域融合单元45,用于根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
另外,本发明实施例还提供一种电子设备,包括处理器和存储器,所述处理器与存储器耦合,用于执行所述存储器中的程序或指令,以使所述电子设备实现如上述图3或图5所述的方法。
如图9所示,该电子设备至少包括处理器和存储器,还可以根据实际 需要进一步包括通信组件、传感器组件、电源组件、多媒体组件及输入/输出接口。其中,存储器、通信组件、传感器组件、电源组件、多媒体组件及输入/输出接口均与该处理器连接。存储器可以是静态随机存取存储器(SRAM)、电可擦除可编程只读存储器(EEPROM)、可擦除可编程只读存储器(EPROM)、可编程只读存储器(PROM)、只读存储器(ROM)、磁存储器、快闪存储器等,处理器可以是中央处理器(CPU)、图形处理器(GPU)、现场可编程逻辑门阵列(FPGA)、专用集成电路(ASIC)、数字信号处理(DSP)芯片等。其它通信组件、传感器组件、电源组件、多媒体组件等均可以采用通用部件实现,在此就不具体说明了。
另外,本发明实施例还提供一种计算机可读存储介质,所述可读存储介质上存储有指令,当其在计算机上运行时,使得所述计算机执行如上述图3或图5所述的方法。
另外,本发明实施例还提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得所述计算机执行如上述图3或图5所述的方法。
本发明所提供的文字图像的阴影消除方法、装置及电子设备,能够将待处理的文字图像转化为第一灰度图像;对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示;对第一灰度图像进行背景增强,得到第二灰度图像;根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。通过本发明实施例,可以获得阴影消除后的文字图像,避免文字图像中阴影遮挡的部分的内容完全丢失的情况,提升浏览和打印的阅读效果。
以上对本发明所提供的文字图像的阴影消除方法、装置及电子设备进行了详细的说明。对本领域的一般技术人员而言,在不背离本发明实质内容的前提下对它所做的任何显而易见的改动,都将属于本发明专利权的保护范围。

Claims (14)

  1. 一种文字图像的阴影消除方法,其特征在于包括如下步骤:
    将待处理的文字图像转化为第一灰度图像;
    对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;
    对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示;
    对第一灰度图像进行背景增强,得到第二灰度图像;
    根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
  2. 如权利要求1所述的阴影消除方法,其特征在于,在将待处理的文字图像转化为第一灰度图像之前,包括如下步骤:
    获得至少一幅文字图像,确定各幅文字图像的阴影区域信息;
    根据各幅文字图像的阴影区域信息,从至少一幅文字图像中筛选得到待处理的文字图像。
  3. 如权利要求2所述的阴影消除方法,其特征在于,所述根据各幅文字图像的阴影区域信息,从至少一幅文字图像中筛选得到待处理的文字图像,包括如下子步骤:
    根据各幅文字图像的阴影区域面积,从至少一幅文字图像中筛选阴影区域面积大于预先设置的面积阈值的文字图像作为待处理的文字图像。
  4. 如权利要求2所述的阴影消除方法,其特征在于,所述根据各幅文字图像的阴影区域信息,从至少一幅文字图像中筛选得到待处理的文字图像,包括如下子步骤:
    根据各幅文字图像的阴影区域占整幅图像的面积比例,从至少一幅文字图像中筛选面积比例大于预先设置的比例阈值的文字图像作为待处理的文字图像。
  5. 如权利要求1所述的阴影消除方法,其特征在于,对所述第一 灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值,包括如下子步骤:
    对所述第一灰度图像进行直方图统计;
    计算直方图统计后每个灰度区间的凸高度,并对凸高度进行排序;
    提取凸高度最大的n个灰度区间,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;其中,n为预先设置的正整数。
  6. 如权利要求5所述的阴影消除方法,其特征在于,对所述第一灰度图像进行直方图统计,包括如下子步骤:
    将所述第一灰度图像中的所有元素通过直方图统计的方式进行分布估计,形成分布估计序列
    Figure PCTCN2022074888-appb-100001
    确定分布估计序列
    Figure PCTCN2022074888-appb-100002
    中各元素对应的分布概率密度λ k;其中,
    Figure PCTCN2022074888-appb-100003
    其中λ k为分布估计序列
    Figure PCTCN2022074888-appb-100004
    的第k个元素对应的分布概率密度;θ k为落入区间[(k-1)*ρ,k*ρ]的取值数;Θ为所述第一灰度图像的元素个数;ρ为统计间隔,ρ=255/Z,Z为预先设置的统计区间总数;
    根据各元素对应的分布概率密度λ k,使用一阶差分和符号判断方法,得到一阶差分符号序列
    Figure PCTCN2022074888-appb-100005
    其中
    Figure PCTCN2022074888-appb-100006
    Figure PCTCN2022074888-appb-100007
    的第i个元素;其中,
    Figure PCTCN2022074888-appb-100008
    根据
    Figure PCTCN2022074888-appb-100009
    中的元素
    Figure PCTCN2022074888-appb-100010
    计算二阶差分极值标记序列
    Figure PCTCN2022074888-appb-100011
    其中
    Figure PCTCN2022074888-appb-100012
    Figure PCTCN2022074888-appb-100013
    第j个元素;其中,
    Figure PCTCN2022074888-appb-100014
  7. 如权利要求6所述的阴影消除方法,其特征在于,计算直方图统计后每个灰度区间的凸高度,并对凸高度进行排序,包括如下子步骤:
    确定分布估计序列
    Figure PCTCN2022074888-appb-100015
    对应的凸高度序列H;其中,凸高度序列H的长 度和分布估计序列
    Figure PCTCN2022074888-appb-100016
    的二阶差分极值标记序列
    Figure PCTCN2022074888-appb-100017
    相同,且在序列
    Figure PCTCN2022074888-appb-100018
    为零的位置上,凸高度序列H对应的值也为零;
    对分布估计序列
    Figure PCTCN2022074888-appb-100019
    中二阶差分极值标记序列非零位置上的元素
    Figure PCTCN2022074888-appb-100020
    计算其对应的凸区间以及凸高度;其中,凸区间的计算包括左凸区间和右凸区间的计算;其中,左凸区间为极值位置到上一个更高极值所在位置或信号起始位置;右凸区间为极值位置到下一个更高极值所在位置或信号结束位置;
    对于满足其对应位置上二阶差分极值序列的值非零的元素λ t,0≤t≤Z-2,其左凸区间的起始位置α L和右凸区间的结束位置α R的计算方式如下:
    Figure PCTCN2022074888-appb-100021
    确定满足其对应位置上二阶差分极值序列的值非零的元素λ t的左凸区间和右凸区间分别为[α L,t]和[t,α R];
    计算左凸区间和右凸区间内的最小值的较大值作为凸高度的参考点λ ref
    Figure PCTCN2022074888-appb-100022
    其中,
    Figure PCTCN2022074888-appb-100023
    算符为求序列ψ在区间[a,b]中的最小值;
    确定元素λ t对应的凸高度为:
    Η t=λ tref
    对凸高度序列H进行排序。
  8. 如权利要求7所述的阴影消除方法,其特征在于,所述提取凸高度最大的n个灰度区间,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值,包括如下子步骤:
    从凸高度序列H中从大到小取出n个元素,对应的索引依次为{τ 012,…,τ n-1},分别取出分布估计序列
    Figure PCTCN2022074888-appb-100024
    对应位置上的值,确定第一灰度图像的背景灰度分割阈值μ b和第一灰度图像的阴影区域内的文字 灰度分割阈值μ st;其中,
    Figure PCTCN2022074888-appb-100025
    其中,Δ为分割阈值的预设偏移量。
  9. 如权利要求8所述的阴影消除方法,其特征在于,所述对第一灰度图像进行背景增强,得到第二灰度图像,包括如下子步骤:
    确定背景增强并保留阴影区域内的文字的第二灰度图像
    Figure PCTCN2022074888-appb-100026
    其中,
    Figure PCTCN2022074888-appb-100027
    其中
    Figure PCTCN2022074888-appb-100028
    Figure PCTCN2022074888-appb-100029
    分别是第二灰度图像
    Figure PCTCN2022074888-appb-100030
    和第一灰度图像D g第i行第j列的元素。
  10. 如权利要求9所述的阴影消除方法,其特征在于还包括如下子步骤:
    对第一灰度图像进行阴影边界增强,得到第三灰度图像
    Figure PCTCN2022074888-appb-100031
    其中,
    Figure PCTCN2022074888-appb-100032
    Figure PCTCN2022074888-appb-100033
    是第三灰度图像
    Figure PCTCN2022074888-appb-100034
    第i行第j列的元素。
  11. 如权利要求10所述的阴影消除方法,其特征在于,对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示,包括如下子步骤:
    对第三灰度图像进行空间域的平滑滤波处理,之后进行二值化处理得到非阴影区域的掩膜表示;
    对非阴影区域的掩膜表示的灰度值进行翻转,获得阴影区域的掩膜表示。
  12. 如权利要求11所述的阴影消除方法,其特征在于,所述根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像,包括如下子步骤:
    将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
  13. 一种文字图像的阴影消除装置,其特征在于包括:
    灰度图像转化单元,用于将待处理的文字图像转化为第一灰度图像;
    灰度分割阈值确定单元,用于对所述第一灰度图像进行直方图统计和凸高度排序处理,确定第一灰度图像的背景灰度分割阈值和第一灰度图像的阴影区域内的文字灰度分割阈值;
    掩膜表示确定单元,用于对所述背景灰度分割阈值和文字灰度分割阈值进行处理,分别获得阴影区域掩膜表示和非阴影区域掩膜表示;
    背景增强单元,用于对第一灰度图像进行背景增强,得到第二灰度图像;
    区域融合单元,用于根据所述阴影区域掩膜表示和非阴影区域掩膜表示将第二灰度图像中背景增强的阴影区域和第一灰度图像中的非阴影区域进行融合处理,获得阴影消除后的文字图像。
  14. 一种电子设备,其特征在于包括处理器和存储器,所述处理器与存储器耦合,用于执行所述存储器中的程序或指令,以使所述电子设备实现如权利要求1~12中任意一项所述的阴影消除方法。
PCT/CN2022/074888 2021-02-08 2022-01-29 一种文字图像的阴影消除方法、装置及电子设备 WO2022166865A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/446,446 US20230386002A1 (en) 2021-02-08 2023-08-08 Shadow elimination method and apparatus for text image, and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110171517.7A CN113012059A (zh) 2021-02-08 2021-02-08 一种文字图像的阴影消除方法、装置及电子设备
CN202110171517.7 2021-02-08

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/446,446 Continuation US20230386002A1 (en) 2021-02-08 2023-08-08 Shadow elimination method and apparatus for text image, and electronic device

Publications (1)

Publication Number Publication Date
WO2022166865A1 true WO2022166865A1 (zh) 2022-08-11

Family

ID=76383835

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/074888 WO2022166865A1 (zh) 2021-02-08 2022-01-29 一种文字图像的阴影消除方法、装置及电子设备

Country Status (3)

Country Link
US (1) US20230386002A1 (zh)
CN (1) CN113012059A (zh)
WO (1) WO2022166865A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116612052A (zh) * 2023-07-17 2023-08-18 青岛瑞源工程集团有限公司 一种建筑施工安全信息管理方法及系统
CN116682112A (zh) * 2023-07-28 2023-09-01 青岛虹竹生物科技有限公司 一种多糖测试数据存储及数字化方法
CN116703888A (zh) * 2023-07-28 2023-09-05 菏泽城建新型工程材料有限公司 一种钻孔灌注桩施工辅助异常检测方法及其系统
CN116779114A (zh) * 2023-08-24 2023-09-19 邹城市人民医院 一种抗肿瘤医疗mri图像信息智能管理系统

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113012059A (zh) * 2021-02-08 2021-06-22 瞬联软件科技(北京)有限公司 一种文字图像的阴影消除方法、装置及电子设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101621607A (zh) * 2009-07-24 2010-01-06 天津三星光电子有限公司 数码相机消除影像阴影的方法
CN106296666A (zh) * 2016-08-01 2017-01-04 北京大学深圳研究生院 一种彩色图像去阴影方法和应用
CN106951811A (zh) * 2017-03-20 2017-07-14 深圳市金立通信设备有限公司 一种图像处理方法及终端
CN113012059A (zh) * 2021-02-08 2021-06-22 瞬联软件科技(北京)有限公司 一种文字图像的阴影消除方法、装置及电子设备

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106815587B (zh) * 2015-11-30 2019-10-18 浙江宇视科技有限公司 图像处理方法及装置
CN107862667B (zh) * 2017-11-23 2019-12-24 武汉大学 一种基于高分辨率遥感影像的城市阴影检测与去除方法
US10559067B2 (en) * 2018-02-28 2020-02-11 Adobe Inc. Removal of shadows from document images while preserving fidelity of image contents

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101621607A (zh) * 2009-07-24 2010-01-06 天津三星光电子有限公司 数码相机消除影像阴影的方法
CN106296666A (zh) * 2016-08-01 2017-01-04 北京大学深圳研究生院 一种彩色图像去阴影方法和应用
CN106951811A (zh) * 2017-03-20 2017-07-14 深圳市金立通信设备有限公司 一种图像处理方法及终端
CN113012059A (zh) * 2021-02-08 2021-06-22 瞬联软件科技(北京)有限公司 一种文字图像的阴影消除方法、装置及电子设备

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116612052A (zh) * 2023-07-17 2023-08-18 青岛瑞源工程集团有限公司 一种建筑施工安全信息管理方法及系统
CN116612052B (zh) * 2023-07-17 2023-09-22 青岛瑞源工程集团有限公司 一种建筑施工安全信息管理方法及系统
CN116682112A (zh) * 2023-07-28 2023-09-01 青岛虹竹生物科技有限公司 一种多糖测试数据存储及数字化方法
CN116703888A (zh) * 2023-07-28 2023-09-05 菏泽城建新型工程材料有限公司 一种钻孔灌注桩施工辅助异常检测方法及其系统
CN116682112B (zh) * 2023-07-28 2023-10-17 青岛虹竹生物科技有限公司 一种多糖测试数据存储及数字化方法
CN116703888B (zh) * 2023-07-28 2023-10-20 菏泽城建新型工程材料有限公司 一种钻孔灌注桩施工辅助异常检测方法及其系统
CN116779114A (zh) * 2023-08-24 2023-09-19 邹城市人民医院 一种抗肿瘤医疗mri图像信息智能管理系统
CN116779114B (zh) * 2023-08-24 2023-11-03 邹城市人民医院 一种抗肿瘤医疗mri图像信息智能管理系统

Also Published As

Publication number Publication date
CN113012059A (zh) 2021-06-22
US20230386002A1 (en) 2023-11-30

Similar Documents

Publication Publication Date Title
WO2022166865A1 (zh) 一种文字图像的阴影消除方法、装置及电子设备
US20220222786A1 (en) Image processing method, smart device, and computer readable storage medium
US20230215197A1 (en) Systems and Methods for Detection and Localization of Image and Document Forgery
Jiang et al. Image dehazing using adaptive bi-channel priors on superpixels
CN110751655B (zh) 一种基于语义分割和显著性分析的自动抠图方法
Xiaofeng et al. Discriminatively trained sparse code gradients for contour detection
EP2863362B1 (en) Method and apparatus for scene segmentation from focal stack images
CN111062854B (zh) 检测水印的方法、装置、终端及存储介质
CN107330387B (zh) 基于图像数据的行人检测方法
CN110991310A (zh) 人像检测方法、装置、电子设备及计算机可读介质
CN107578011A (zh) 视频关键帧的判定方法及装置
CN113033558A (zh) 一种用于自然场景的文本检测方法及装置、存储介质
CN112651953A (zh) 图片相似度计算方法、装置、计算机设备及存储介质
Zhang et al. Single image dehazing based on bright channel prior model and saliency analysis strategy
Tuptewar et al. Robust exemplar based image and video inpainting for object removal and region filling
CN113139544A (zh) 一种基于多尺度特征动态融合的显著性目标检测方法
Song et al. A Single Image Dehazing Method Based on End-to-End CPAD-Net Network in Deep Learning Environment
CN115661482B (zh) 一种基于联合注意力的rgb-t显著目标检测方法
TWI308729B (zh)
CN112991236B (zh) 一种基于模板的图像增强方法及装置
CN115937039A (zh) 数据扩充方法、装置、电子设备及可读存储介质
CN113344011B (zh) 一种基于级联融合特征置信度加权的颜色恒常性方法
Zhang et al. SDTCN: Similarity driven transmission computing network for image dehazing
WO2020168818A1 (zh) 一种图像处理方法、系统、装置、存储介质及黑板装置
CN111932470A (zh) 基于视觉选择融合的图像复原方法、装置、设备和介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22749144

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 21.11.2023)