Text image quality evaluation method, terminal equipment and storage medium
By extracting the grayscale histogram features of text images and calculating the quality evaluation coefficients, combined with Fourier transform denoising processing, the problem of poor evaluation results in the existing technology in noise and complex backgrounds is solved, and text images in complex scenarios are realized Efficient quality assessment.
Patent Information
- Application Number
- CN202411537877.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-11
AI Technical Summary
Existing text image quality evaluation methods are poor in dealing with noise interference, complex backgrounds, and differences in imaging quality of different imaging devices, and deep learning models are insufficient in generalization without training data sets or in extreme cases.
A text image quality evaluation method is proposed. By obtaining grayscale maps and converting them into grayscale histograms, the grayscale values of peaks and valleys are extracted, the quality evaluation coefficient L is calculated, and the image is determined to be clear or blurred. After denoising, this method uses Fourier transform to separate noise and text frequency components to reduce background interference.
Without the need for massive labeled data, efficient quality evaluation of text images in complex scenarios improves the accuracy and robustness of the evaluation.
Smart Images

Figure CN119418349A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image quality assessment, and in particular to a text image quality assessment method, terminal equipment and storage medium. Background Art
[0002] In the modern information society, text image quality assessment is crucial for document processing, optical character recognition (OCR), archive management, and intelligent analysis. Traditional text image quality assessment methods mainly rely on image processing algorithms, such as contrast analysis, edge detection, and blur estimation. Although these methods can work effectively under certain conditions, they are often limited by image noise interference, complex backgrounds, and differences in imaging quality between different acquisition devices. In addition, with the rise of deep learning, image quality assessment methods based on convolutional neural networks (CNNs) have gradually become mainstream. However, although deep learning models can provide a certain degree of accuracy when processing complex scenes, they have high computational complexity and rely on a large amount of labeled data. In some untrained data sets or extreme cases, the generalization ability of the model is not as good as expected. Summary of the invention
[0003] In order to solve the above problems, the present invention proposes a text image quality assessment method, a terminal device and a storage medium.
[0004] The specific plan is as follows:
[0005] A text image quality assessment method comprises the following steps:
[0006] S1: Obtain the grayscale image corresponding to the text image to be analyzed, and convert the grayscale image into a grayscale histogram;
[0007] S2: based on the grayscale histogram, extract the grayscale values corresponding to the peaks of the two peaks and the grayscale value corresponding to the valley between the two peaks;
[0008] S3: Calculate the quality assessment coefficient L by the following formula:
[0009]
[0010] Among them, k represents the amplification factor, P1 and P2 represent the grayscale values corresponding to the peaks of the two peaks, V represents the grayscale value corresponding to the valley between the two peaks, and α is a hyperparameter;
[0011] S4: When the quality assessment coefficient L is greater than 0, the analyzed text image is determined to be clear; when the quality assessment coefficient L is less than 0, the analyzed text image is determined to be fuzzy.
[0012] Furthermore, before converting the grayscale image into a grayscale histogram, step S1 further includes: performing denoising on the grayscale image.
[0013] Furthermore, the specific process of denoising includes: converting the grayscale image into a frequency domain image through Fourier transform; removing high-frequency noise in the frequency domain image to obtain a repaired frequency domain image; and performing inverse Fourier transform on the repaired frequency domain image to obtain a denoised grayscale image.
[0014] Furthermore, k is set to 30.
[0015] Furthermore, α is set to 40.
[0016] A text image quality assessment terminal device comprises a processor, a memory and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described above in the embodiment of the present invention are implemented.
[0017] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described above in an embodiment of the present invention are implemented.
[0018] The present invention adopts the above technical solution, which can perform efficient quality assessment on text images in complex scenes without massive data annotation. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 Shown is a flow chart of a method according to a first embodiment of the present invention.
[0020] Figure 2 Shown is a schematic diagram of the function change curve in this embodiment. DETAILED DESCRIPTION
[0021] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.
[0022] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.
[0023] Embodiment 1:
[0024] The embodiment of the present invention provides a text image quality assessment method, such as Figure 1 As shown, the method comprises the following steps:
[0025] S1: Obtain a grayscale image corresponding to the text image to be analyzed, and convert the grayscale image into a grayscale histogram.
[0026] In this embodiment, before converting the grayscale image into a grayscale histogram, the process also includes: performing denoising on the grayscale image. In this embodiment, the denoising is performed based on the frequency domain image obtained by Fourier transform, and the specific process includes: converting the grayscale image into a frequency domain image by Fourier transform; removing high-frequency noise in the frequency domain image to obtain a repaired frequency domain image; and performing inverse Fourier transform on the repaired frequency domain image to obtain a denoised grayscale image.
[0027] In this embodiment, the input text image to be analyzed is first converted into a grayscale image, and then the frequency domain information of the grayscale image is analyzed by Fourier transform. The blur kernel is estimated from the edge and frequency domain information in the text image grayscale image to obtain the spectrum H(u,v), and its frequency domain representation is shown in formula (1). The grayscale image g(x,y) is Fourier transformed to obtain the frequency domain image G(u,v), and the high-frequency noise is removed to obtain the repaired frequency domain image F(u,v), as shown in formula (2). The repaired frequency domain image is inversely Fourier transformed to obtain the denoised grayscale image f(x,y).
[0028]
[0029] Where (u,v) represents the coordinates in the frequency domain.
[0030] Through the above-mentioned Fourier transform, the frequency components of background noise and text can be separated in the frequency domain, reducing the impact of background interference on text clarity evaluation.
[0031] S2: Based on the grayscale histogram, the grayscale values corresponding to the peaks of the two peaks and the grayscale value corresponding to the valley between the two peaks are extracted.
[0032] Since the horizontal axis of the grayscale histogram represents the grayscale value and the vertical axis represents the frequency, and the grayscale histogram corresponding to the text image is a relatively smooth histogram, usually including only two peaks corresponding to the foreground and the background, the grayscale value distribution corresponding to the peaks of the two peaks of the grayscale histogram corresponding to a clear text image should tend to 0 and 255, and the frequency corresponding to the valley between the two peaks has a large difference from the frequency corresponding to the peaks of the two peaks. Therefore, this embodiment evaluates the image quality based on this feature.
[0033] S3: Calculate the quality assessment coefficient L by the following formula:
[0034]
[0035] Among them, k represents the amplification factor, P1 and P2 represent the grayscale values corresponding to the peaks of the two peaks respectively, V represents the grayscale value corresponding to the valley between the two peaks, α is a hyperparameter, min represents the minimum value, and max represents the maximum value.
[0036] In the calculation of the above quality assessment coefficient L, first, by sorting the frequencies of the gray values, the gray values corresponding to the two frequencies at the first two frequencies are found, that is, the gray values P1 and P2 corresponding to the peaks of the two peaks; then, based on the gray values corresponding to the peaks of the two peaks, the peak gray difference is calculated by formula (3):
[0037]
[0038] Among them, 255 is the maximum grayscale value of an 8-bit grayscale image.
[0039] Secondly, find the gray value with the lowest frequency between the gray values P1 and P2 corresponding to the two peaks, that is, the gray value V corresponding to the valley between the two peaks; then calculate the peak-to-valley drop ΔH using formula (4): norm :
[0040]
[0041] Based on the peak grayscale difference and the peak-to-valley difference, the calculation formula of the comprehensive clarity index S can be obtained as shown in formula (5):
[0042]
[0043] Wherein, k represents the amplification factor, which is preferably set to 30 in this embodiment; α is a hyperparameter, which is preferably set to 40 based on empirical values in this embodiment. The function change curve corresponding to formula (5) is as follows: Figure 2 As shown in the figure, it can be seen that when the value of S is close to 0, it means that the peak difference of the text image is small or the peak-to-valley difference is small, and the image is fuzzy; when the value of S is close to 1, it means that the peak difference of the text image is large or the peak-to-valley difference is large, and the image is clear. Figure 2 The horizontal axis is -k(ΔP norm +ΔH norm -α), when it is less than 0, the value of S tends to 0, and the image is blurry; when it is greater than 0, the value of S tends to 1, and the image is clear. As the quality assessment coefficient of text images.
[0044] S4: When the quality assessment coefficient L is greater than 0, the analyzed text image is determined to be clear; when the quality assessment coefficient L is less than 0, the analyzed text image is determined to be fuzzy.
[0045] The method of this embodiment converts the text image from the spatial domain to the frequency domain through Fourier transform, so that the edges and details of the text in the noise and image can be separated and the low-frequency noise can be filtered out, so that the denoised image can present the text details more clearly, so that the subsequent adaptive grayscale histogram change analysis can more accurately reflect the real image quality and structure of the text. This method has the advantages of high efficiency, robustness and easy implementation.
[0046] Embodiment 2:
[0047] The present invention also provides a text image quality assessment terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above method embodiment of embodiment 1 of the present invention when executing the computer program.
[0048] Further, as an executable solution, the text image quality assessment terminal device can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The text image quality assessment terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the composition structure of the above-mentioned text image quality assessment terminal device is only an example of a text image quality assessment terminal device, and does not constitute a limitation on the text image quality assessment terminal device. It may include more or less components than the above-mentioned, or a combination of certain components, or different components. For example, the text image quality assessment terminal device may also include input and output devices, network access devices, buses, etc., and the embodiments of the present invention do not limit this.
[0049] Further, as an executable solution, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the text image quality assessment terminal device, and uses various interfaces and lines to connect various parts of the entire text image quality assessment terminal device.
[0050] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the text image quality assessment terminal device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and an application required for at least one function; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0051] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method in the embodiment of the present invention are implemented.
[0052] If the module / unit integrated in the text image quality assessment terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) and software distribution medium, etc.
[0053] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.
Claims
1. A text image quality assessment method, characterized in that: The following steps are involved: S1: Obtain the grayscale image corresponding to the text image to be analyzed, and convert the grayscale image into a grayscale histogram; S2: based on the grayscale histogram, extract the grayscale values corresponding to the peaks of the two peaks and the grayscale value corresponding to the valley between the two peaks; S3: Calculate the quality evaluation coefficient L by the following formula: Among them, k represents the amplification factor, P1 and P2 represent the grayscale values corresponding to the peaks of the two peaks, V represents the grayscale value corresponding to the valley between the two peaks, and α is a hyperparameter; S4: When the quality assessment coefficient L is greater than 0, the analyzed text image is determined to be clear; when the quality assessment coefficient L is less than 0, the analyzed text image is determined to be fuzzy.
2. The text image quality assessment method according to claim 1, characterized in that: Before converting the grayscale image into a grayscale histogram, step S1 further includes: performing denoising processing on the grayscale image.
3. The text image quality assessment method according to claim 2, characterized in that: The specific process of denoising includes: converting the grayscale image into a frequency domain image through Fourier transform; removing high-frequency noise in the frequency domain image to obtain a repaired frequency domain image; and performing inverse Fourier transform on the repaired frequency domain image to obtain a denoised grayscale image.
4. The text image quality assessment method according to claim 1, characterized in that: k is set to 30.
5. The text image quality assessment method according to claim 1, characterized in that: Alpha is set to 40.
6. A text image quality assessment terminal device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any one of the methods of claims 1 to 5 when executing the computer program.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.