CN110992387B - Image processing method and device, electronic equipment and storage medium - Google Patents

Image processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN110992387B
CN110992387B CN201911088672.1A CN201911088672A CN110992387B CN 110992387 B CN110992387 B CN 110992387B CN 201911088672 A CN201911088672 A CN 201911088672A CN 110992387 B CN110992387 B CN 110992387B
Authority
CN
China
Prior art keywords
matrix
image
processed
variance
binarization
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201911088672.1A
Other languages
Chinese (zh)
Other versions
CN110992387A (en
Inventor
金良
范宝余
张润泽
郭振华
赵雅倩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
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 Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN201911088672.1A priority Critical patent/CN110992387B/en
Publication of CN110992387A publication Critical patent/CN110992387A/en
Application granted granted Critical
Publication of CN110992387B publication Critical patent/CN110992387B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The application discloses an image processing method, an image processing device, an electronic device and a computer readable storage medium, wherein the method comprises the following steps: acquiring an image to be processed, and calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of a sliding window; calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix; and processing each pixel point by using the binarization threshold value to obtain a processed binarization image. According to the image processing method, matrix correlation operation is introduced, the original operation of calculating the mean value and the variance of a single point based on the whole image is improved to the operation based on the whole image, and the efficiency of local self-adaptive threshold value binarization is improved.

Description

Image processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image processing method and apparatus, an electronic device, and a computer-readable storage medium.
Background
Image binarization is widely applied to image processing, and after graying and binarization processing are carried out on an original image, a large amount of useless information in the original image can be filtered, and useful information is reserved. The image binarization is divided into global threshold binarization and local adaptive threshold binarization. The global threshold binarization is to calculate one or more thresholds according to the related information of the whole image, and then perform binary segmentation on the whole image by using the thresholds, for example, a foreground is obtained when the threshold is larger than the threshold, and a background is obtained when the threshold is smaller than the threshold. The local self-adaptive threshold binarization is to calculate a threshold in the neighborhood of the current point according to the position of the current point in the image, and then judge whether the current point belongs to the foreground or the background according to the threshold.
In the related technology, the local adaptive threshold binarization is based on a single-point processing mode, the processing flow is slightly complex, and the efficiency of the algorithm is greatly restricted by the single-point processing mode along with the rapid development of computer hardware resources and related chips.
Therefore, how to improve the efficiency of the local adaptive threshold binarization is a technical problem to be solved by those skilled in the art.
Disclosure of Invention
An object of the present application is to provide an image processing method, an image processing apparatus, an electronic device, and a computer-readable storage medium, which improve the efficiency of local adaptive threshold binarization.
To achieve the above object, the present application provides an image processing method, comprising:
acquiring an image to be processed, and calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of a sliding window;
calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix;
and processing each pixel point by using the binarization threshold value to obtain a processed binarization image.
Wherein, the calculating the mean matrix and the variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of the sliding window comprises:
determining a quadratic matrix, a row matrix and a column matrix corresponding to the image to be processed; the row matrix is an m multiplied by m matrix, m is the width of the image to be processed, the column matrix is an n multiplied by n matrix, n is the height of the image to be processed, the element of the jth row and the jth column in the row matrix and the column matrix is 1, the rest elements are 0, | i-j | ≦ s/2, and s is the width or the height of the sliding window;
taking the product of the image to be processed and the row matrix as a first intermediate matrix, and taking the product of the first intermediate matrix and the column matrix as the mean matrix;
And taking the product of the quadratic matrix and the row matrix as a second intermediate matrix, and taking the product of the second intermediate matrix and the column matrix as the variance matrix.
Calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix, wherein the calculating comprises:
calculating a binarization threshold corresponding to each pixel point in the image to be processed based on a target formula; wherein the target formula is specifically:
Figure BDA0002266217520000021
wherein T is the binarization threshold, m is the mean value of the pixel points determined according to the mean matrix, S is the variance of the pixel points determined according to the variance matrix, k is a constant, and R is a preset gray level.
Wherein, the processing of each pixel point by using the binarization threshold value to obtain a processed binarization image comprises:
and taking the pixel points of which the pixel values are greater than or equal to the corresponding binarization threshold values in the image to be processed as a foreground, and taking the pixel points of which the pixel values are less than the corresponding binarization threshold values in the image to be processed as a background so as to obtain a processed binarization image.
To achieve the above object, the present application provides an image processing apparatus comprising:
The acquisition module is used for acquiring an image to be processed and calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of the sliding window;
the calculation module is used for calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix;
and the processing module is used for processing each pixel point by using the binarization threshold value to obtain a processed binarization image.
Wherein the acquisition module comprises:
the acquisition unit is used for acquiring an image to be processed;
the determining unit is used for determining a quadratic matrix, a row matrix and a column matrix corresponding to the image to be processed; the row matrix is an m multiplied by m matrix, m is the width of the image to be processed, the column matrix is an n multiplied by n matrix, n is the height of the image to be processed, the element of the jth row and the jth column in the row matrix and the column matrix is 1, the rest elements are 0, | i-j | ≦ s/2, and s is the width or the height of the sliding window;
the first calculation unit is used for taking the product of the image to be processed and the row matrix as a first intermediate matrix and taking the product of the first intermediate matrix and the column matrix as the mean matrix;
A second calculation unit configured to use a product of the quadratic matrix and the row matrix as a second intermediate matrix, and use a product of the second intermediate matrix and the column matrix as the variance matrix.
The calculation module is specifically a module for calculating a binarization threshold corresponding to each pixel point in the image to be processed based on a target formula; wherein the target formula is specifically:
Figure BDA0002266217520000031
wherein T is the binarization threshold, m is the mean value of the pixel points determined according to the mean matrix, S is the variance of the pixel points determined according to the variance matrix, k is a constant, and R is a preset gray level.
The processing module is specifically a module which takes pixel points with pixel values larger than or equal to the corresponding binarization threshold value in the image to be processed as a foreground, and takes pixel points with pixel values smaller than the corresponding binarization threshold value in the image to be processed as a background so as to obtain a processed binarization image.
To achieve the above object, the present application provides an electronic device including:
a memory for storing a computer program;
a processor for implementing the steps of the image processing method as described above when executing the computer program.
To achieve the above object, the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the image processing method as described above.
According to the scheme, the image processing method provided by the application comprises the following steps: acquiring an image to be processed, and calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of a sliding window; calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix; and processing each pixel point by using the binarization threshold value to obtain a processed binarization image.
According to the image processing method, matrix correlation operation is introduced, the original operation of calculating the mean value and the variance of a single point based on the whole image is improved to the operation based on the whole image, and the efficiency of local self-adaptive threshold value binarization is improved. The application also discloses an image processing device, an electronic device and a computer readable storage medium, which can also realize the technical effects.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow diagram illustrating an image processing method according to an exemplary embodiment;
FIG. 2 is a flow diagram illustrating another method of image processing according to an exemplary embodiment;
FIG. 3 is a diagram of an image to be processed;
FIG. 4 is an expanded image corresponding to FIG. 3;
FIG. 5 is a row matrix corresponding to FIG. 3;
FIG. 6 is a column matrix corresponding to FIG. 3;
FIG. 7 is a row operation result;
FIG. 8 is a result of a column operation;
FIG. 9 is a block diagram illustrating an image processing apparatus according to an exemplary embodiment;
FIG. 10 is a block diagram illustrating an electronic device in accordance with an exemplary embodiment.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application discloses an image processing method, which improves the efficiency of local self-adaptive threshold binarization.
Referring to fig. 1, a flowchart of an image processing method according to an exemplary embodiment is shown, as shown in fig. 1, including:
s101: acquiring an image to be processed, and calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of a sliding window;
in the embodiment, the image to be processed is integrally processed through matrix operation to obtain a corresponding mean matrix and a corresponding variance matrix, so that the efficiency of local adaptive threshold binarization is improved compared with single-point operation.
Specifically, the step of calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of the sliding window includes: determining a quadratic matrix, a row matrix and a column matrix corresponding to the image to be processed; the row matrix is an m multiplied by m matrix, m is the width of the image to be processed, the column matrix is an n multiplied by n matrix, n is the height of the image to be processed, the element of the jth row and the jth column in the row matrix and the column matrix is 1, the rest elements are 0, | i-j | ≦ s/2, and s is the width or the height of the sliding window; taking the product of the image to be processed and the row matrix as a first intermediate matrix, and taking the product of the first intermediate matrix and the column matrix as the mean matrix; and taking the product of the quadratic matrix and the row matrix as a second intermediate matrix, and taking the product of the second intermediate matrix and the column matrix as the variance matrix.
In a specific implementation, in order to ensure that the size of the resulting image is the same as that of the original image after the row operation and the column operation, it is necessary to perform filling in the width and height directions of the image to be processed respectively according to the size of the sliding window, where the number of rows or columns [ s/2] filled at each side is s is the width or height of the sliding window, and the filling value is 0. For example, if the height of the image to be processed is 8, the width is 10, and the size of the sliding window is 5 × 5, the size of the image after padding is 12 × 14.
The dimensions of the row matrix and the column matrix are m × m and n × n, respectively, m and n being the width and height of the image to be processed, respectively. The row matrix and the column matrix are matrixes with main diagonal symmetry, the element of the ith row and the jth column in the matrixes is 1, the rest elements are 0, and | i-j | is less than or equal to [ s/2 ]. In a specific implementation, the main diagonal line in the matrix is 1, and 1 is filled upwards and downwards respectively by taking the main diagonal line as a center, and the filling width does not exceed [ s/2 ]. In the above-mentioned example, the pixel points having coordinates (1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (2,4), etc. are 1, and the remaining pixel points are 0.
The result of multiplying the image to be processed by the row matrix is a row operation result, the result of multiplying the row operation result by the column matrix is a column operation result, and the column matrix operation result is an average value result. Taking a square value of each pixel point in the image to be processed to obtain a quadratic matrix, multiplying the quadratic matrix by the row matrix, and multiplying the quadratic matrix by the column matrix to obtain a variance matrix.
S102: calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix;
in the step, for each pixel point, the mean value of the pixel point is determined by using a mean matrix, the variance of the pixel point is determined by using a variance matrix, and the binarization threshold value corresponding to the pixel point is obtained by calculating based on the mean value and the variance.
Specifically, the method comprises the following steps: calculating a binarization threshold corresponding to each pixel point in the image to be processed based on a target formula; wherein the target formula is specifically:
Figure BDA0002266217520000061
wherein T is the binarization threshold, m is the mean value of the pixel points determined according to the mean matrix, S is the variance of the pixel points determined according to the variance matrix, k is a constant, and R is a preset gray level.
S103: and processing each pixel point by using the binarization threshold value to obtain a processed binarization image.
In this step, the pixel points of which the pixel values are greater than or equal to the corresponding binarization threshold value in the image to be processed are taken as the foreground, and the pixel points of which the pixel values are less than the corresponding binarization threshold value in the image to be processed are taken as the background, so as to obtain the processed binarization image.
According to the image processing method provided by the embodiment of the application, matrix correlation operation is introduced, the original operation of calculating the mean value and the variance of a single point based on the whole image is improved to the operation based on the whole image, and the efficiency of local self-adaptive threshold value binarization is improved.
The embodiment of the application discloses an image processing method, and compared with the previous embodiment, the embodiment further explains and optimizes the technical scheme. Specifically, the method comprises the following steps:
Referring to fig. 2, a flowchart illustrating another image processing method according to an exemplary embodiment, as shown in fig. 2, includes:
s201: acquiring an image to be processed, and determining a quadratic matrix, a row matrix and a column matrix corresponding to the image to be processed;
the row matrix is an m multiplied by m matrix, m is the width of the image to be processed, the column matrix is an n multiplied by n matrix, n is the height of the image to be processed, the element of the jth row and the jth column in the row matrix and the column matrix is 1, the rest elements are 0, | i-j | ≦ s/2, and s is the width or the height of the sliding window;
s202: taking the product of the image to be processed and the row matrix as a first intermediate matrix, and taking the product of the first intermediate matrix and the column matrix as the mean matrix;
s203: and taking the product of the quadratic matrix and the row matrix as a second intermediate matrix, and taking the product of the second intermediate matrix and the column matrix as the variance matrix.
S204: calculating a binarization threshold corresponding to each pixel point in the image to be processed based on a target formula;
wherein the target formula is specifically:
Figure BDA0002266217520000071
wherein T is the binarization threshold, m is the mean value of the pixel points determined according to the mean matrix, S is the variance of the pixel points determined according to the variance matrix, k is a constant, and R is a preset gray level.
S205: and taking the pixel points of which the pixel values are greater than or equal to the corresponding binarization threshold values in the image to be processed as a foreground, and taking the pixel points of which the pixel values are less than the corresponding binarization threshold values in the image to be processed as a background so as to obtain a processed binarization image.
Therefore, compared with the Sauvola algorithm based on single-point operation, the embodiment modifies the image into matrix operation based on the whole image based on single-point operation, calculates the square of the gray level in advance, calculates the row matrix and the column matrix corresponding to the image to be processed according to the size of the image to be processed and the size of the sliding window, then performs row operation and column operation on the whole image to obtain the mean value and the variance of each pixel point in the image to be processed at the self-adaptive window, then obtains the binarization threshold value of each pixel point, and finally obtains the final binarization result by directly comparing the pixel value of each pixel point in the image to be processed with the binarization threshold value corresponding to the pixel point. The whole operation is based on the whole image operation, and is based on the self-adaptive window when the mean value and the variance are calculated, so that the time complexity and the space complexity are low, and the running speed of the Sauvola algorithm is greatly increased.
An application example provided by the present application is described below, if the input to-be-processed image is as shown in fig. 3, the height is 8, the width is 10, and the size of the sliding window is 5 × 5. The image to be processed is first expanded to obtain an expanded image as shown in fig. 4, so as to perform mean and variance calculations.
Calculating a row matrix and a column matrix of the image to be processed by using the matlab algorithm as follows:
Figure BDA0002266217520000081
when the row matrix is calculated, S is the width of the image to be processed, namely 10, S is the width of the sliding window, namely 5, and the output m is the row matrix. When the column matrix is calculated, S is the height of the image to be processed, namely 8, S is the height of the sliding window, namely 5, and the output m is the column matrix. The calculated row matrix is shown in fig. 5 and the column matrix is shown in fig. 6.
The product of the image to be processed and the row matrix, i.e., the row operation result, is shown in fig. 7, the product of the row operation result and the column matrix, i.e., the column matrix operation result, is shown in fig. 8, and fig. 8 is the mean matrix.
Taking a square value of each pixel point in the image to be processed to obtain a quadratic matrix, multiplying the quadratic matrix by the row matrix, and multiplying the quadratic matrix by the column matrix to obtain a variance matrix.
And calculating a binarization threshold value of each pixel point in the image to be processed based on the mean matrix and the variance matrix, wherein if the pixel value is greater than or equal to the binarization threshold value, the pixel point is a foreground, and if the pixel value is less than the binarization threshold value, the pixel point is a background.
An image processing apparatus provided in an embodiment of the present application is described below, and an image processing apparatus described below and an image processing method described above may be referred to with each other.
Referring to fig. 9, a block diagram of an image processing apparatus according to an exemplary embodiment is shown, as shown in fig. 9, including:
an obtaining module 901, configured to obtain an image to be processed, and calculate a mean matrix and a variance matrix corresponding to the image to be processed according to a size of the image to be processed and a size of a sliding window;
a calculating module 902, configured to calculate a binarization threshold corresponding to each pixel in the image to be processed based on the mean matrix and the variance matrix;
and the processing module 903 is configured to process each pixel point by using the binarization threshold to obtain a processed binarization image.
The image processing device provided by the embodiment of the application introduces matrix correlation operation, improves the original operation of calculating the mean value and the variance of a single point based on the whole image into the operation based on the whole image, and improves the efficiency of local self-adaptive threshold value binarization.
On the basis of the foregoing embodiment, as a preferred implementation, the obtaining module 901 includes:
An acquisition unit for acquiring an image to be processed;
the determining unit is used for determining a quadratic matrix, a row matrix and a column matrix corresponding to the image to be processed; the row matrix is an m multiplied by m matrix, m is the width of the image to be processed, the column matrix is an n multiplied by n matrix, n is the height of the image to be processed, the element of the jth row and the jth column in the row matrix and the column matrix is 1, the rest elements are 0, | i-j | ≦ s/2, and s is the width or the height of the sliding window;
the first calculation unit is used for taking the product of the image to be processed and the row matrix as a first intermediate matrix and taking the product of the first intermediate matrix and the column matrix as the mean matrix;
and the second calculation unit is used for taking the product of the quadratic matrix and the row matrix as a second intermediate matrix and taking the product of the second intermediate matrix and the column matrix as the variance matrix.
On the basis of the foregoing embodiment, as a preferred implementation manner, the calculating module 902 is specifically a module that calculates a binarization threshold corresponding to each pixel point in the image to be processed based on a target formula; wherein the target formula is specifically:
Figure BDA0002266217520000101
Wherein T is the binarization threshold, m is the mean value of the pixel points determined according to the mean matrix, S is the variance of the pixel points determined according to the variance matrix, k is a constant, and R is a preset gray level.
On the basis of the foregoing embodiment, as a preferred implementation manner, the processing module 903 is specifically a module that takes pixel points in the to-be-processed image whose pixel values are greater than or equal to the corresponding binarization threshold as a foreground, and takes pixel points in the to-be-processed image whose pixel values are less than the corresponding binarization threshold as a background, so as to obtain a processed binarization image.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
The present application further provides an electronic device, and referring to fig. 10, a structure diagram of an electronic device provided in an embodiment of the present application may include a processor 11 and a memory 12, as shown in fig. 10. The electronic device may also include one or more of a multimedia component 13, an input/output (I/O) interface 14, and a communication component 15.
The processor 11 is configured to control the overall operation of the electronic device, so as to complete all or part of the steps in the image processing method. The memory 12 is used to store various types of data to support operation at the electronic device, which may include, for example, instructions for any application or method operating on the electronic device, as well as application-related data, such as contact data, messaging, pictures, audio, video, and so forth. The Memory 12 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as 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, magnetic disk or optical disk. The multimedia component 13 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 12 or transmitted via the communication component 15. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 14 provides an interface between the processor 11 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 15 is used for wired or wireless communication between the electronic device and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so that the corresponding Communication component 15 may include: Wi-Fi module, bluetooth module, NFC module.
In an exemplary embodiment, the electronic Device may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the image Processing method described above.
In another exemplary embodiment, there is also provided a computer-readable storage medium including program instructions which, when executed by a processor, implement the steps of the above-described image processing method. The computer readable storage medium may be, for example, the memory 12 described above comprising program instructions executable by the processor 11 of the electronic device to perform the image processing method described above.
The embodiments are described in a progressive mode in the specification, the emphasis of each embodiment is on the difference from the other embodiments, and the same and similar parts among the embodiments can be referred to each other. The device disclosed in the embodiment corresponds to the method disclosed in the embodiment, so that the description is simple, and the relevant points can be referred to the description of the method part. It should be noted that, for those skilled in the art, without departing from the principle of the present application, the present application can also make several improvements and modifications, and those improvements and modifications also fall into the protection scope of the claims of the present application.
It should also be noted that, in this specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.

Claims (6)

1. An image processing method, characterized by comprising:
acquiring an image to be processed, and calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of a sliding window;
calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix;
Processing each pixel point by utilizing the binarization threshold value to obtain a processed binarization image;
wherein, the calculating the mean matrix and the variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of the sliding window comprises:
determining a quadratic matrix, a row matrix and a column matrix corresponding to the image to be processed; wherein, taking a square value of each pixel point in the image to be processed to obtain the quadratic matrix, the row matrix is an m × m matrix, m is the width of the image to be processed, the column matrix is an n × n matrix, n is the height of the image to be processed, the elements of the ith row and the jth column in the row matrix and the column matrix are 1, and the rest elements are 0,
Figure DEST_PATH_IMAGE002
and s is the width or height of the sliding window;
taking the product of the image to be processed and the row matrix as a first intermediate matrix, and taking the product of the first intermediate matrix and the column matrix as the mean matrix;
taking a product of the quadratic matrix and the row matrix as a second intermediate matrix, and taking a product of the second intermediate matrix and the column matrix as the variance matrix;
Calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix, wherein the calculating comprises:
calculating a binarization threshold corresponding to each pixel point in the image to be processed based on a target formula; wherein the target formula is specifically:
Figure DEST_PATH_IMAGE004
wherein T is the binarization threshold, m is the mean value of the pixel points determined according to the mean matrix, S is the variance of the pixel points determined according to the variance matrix, k is a constant, and R is a preset gray level.
2. The image processing method according to claim 1, wherein said processing each of said pixel points by using said binarization threshold to obtain a processed binarization image comprises:
and taking the pixel points of which the pixel values are greater than or equal to the corresponding binarization threshold values in the image to be processed as a foreground, and taking the pixel points of which the pixel values are less than the corresponding binarization threshold values in the image to be processed as a background so as to obtain a processed binarization image.
3. An image processing apparatus characterized by comprising:
the acquisition module is used for acquiring an image to be processed and calculating a mean matrix and a variance matrix corresponding to the image to be processed according to the size of the image to be processed and the size of the sliding window;
The calculation module is used for calculating a binarization threshold corresponding to each pixel point in the image to be processed based on the mean matrix and the variance matrix;
the processing module is used for processing each pixel point by using the binarization threshold value to obtain a processed binarization image;
wherein the acquisition module comprises:
the acquisition unit is used for acquiring an image to be processed;
the determining unit is used for determining a quadratic matrix, a row matrix and a column matrix corresponding to the image to be processed; wherein, taking a square value of each pixel point in the image to be processed to obtain the quadratic matrix, the row matrix is an m × m matrix, m is the width of the image to be processed, the column matrix is an n × n matrix, n is the height of the image to be processed, the elements of the ith row and the jth column in the row matrix and the column matrix are 1, and the rest elements are 0,
Figure DEST_PATH_IMAGE005
and s is the width or height of the sliding window;
the first calculation unit is used for taking the product of the image to be processed and the row matrix as a first intermediate matrix and taking the product of the first intermediate matrix and the column matrix as the mean matrix;
a second calculation unit configured to use a product of the quadratic matrix and the row matrix as a second intermediate matrix, and use a product of the second intermediate matrix and the column matrix as the variance matrix;
The calculation module is specifically a module for calculating a binarization threshold corresponding to each pixel point in the image to be processed based on a target formula; wherein the target formula is specifically:
Figure 80807DEST_PATH_IMAGE004
wherein T is the binarization threshold, m is the mean value of the pixel points determined according to the mean matrix, S is the variance of the pixel points determined according to the variance matrix, k is a constant, and R is a preset gray level.
4. The image processing apparatus according to claim 3, wherein the processing module is specifically a module that takes pixel points in the image to be processed whose pixel values are greater than or equal to the corresponding binarization threshold as a foreground, and takes pixel points in the image to be processed whose pixel values are less than the corresponding binarization threshold as a background, so as to obtain the processed binarization image.
5. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the image processing method as claimed in claim 1 or 2 when executing said computer program.
6. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the image processing method as claimed in claim 1 or 2.
CN201911088672.1A 2019-11-08 2019-11-08 Image processing method and device, electronic equipment and storage medium Active CN110992387B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911088672.1A CN110992387B (en) 2019-11-08 2019-11-08 Image processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911088672.1A CN110992387B (en) 2019-11-08 2019-11-08 Image processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110992387A CN110992387A (en) 2020-04-10
CN110992387B true CN110992387B (en) 2022-06-10

Family

ID=70083648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911088672.1A Active CN110992387B (en) 2019-11-08 2019-11-08 Image processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110992387B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113034389B (en) * 2021-03-17 2023-07-25 武汉联影智融医疗科技有限公司 Image processing method, device, computer equipment and storage medium
CN112967331B (en) * 2021-03-25 2021-12-17 北京的卢深视科技有限公司 Image processing method, electronic equipment and storage medium

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100561504C (en) * 2005-12-22 2009-11-18 佳能株式会社 The self-adaption binaryzation method of document and equipment
US8947736B2 (en) * 2010-11-15 2015-02-03 Konica Minolta Laboratory U.S.A., Inc. Method for binarizing scanned document images containing gray or light colored text printed with halftone pattern
US9025897B1 (en) * 2013-04-05 2015-05-05 Accusoft Corporation Methods and apparatus for adaptive auto image binarization
CN104200211A (en) * 2014-09-03 2014-12-10 腾讯科技(深圳)有限公司 Image binaryzation method and device
CN105608708A (en) * 2016-03-02 2016-05-25 浙江宇视科技有限公司 Block plane fitting-based image binaryzation method and device
CN106529534A (en) * 2016-11-07 2017-03-22 湖南源信光电科技有限公司 Variable-length license plate character segmentation method based on hybrid tilt correction and projection method
CN106772379B (en) * 2017-03-22 2019-08-02 西安电子科技大学 Two-parameter CFAR Ship Detection based on Fourier transformation
CN107610132B (en) * 2017-08-28 2021-12-31 西北民族大学 Method for removing stains from ancient book document image
CN107945200B (en) * 2017-12-14 2021-08-03 中南大学 Image binarization segmentation method
CN108509819A (en) * 2018-03-07 2018-09-07 中山大学 A kind of Quick Response Code binarization method even for uneven illumination
CN108763997A (en) * 2018-04-13 2018-11-06 广州中大微电子有限公司 A kind of Quick Response Code noise-reduction method and system based on crisscross quick binaryzation
CN108960259A (en) * 2018-07-12 2018-12-07 浙江工业大学 A kind of license plate preprocess method based on HSV

Also Published As

Publication number Publication date
CN110992387A (en) 2020-04-10

Similar Documents

Publication Publication Date Title
CN108229360B (en) Image processing method, device and storage medium
CN108885787B (en) Method for training image restoration model, image restoration method, device, medium, and apparatus
CN109035158B (en) Image blurring processing method, image blurring processing device, storage medium and electronic equipment
CN108986100B (en) Image cutting method and device
CN108875519B (en) Object detection method, device and system and storage medium
CN110992387B (en) Image processing method and device, electronic equipment and storage medium
CN109658346B (en) Image restoration method and device, computer-readable storage medium and electronic equipment
CN109492531B (en) Face image key point extraction method and device, storage medium and electronic equipment
KR102389766B1 (en) Image processing method and apparatus, electronic device and storage medium
US20230122927A1 (en) Small object detection method and apparatus, readable storage medium, and electronic device
CN111145202B (en) Model generation method, image processing method, device, equipment and storage medium
CN111709415B (en) Target detection method, device, computer equipment and storage medium
CN115456167A (en) Lightweight model training method, image processing device and electronic equipment
CN108596120B (en) Target detection method and device based on deep learning
CN112561050A (en) Neural network model training method and device
CN117349671A (en) Model training method and device, storage medium and electronic equipment
CN111860287A (en) Target detection method and device and storage medium
CN107977923B (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN110633595B (en) Target detection method and device by utilizing bilinear interpolation
CN110809083B (en) Mobile terminal information reminding method, mobile terminal and storage medium
CN116483313A (en) Information processing method, information processing device, electronic equipment and computer readable storage medium
CN113706428B (en) Image generation method and device
CN113807407B (en) Target detection model training method, model performance detection method and device
CN113361719B (en) Incremental learning method and image processing method based on image processing model
CN113361703B (en) Data processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant