CN107292840B - Image restoration method and device, computer-readable storage medium and terminal - Google Patents

Image restoration method and device, computer-readable storage medium and terminal Download PDF

Info

Publication number
CN107292840B
CN107292840B CN201710424945.XA CN201710424945A CN107292840B CN 107292840 B CN107292840 B CN 107292840B CN 201710424945 A CN201710424945 A CN 201710424945A CN 107292840 B CN107292840 B CN 107292840B
Authority
CN
China
Prior art keywords
pixel
image
pixel value
neighborhood
pixels
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
CN201710424945.XA
Other languages
Chinese (zh)
Other versions
CN107292840A (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.)
Shanghai Zhizhen Intelligent Network Technology Co Ltd
Original Assignee
Shanghai Zhizhen Intelligent Network Technology 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 Shanghai Zhizhen Intelligent Network Technology Co Ltd filed Critical Shanghai Zhizhen Intelligent Network Technology Co Ltd
Priority to CN201710424945.XA priority Critical patent/CN107292840B/en
Publication of CN107292840A publication Critical patent/CN107292840A/en
Application granted granted Critical
Publication of CN107292840B publication Critical patent/CN107292840B/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
    • G06T5/00Image enhancement or restoration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/23Clustering techniques
    • G06F18/232Non-hierarchical techniques
    • G06F18/2321Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
    • G06F18/23213Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions with fixed number of clusters, e.g. K-means clustering

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Probability & Statistics with Applications (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

An image restoration method and device, a computer-readable storage medium and a terminal, wherein the image restoration method comprises the following steps: acquiring an image to be processed; for each pixel in the image, carrying out fuzzy clustering processing by using the pixel values of the pixels in the neighborhood of the pixel so as to determine the category of each pixel and the category pixel value corresponding to each category; and assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category to obtain the restored image. The technical scheme of the invention can improve the image restoration effect.

Description

Image restoration method and device, computer-readable storage medium and terminal
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to an image restoration method and apparatus, a computer-readable storage medium, and a terminal.
Background
At present, in the field of image processing, when an acquired original image is processed, the defect or the surplus of a target in the original image causes difficulty in image recognition and influences an image processing output result. For example, in the scenes of text recognition and license plate recognition, the situation that the Chinese characters and the numbers are defective can cause errors in text recognition or license plate recognition.
In the prior art, there are many image restoration methods, and the model proposed earlier is a model based on partial differential equation, and is mainly used for restoration of a small area. In the later stage, scholars at home and abroad propose an image restoration technology based on a texture structure, which is mainly used for filling large lost information in an image.
However, the prior art has a poor effect on image restoration, and the image restoration effect still needs to be improved.
Disclosure of Invention
The technical problem solved by the invention is how to improve the image restoration effect.
To solve the above technical problem, an embodiment of the present invention provides an image restoration method, where the image restoration method includes: acquiring an image to be processed; for each pixel in the image, carrying out fuzzy clustering processing by using the pixel values of the pixels in the neighborhood of the pixel so as to determine the category of each pixel and the category pixel value corresponding to each category; and assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category to obtain the restored image.
Optionally, the performing, by using the pixel values of the neighboring pixels, a fuzzy clustering process on each pixel in the image includes: updating the pixel value of each pixel by using neighborhood information of each pixel, wherein the neighborhood information comprises neighborhood gray scale information and neighborhood distance information; and carrying out fuzzy clustering processing by using the updated pixel values.
Optionally, before performing the fuzzy clustering process on each pixel in the image by using the pixel values of the neighboring pixels, the method further includes: the image is pre-processed according to a predetermined classification of the image, the classification being selected from a defect classification and a redundant classification.
Optionally, before performing the fuzzy clustering process on each pixel in the image by using the pixel values of the neighboring pixels, the method further includes: and determining the classification of the image as a defect classification, and performing expansion operation and then corrosion operation on the image.
Optionally, before performing the fuzzy clustering process on each pixel in the image by using the pixel values of the neighboring pixels, the method further includes: and determining the classification of the image as redundant classification, and performing corrosion operation and then expansion operation on the image.
Optionally, the performing, by using the pixel values of the neighboring pixels, a fuzzy clustering process on each pixel in the image includes: determining the initial membership of each pixel in the image relative to each class and the initial clustering center of each class; iteratively calculating a new clustering center and a new membership degree of each pixel based on the current clustering center and the current membership degree by utilizing the pixel value of the neighborhood pixel of each pixel in the neighborhood window until the iteration times reach the maximum iteration times, or the maximum value of the difference value between the new membership degree of all the pixels and the current membership degree is smaller than a set threshold value; and determining the class of each pixel according to the new membership degree of each pixel determined by the last iteration, and determining the class pixel value corresponding to each class according to the new clustering center of each class determined by the last iteration.
Optionally, the following formula is used to calculate the new membership degree of each pixel:
Figure GDA0002289054220000021
Figure GDA0002289054220000022
wherein, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiIs the pixel value of pixel i, vkThe pixel value of a clustering center k, m is a preset fuzzy index, c is the number of the clustering centers, W1 and W2 are pixel information of neighborhood pixels of a pixel i, and the pixel information of the neighborhood pixels is determined according to the pixel value and the position of the neighborhood pixels.
Optionally, the new cluster center is calculated by using the following formula:
Figure GDA0002289054220000023
wherein v isiterThe new clustering center k at iter iteration, N is the total number of pixels in the image, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiW1 is pixel information of a neighborhood pixel of the pixel i, which is determined according to the pixel value and the position of the neighborhood pixel.
Optionally, the image is a grayscale image, the pixel value of the pixel of the target portion in the image is within a first pixel value range, and the pixel value of the pixel of the background portion is within a second pixel value range, where the first pixel value range and the second pixel value range are adjacent domains; the determining that the classification of the image is defect classification, and performing expansion operation and then corrosion operation on the image comprises the following steps: transversely scanning the image, determining a first position of a pixel value which is changed from the first pixel value range to the second pixel value range, and determining a second position of the pixel value which is changed from the second pixel value range to the first pixel value range; longitudinally and bidirectionally scanning from the middle position between the first position and the second position, and determining a third position and a fourth position of a pixel value which is changed from the second pixel value range to the first pixel value range; and if the distance between the first position and the second position is greater than a minimum transverse threshold and less than a maximum transverse threshold, and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold, performing expansion operation on the image, and then performing erosion operation on the image.
Optionally, the image is a grayscale image, the pixel value of the pixel of the target portion in the image is within a first pixel value range, and the pixel value of the pixel of the background portion is within a second pixel value range; wherein the first pixel value range and the second pixel value range are adjacent domains, the determining that the classification of the image is redundant classification, and performing the erosion operation and then the expansion operation on the image comprises: transversely scanning the image, determining a first position of a pixel value which is changed from the second pixel value range to the first pixel value range, and determining a second position of the pixel value which is changed from the first pixel value range to the second pixel value range; longitudinally and bidirectionally scanning from the middle position between the first position and the second position, and determining a third position and a fourth position of a pixel value which is changed from the first pixel value range to the second pixel value range; and if the distance between the first position and the second position is greater than a minimum transverse threshold and less than a maximum transverse threshold, and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold, performing erosion operation on the image, and then performing expansion operation on the image.
Optionally, the grayscale image is a binary image, the first pixel value range is a first pixel value, and the second pixel value range is a second pixel value.
Optionally, the size of the neighborhood window of the neighborhood pixels is determined according to the following parameters: a distance between the first and second positions and a distance between the third and fourth positions.
Optionally, the acquiring the image to be processed includes: the method comprises the steps of dividing an original image into single-character images, wherein the original image comprises at least one character, and the character is selected from Chinese characters, letters and numbers.
Optionally, after acquiring the image to be processed, the method further includes: and if the image is a color image, converting the image into a gray scale image.
The embodiment of the invention also discloses an image restoration device, which comprises: the image acquisition module is used for acquiring an image to be processed; the fuzzy clustering module is used for carrying out fuzzy clustering processing on each pixel in the image by using the pixel values of the adjacent pixels so as to determine the category of each pixel and the category pixel value corresponding to each category; and the assignment module is used for assigning the pixel values of all the pixels in the same category to the category pixel values corresponding to the category so as to obtain the restored image.
The embodiment of the invention also discloses a computer readable storage medium, wherein computer instructions are stored on the computer readable storage medium, and the computer instructions execute the steps of the image restoration method when running.
The embodiment of the invention also discloses a terminal which comprises a memory and a processor, wherein the memory is stored with a computer instruction capable of running on the processor, and the processor executes the steps of the image restoration method when running the computer instruction.
Compared with the prior art, the technical scheme of the embodiment of the invention has the following beneficial effects:
the technical scheme of the invention is that an image to be processed is obtained; for each pixel in the image, carrying out fuzzy clustering processing by using the pixel values of the pixels in the neighborhood of the pixel so as to determine the category of each pixel and the category pixel value corresponding to each category; and assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category to obtain the restored image. The technical scheme of the invention utilizes the pixel value of each pixel neighborhood pixel in the image to be processed to carry out fuzzy clustering processing on each pixel; by utilizing the neighborhood pixels of each pixel to carry out fuzzy clustering, the defective or redundant pixels in the image to be processed can be accurately classified; and then assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category, namely accurately determining the original pixel values of all the pixels in the image to be processed, completing the restoration of the image to be processed, realizing the accuracy of restoration of the image to be processed, and further improving the effect of image restoration.
Further, the performing fuzzy clustering processing on each pixel in the image by using the pixel values of the neighboring pixels comprises: updating the pixel value of each pixel by using neighborhood information of each pixel, wherein the neighborhood information comprises neighborhood gray scale information and neighborhood distance information; and carrying out fuzzy clustering processing by using the updated pixel values. When each pixel neighborhood pixel is used for fuzzy clustering, the neighborhood information of the neighborhood pixel is used for updating the pixel value of the pixel, and then the updated pixel value is used for fuzzy clustering; therefore, when fuzzy clustering is carried out, neighborhood information of the pixel can be taken into consideration, the accuracy of the classification of the pixel is realized, the original pixel value of the pixel can be accurately determined, and the image repairing effect is further improved.
Drawings
FIG. 1 is a flow chart of a method for restoring an image according to an embodiment of the present invention;
FIG. 2 is a flowchart of an implementation of step S102 shown in FIG. 1;
fig. 3 is a schematic structural diagram of an image restoration apparatus according to an embodiment of the present invention.
Detailed Description
As described in the background, the prior art needs to improve the effect of image restoration.
The technical scheme of the invention utilizes the pixel value of each pixel neighborhood pixel in the image to be processed to carry out fuzzy clustering processing on each pixel; by utilizing the neighborhood pixels of each pixel to carry out fuzzy clustering, the defective or redundant pixels in the image to be processed can be accurately classified, namely the original pixels of the pixels are accurately determined; and then assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category, completing the restoration of the image to be processed, and realizing the accuracy of the restoration of the image to be processed, thereby improving the effect of image restoration.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
Fig. 1 is a flowchart of an image restoration method according to an embodiment of the present invention.
The image restoration method shown in fig. 1 may include the steps of:
step S101: acquiring an image to be processed;
step S102: for each pixel in the image, carrying out fuzzy clustering processing by using the pixel values of the pixels in the neighborhood of the pixel so as to determine the category of each pixel and the category pixel value corresponding to each category;
step S103: and assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category to obtain the restored image.
In a specific implementation, in step S101, an image to be processed is obtained, and specifically, the image to be processed may be an image directly acquired by using an image sensor or other suitable means, or may be a pre-processed image. The image to be processed refers to an image in which an object in the image has a defective or unnecessary portion. For example, the objects in the image to be processed may be numbers, numbers with defects, or with redundant dots, bars, or columns. Further, the restoration of the image to be processed is to restore the pixel values of the pixels occupied by the defective or redundant portions, so as to fill up the defective portions or remove the redundant portions.
In a specific implementation, in order to restore an image to be processed, it is necessary to accurately restore pixel values of pixels occupied by defective or redundant portions, and the pixel value to be restored of each pixel may be determined by pixel values of pixels in the neighborhood of the pixel. In step S102, each pixel in the image is subjected to fuzzy clustering processing using the pixel values of the pixels in the neighborhood thereof to determine the category to which each pixel belongs and the category pixel value corresponding to each category. Specifically, when all pixels in an image are clustered, the pixel value of the neighborhood pixel of each pixel is used as a consideration factor to influence the clustering result, that is, the category to which each pixel belongs and the category pixel value corresponding to each category are influenced, so that the accuracy of classifying the pixels into the category to which the pixel value to be recovered is located is improved.
It should be understood by those skilled in the art that any implementable algorithm may be used to implement the fuzzy clustering process, and the embodiment of the present invention is not limited thereto.
Further, in step S103, the pixel values of all the pixels in the same category are assigned as the category pixel values corresponding to the category. Specifically, after obtaining the clustering result of the fuzzy clustering, the clustering result may include the category, the category pixel value, and all the pixels in each category. And if the pixel belongs to a certain class and the probability that the pixel belongs to the class of pixel values is the maximum, assigning the class pixel value corresponding to the class to the pixel. That is, the class pixel value corresponding to the class to which the pixel belongs is the pixel value of the pixel. So far, restoration of pixel values of all pixels in the image to be processed has been achieved.
The embodiment of the invention can accurately classify the defective or redundant pixels in the image to be processed, i.e. accurately determine the original pixels of the pixels; and then assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category, completing the restoration of the image to be processed, and realizing the accuracy of the restoration of the image to be processed, thereby improving the effect of image restoration.
Preferably, step S102 may include the steps of: updating the pixel value of each pixel by using neighborhood information of each pixel, wherein the neighborhood information comprises neighborhood gray scale information and neighborhood distance information; and carrying out fuzzy clustering processing by using the updated pixel values.
In this embodiment, when performing fuzzy clustering on a pixel by using a neighborhood pixel, the pixel value of the pixel may be updated by using neighborhood information of each pixel, where the neighborhood information may refer to information of the neighborhood pixel, the neighborhood grayscale information may refer to a grayscale value of the neighborhood pixel, and the neighborhood distance information may refer to a distance between the neighborhood pixel and the pixel.
Specifically, when the pixel value of the pixel is updated, the neighborhood information of each pixel may be used as a weight to be multiplied by the pixel value of the pixel, and the obtained product may be used as the updated pixel value; alternatively, the neighborhood information of each pixel may be added to the pixel value of the pixel, and the resulting addition result may be used as the updated pixel value; alternatively, a combination of weighting and summing may be used, and the embodiment of the present invention is not limited to this.
Preferably, step S102 may further include the following steps: the image is pre-processed according to a predetermined classification of the image, the classification being selected from a defect classification and a redundant classification.
In this embodiment, the classification of the image may be predetermined, and corresponding preprocessing may be performed according to the classification of the image. Wherein, the defect classification means that the target in the image has defects and is incomplete; redundant classification refers to the existence of redundancy in objects in an image. Because the defective part and the redundant part of the image of the defective classification and the redundant classification account for different pixel values of the pixels, different preprocessing processes are required to be carried out so as to improve the accuracy of the subsequent clustering process.
Preferably, step S102 may further include the following steps: and determining the classification of the image as a defect classification, and performing expansion operation and then corrosion operation on the image.
In this embodiment, the erosion operation may refer to scanning each pixel in the image by using a structural element (i.e., an operand matrix), for example, a matrix of 3 × 3 size, scanning each pixel in the image by using the matrix, and performing an and operation on each pixel in the operand matrix and the covered pixels, for example, taking a binary image as an example, if the and operation results are all 1, the pixel in the image is 1, and otherwise, the and operation result is 0; in contrast to the dilation operation, if the operation results are all 0, the pixel in the image pixel is 0, and otherwise is 1. The erosion operation can eliminate the boundary points of the target in the image and shrink the target, so the erosion operation can eliminate small and meaningless pixel points and shrink the boundary inwards. Conversely, the dilation operation may enlarge the target, fill fine voids within the target, and smooth the boundary of the target, expanding the boundary outward.
In particular, the boundary of the object in the image is often very uneven due to the influence of noise, so the object region has some noise holes. When the image is classified into a defect classification, the image is firstly subjected to expansion operation and then corrosion operation, so that fine noise holes in the target in the image can be filled, and the boundary of the target is smoothed. Specifically, the dilation operation may cause the boundary of the target to expand outward, and if there are noise holes inside the target, the noise holes will be complemented by the dilation operation and thus no longer be the boundary. When the etching operation is performed again, the outer boundary of the target returns to the original state, and the internal noise holes do not exist.
Preferably, step S102 may further include the following steps: and determining the classification of the image as redundant classification, and performing corrosion operation and then expansion operation on the image.
In this embodiment, the boundary of the object in the image is often not smooth due to the influence of noise, so the background area in the image is scattered by some small noise objects. When the image is classified into redundant classification, the image is firstly subjected to corrosion operation and then expansion operation, so that fine noise on the image can be eliminated, and the boundary of the target is smoothed. Specifically, the erosion operation removes edge points of the target, and small noise targets are considered edge points and are therefore eliminated. When the dilation operation is performed again, the remaining targets will return to their original size, while the removed small noisy targets will not exist.
It will be understood by those skilled in the art that the continuous etching operation and the expanding operation, or the continuous expanding operation and the etching operation, can achieve better pretreatment effect, so the number of etching operations and/or expanding operations can be one or more, and the embodiment is not limited thereto.
Further, the image to be processed may be a grayscale image, the pixel value of the pixel of the target portion in the image is within a first pixel value range, and the pixel value of the pixel of the background portion is within a second pixel value range, where the first pixel value range and the second pixel value range are adjacent domains. The expanding operation and then the etching operation on the image may include the steps of: transversely scanning the image, determining a first position of a pixel value which is changed from the first pixel value range to the second pixel value range, and determining a second position of the pixel value which is changed from the second pixel value range to the first pixel value range; longitudinally and bidirectionally scanning from the middle position between the first position and the second position, and determining a third position and a fourth position of a pixel value which is changed from the second pixel value range to the first pixel value range; if the distance between the first position and the second position is greater than the minimum transverse threshold and less than the maximum transverse threshold (which may also include the case where the distance between the first position and the second position is equal to the minimum transverse threshold or equal to the maximum transverse threshold), and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include the case where the distance between the third position and the fourth position is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold), the image is first dilated and then eroded.
In this embodiment, the image is classified into a defect, the inside of the defect is a background portion, and the outside is a back target portion. And determining a first position, a second position, a third position and a fourth position according to the change of the pixel value in the first pixel value range and the second pixel value range by scanning the image. That is, when the image is classified as a defect classification, the defect region in the image is determined by the first position, the second position, the third position, and the fourth position. Only when the defect area reaches a set size, that is, the distance between the first position and the second position is greater than the minimum transverse threshold and less than the maximum transverse threshold (which may also include a case where the distance between the first position and the second position is equal to the minimum transverse threshold or equal to the maximum transverse threshold), and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include a case where the distance between the third position and the fourth position is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold), the defect area is determined as being defective in the target in the image, so as to eliminate noise in the image or avoid determining the background portion as a defective portion.
In a specific application scenario of the present invention, an image to be processed is a binary image, a pixel value of a pixel of a target portion in the image is 1, and a pixel value of a pixel of a background portion is 0. Performing an erosion operation and then performing an expansion operation on the image may include the steps of: scanning the image transversely, determining a first position where the pixel value is changed from 1 to 0, and determining a second position where the pixel value is changed from 0 to 1; longitudinally and bidirectionally scanning from a middle position between the first position and the second position, and determining a third position and a fourth position of which the pixel value is changed from 0 to 1; and if the distance between the first position and the second position is greater than a minimum transverse threshold and less than a maximum transverse threshold, and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold, performing expansion operation on the image, and then performing erosion operation on the image. It can be understood that, when the pixel value of the pixel of the target portion in the image is 0 and the pixel value of the pixel of the background portion is 1, performing the erosion operation on the image first, and then performing the dilation operation may refer to the above description, and details are not repeated herein.
Further, the image to be processed may be a grayscale image, the pixel value of the pixel of the target portion in the image is within a first pixel value range, and the pixel value of the pixel of the background portion is within a second pixel value range, where the first pixel value range and the second pixel value range are adjacent domains. Performing an erosion operation on the image and then performing an expansion operation may include the steps of: transversely scanning the image, determining a first position of a pixel value which is changed from the second pixel value range to the first pixel value range, and determining a second position of the pixel value which is changed from the first pixel value range to the second pixel value range; longitudinally and bidirectionally scanning from the middle position between the first position and the second position, and determining a third position and a fourth position of a pixel value which is changed from the first pixel value range to the second pixel value range; if the distance between the first position and the second position is greater than the minimum transverse threshold and less than the maximum transverse threshold (which may also include the case where the distance between the first position and the second position is equal to the minimum transverse threshold or equal to the maximum transverse threshold), and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include the case where the distance between the third position and the fourth position is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold), then performing a erosion operation and then performing a dilation operation on the image.
Unlike the foregoing embodiment, the image in this embodiment is an unnecessary classification, and the inside of the unnecessary portion is a target portion and the outside is a background portion. Because the pixel value of the pixel of the target part is in the first pixel value range and the pixel value of the pixel of the background part is in the second pixel value range, when the first position, the second position, the third position and the fourth position are determined by scanning an image, the position of the pixel value changed from the second pixel value range to the first pixel value range is determined as the first position, and the other positions are determined in the same way. And further determining whether the redundant area reaches a set size, that is, whether the distance between the first position and the second position is greater than the minimum transverse threshold and less than the maximum transverse threshold (which may also include a case where the distance between the first position and the second position is equal to the minimum transverse threshold or equal to the maximum transverse threshold), and when the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include a case where the distance between the third position and the fourth position is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold), determining that the redundant area is redundant for the target in the image, so as to eliminate noise in the image or avoid determining the target portion as the redundant portion.
In a specific application scenario of the present invention, an image to be processed is a binary image, a pixel value of a pixel of a target portion in the image is 1, and a pixel value of a pixel of a background portion is 0. Further, the image may be scanned laterally, a first location where the pixel value changes from 0 to 1 is determined, a second location where the pixel value changes from 1 to 0 is determined; and longitudinally and bidirectionally scanning from the middle position of the first position and the second position, and determining a third position and a fourth position of which the pixel value is changed from 1 to 0. It can be understood that, when the pixel value of the pixel of the target portion in the image is 0 and the pixel value of the pixel of the background portion is 1, the specific manner of determining the first position, the second position, the third position, and the fourth position may refer to the above description, and details are not repeated here.
More further, the grayscale image is a binary image, the first pixel value range is a first pixel value, and the second pixel value range is a second pixel value. In this embodiment, when the image to be processed is a binary image, when determining the boundary position of the defect region or the redundant region, it is only necessary to determine whether the change of the pixel value is changed from the first pixel value to the second pixel value, or whether the change of the pixel value is changed from the second pixel value to the first pixel value, so that the calculation amount can be reduced. In addition, when the image to be processed is a binary image and the image to be processed is subjected to fuzzy clustering, the number of the categories is two, and the clustering centers are respectively a pixel value 0 and a pixel value 1, so that the calculation amount in the image restoration process is further reduced, and the convenience of the image restoration method is improved.
More closely, the size of the neighborhood window of the neighborhood pixels is determined according to the following parameters: a distance between the first and second positions and a distance between the third and fourth positions.
In this embodiment, in order to determine the neighborhood pixels of each pixel, it may be implemented by setting a neighborhood window. When the pixel is in the center position of the neighborhood window, the pixels in other positions in the neighborhood window are the neighborhood pixels of the pixel. In order to give consideration to the accuracy and the calculated amount of fuzzy clustering and ensure that a proper number of neighborhood pixels are selected, the size of a neighborhood window is configured as follows: the size of the neighborhood window is determined according to the following parameters: a distance between the first and second positions and a distance between the third and fourth positions. In other words, the distance between the first position and the second position and the distance between the third position and the fourth position may represent the size of the defect region or the redundant region, and the size of the neighborhood window may be configured according to the size of the defect region or the redundant region.
Referring to fig. 2, fig. 2 is a flowchart illustrating an implementation of step S102 shown in fig. 1, where step S102 may include the following steps:
step S21: determining the initial membership of each pixel in the image relative to each class and the initial clustering center of each class;
step S22: iteratively calculating a new clustering center and a new membership degree of each pixel based on the current clustering center and the current membership degree by utilizing the pixel value of the neighborhood pixel of each pixel in the neighborhood window until the iteration times reach the maximum iteration times, or the maximum value of the difference value between the new membership degree of all the pixels and the current membership degree is smaller than a set threshold value;
step S23: and determining the class of each pixel according to the new membership degree of each pixel determined by the last iteration, and determining the class pixel value corresponding to each class according to the new clustering center of each class determined by the last iteration.
In this embodiment, when performing fuzzy clustering, the initial membership and the initial clustering center are determined in step S21. Specifically, the total number of categories c is predetermined. For example, when the image is a binary image, the total number of categories c is 2 because the pixel values are only 0 and 1. For each pixel's c initial degrees of membership to the respective class, a random number between 0 and 1 may be used. And then calculating according to the initial membership degree to obtain an initial clustering center. Or, for the initial clustering centers of the c categories, the initial clustering centers can be obtained by randomly selecting the pixel values of all pixels in the image, and then the initial clustering centers are used for calculating the initial membership degree. Wherein the cluster center may be a pixel value.
It is to be understood that any implementable formula may be used to calculate the initial clustering center according to the initial membership, or calculate the initial membership according to the initial clustering center, which is not limited in this embodiment of the present invention.
Further, in step S22, a neighborhood pixel of each pixel may be selected through the neighborhood window, that is, when the pixel is located at the center of the neighborhood window, other pixels located in the neighborhood window are the neighborhood pixels of the pixel. And iteratively calculating a new clustering center and a new membership degree of each pixel by using the pixel value of the neighborhood pixel, the current clustering center and the current membership degree until an iteration stop condition is reached. The iteration stopping condition means that the iteration times reach the maximum iteration times, or the maximum value of the difference value between the new membership degree of all the pixels and the current membership degree is smaller than a set threshold. Further, after each iteration is completed, a plurality of new membership degrees and current membership degree difference values are provided, and the iterative computation is stopped only when the maximum value of the plurality of new membership degree and current membership degree difference values is smaller than a set threshold value, so that the computation amount can be reduced.
Further, in step S23, after the last iteration is completed, each pixel has c new membership degrees corresponding to the c classes, and the class corresponding to the maximum value of the c new membership degrees is selected as the class to which the pixel belongs. After the last iteration is completed, a new clustering center of each category can be determined, and the pixel value corresponding to the new clustering center is the category pixel value corresponding to the category.
Further, the new degree of membership for each pixel may be calculated using the following formula:
Figure GDA0002289054220000121
Figure GDA0002289054220000122
wherein, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiIs the pixel value of pixel i, vkThe pixel value of a clustering center k, m is a preset fuzzy index, c is the number of the clustering centers, W1 and W2 are pixel information of neighborhood pixels of a pixel i, and the pixel information of the neighborhood pixels is determined according to the pixel value and the position of the neighborhood pixels.
In this embodiment, when the neighborhood information of each pixel is used to update the pixel value of the pixel, the membership degree is calculated by means of weighting and summing. It is also possible to use only the pixel information W1 or W2 of the neighborhood pixels of the pixel i.
It is to be understood that the pixel information W1 and W2 of the neighborhood pixels of the pixel i may be determined from the pixel values and positions of the neighborhood pixels using any practicable algorithm. For example,
Figure GDA0002289054220000131
Figure GDA0002289054220000132
where N is the total number of pixels in the image, xrA pixel value of a neighborhood pixel of pixel i; the pixel information W2 of the neighboring pixel may represent the similarity of the pixel i and its neighboring pixel, and the calculation formula is as follows:
Figure GDA0002289054220000133
wherein x isrσ is a preset coefficient, and is a pixel value of a neighborhood pixel of the pixel i.
Further, the new cluster center may be calculated using the following formula:
Figure GDA0002289054220000134
Figure GDA0002289054220000135
wherein v isiterThe new clustering center k at iter iteration, N is the total number of pixels in the image, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiW1 is pixel information of a neighborhood pixel of the pixel i, which is determined according to the pixel value and the position of the neighborhood pixel.
During iteration, the embodiment adopts a mode of firstly calculating the new membership degree and then calculating the new clustering center. Or a mode of calculating a new clustering center and then calculating a new membership degree can be adopted.
Preferably, step S101 may include the steps of: the method comprises the steps of dividing an original image into single-character images, wherein the original image comprises at least one character, and the character is selected from Chinese characters, letters and numbers. In this embodiment, when the target in the image to be processed is a character, such as a chinese character, a number, an english letter, and the like, in order to ensure accuracy and rapidity of image restoration, the original image may be divided into single character images, so as to avoid influence of other characters on the character to be restored.
Preferably, the following steps may be further included after step S101: and if the image is a color image, converting the image into a gray scale image.
Since a color image includes a plurality of color channels, such as RGB or YUV, the complexity of restoring an image using the colors of the image is relatively high. In this embodiment, in order to improve the accuracy and rapidity of image restoration, if the acquired image is a color image, the color image may be converted into a grayscale image, that is, an image with a single channel. Further, the color image may be converted into a binary image.
Fig. 3 is a schematic structural diagram of an image restoration apparatus according to an embodiment of the present invention.
The image restoration apparatus 30 shown in fig. 3 may include an image acquisition module 301, a fuzzy clustering module 302, and an assignment module 303.
The image acquisition module 301 is configured to acquire an image to be processed; the fuzzy clustering module 302 is configured to perform fuzzy clustering on each pixel in the image by using pixel values of neighboring pixels to determine a category to which each pixel belongs and a category pixel value corresponding to each category; the assigning module 303 is configured to assign the pixel values of all pixels in the same category to the category pixel value corresponding to the category, so as to obtain a restored image.
Specifically, the assignment module 303 may further output the restored image.
In the embodiment, the pixel value of each pixel neighborhood pixel in the image to be processed is utilized to perform fuzzy clustering processing on each pixel; by utilizing the neighborhood pixels of each pixel to carry out fuzzy clustering, the defective or redundant pixels in the image to be processed can be accurately classified; and then assigning the pixel values of all the pixels in the same category as the category pixel values corresponding to the category, namely accurately determining the original pixel values of all the pixels in the image to be processed, completing the restoration of the image to be processed, realizing the accuracy of restoration of the image to be processed, and further improving the effect of image restoration.
Preferably, the fuzzy clustering module 302 may include an updating unit 3021 and a clustering processing unit 3022. The updating unit 3021 is configured to update the pixel value of each pixel using neighborhood information of the pixel, where the neighborhood information includes neighborhood grayscale information and neighborhood distance information; the clustering unit 3022 is configured to perform fuzzy clustering using the updated pixel values. In this embodiment, when performing fuzzy clustering on a pixel by using a neighborhood pixel, the neighborhood information of each pixel may be used to update the pixel value of the pixel, where the neighborhood information may refer to neighborhood pixel information. The neighborhood grayscale information may refer to the grayscale value of the neighborhood pixel and the neighborhood distance information may refer to the distance of the neighborhood pixel relative to the pixel.
Specifically, when the pixel value of the pixel is updated, the neighborhood information of each pixel may be used as a weight to be multiplied by the pixel value of the pixel, and the product may be used as the updated pixel value; alternatively, the neighborhood information for each pixel may be added to the pixel value of the pixel, and the sum may be taken as the updated pixel value; alternatively, a combination of weighting and summing may be used, and the embodiment of the present invention is not limited to this.
Preferably, the image restoration device 30 may further comprise a pre-processing module 304, the pre-processing module 304 being configured to pre-process the image according to a predetermined classification of the image, the classification being selected from a defect classification and a redundant classification. In this embodiment, the classification of the image may be predetermined, and corresponding preprocessing may be performed according to the classification of the image. Wherein, the defect classification means that the target in the image has defects and is incomplete; redundant classification refers to the existence of redundancy in objects in an image. Because the defective part and the redundant part of the image of the defective classification and the redundant classification account for different pixel values of the pixels, different preprocessing processes are required to be carried out so as to improve the accuracy of the subsequent clustering process.
Preferably, the image restoration apparatus 30 may further include a first processing module 305, and the first processing module 305 is configured to determine that the classification of the image is a defect classification, and perform an expansion operation and then perform an erosion operation on the image. In this embodiment, the boundary of the target is expanded outward by the expansion operation, and if there are noise holes in the target, the noise holes are compensated by the expansion operation, so that the boundary is no longer the boundary. When the etching operation is performed again, the outer boundary of the target returns to the original state, and the internal noise holes do not exist.
Preferably, the image restoration apparatus 30 may further include a second processing module 306, where the second processing module 306 is configured to determine that the classification of the image is a redundant classification, and perform an erosion operation and then perform a dilation operation on the image. In this embodiment, the edge points of the target are removed by the erosion operation, and the small noise target is considered as an edge point and is thus eliminated. When the dilation operation is performed again, the remaining targets will return to their original size, while the removed small noisy targets will not exist.
Preferably, the fuzzy clustering module 302 may further include a determination unit 3023, an iterative computation unit 3024, and a classification unit 3025. The determining unit 3023 is configured to determine an initial degree of membership of each pixel in the image with respect to each class, and an initial clustering center of each class; the iteration calculation unit 3024 is configured to iteratively calculate a new cluster center and a new membership degree of each pixel based on the current cluster center and the current membership degree by using the pixel value of a neighborhood pixel of each pixel in the neighborhood window until the iteration number reaches the maximum iteration number, or the maximum value of the difference between the new membership degree and the current membership degree of all the pixels is smaller than a set threshold; the classification unit 3025 is configured to determine a class to which each pixel belongs according to the new membership degree of each pixel determined by the last iteration, and determine a class pixel value corresponding to each class according to the new cluster center of each class determined by the last iteration.
Further, the iterative computation unit 3024 computes a new degree of membership for each pixel using the following formula:
Figure GDA0002289054220000151
wherein, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiIs the pixel value of pixel i, vkThe pixel value of a clustering center k, m is a preset fuzzy index, c is the number of the clustering centers, W1 and W2 are pixel information of neighborhood pixels of a pixel i, and the pixel information of the neighborhood pixels is determined according to the pixel value and the position of the neighborhood pixels.
Further, the iterative computation unit 3024 computes the new cluster center using the following formula:
Figure GDA0002289054220000161
wherein v isiterThe new clustering center k at iter iteration, N is the total number of pixels in the image, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiW1 is pixel information of a neighborhood pixel of the pixel i, which is determined according to the pixel value and the position of the neighborhood pixel.
Preferably, the image is a grayscale image, the pixel value of the pixel of the target portion in the image is in a first pixel value range, and the pixel value of the pixel of the background portion is in a second pixel value range, where the first pixel value range and the second pixel value range are adjacent domains; the first processing module 305 may include a first position determination unit 3051, a second position determination unit 3052, and a first processing unit 3053. The first position determining unit 3051 is configured to laterally scan the image, determine a first position where a pixel value is changed from the first pixel value range to the second pixel value range, and determine a second position where the pixel value is changed from the second pixel value range to the first pixel value range; the second position determination unit 3052 is configured to perform longitudinal bidirectional scanning from an intermediate position between the first position and the second position, and determine a third position and a fourth position where a pixel value is changed from the second pixel value range to the first pixel value range; the first processing unit 3053 is configured to, if the distance between the first position and the second position is greater than a minimum lateral threshold and less than a maximum lateral threshold (which may also include a case where the distance between the first position and the second position is equal to the minimum lateral threshold or equal to the maximum lateral threshold), and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include a case where the distance between the third position and the fourth position is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold), perform a dilation operation on the image first, and then perform a erosion operation on the image.
In this embodiment, when the image is classified into the defect classification, the defect region in the image is determined by the first position, the second position, the third position, and the fourth position. And only when the defect area reaches a set size, that is, the distance between the first position and the second position is greater than the minimum transverse threshold and less than the maximum transverse threshold (which may also include a case where the distance between the first position and the second position is equal to the minimum transverse threshold or equal to the maximum transverse threshold), and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include a case where the distance between the third position and the fourth position is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold), the defect area is determined to be defective in the target in the image, so as to eliminate noise in the image or avoid determining the background portion as a defective portion.
Preferably, the image is a grayscale image, the pixel value of the pixel of the target portion in the image is within a first pixel value range, and the pixel value of the pixel of the background portion is within a second pixel value range; the first pixel value range and the second pixel value range are adjacent domains, and the second processing module 306 may include a third position determination unit 3061, a fourth position determination unit 3062, and a second processing unit 3063. The third position determination unit 3061 is configured to scan the image laterally, determine a first position at which the pixel value is changed from the second pixel value range to the first pixel value range, and determine a second position at which the pixel value is changed from the first pixel value range to the second pixel value range; the fourth position determination unit 3062 is configured to longitudinally scan in two directions from a middle position between the first position and the second position, and determine a third position and a fourth position where a pixel value is changed from the first pixel value range to the second pixel value range; the second processing unit 3063 is configured to perform a erosion operation on the image and then perform a dilation operation if the distance between the first location and the second location is greater than a minimum lateral threshold and less than a maximum lateral threshold (which may also include a case where the distance between the first location and the second location is equal to the minimum lateral threshold or equal to the maximum lateral threshold), and the distance between the third location and the fourth location is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include a case where the distance between the third location and the fourth location is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold).
In this embodiment, when the image is classified into the unnecessary classification, the unnecessary area in the image is determined by the first position, the second position, the third position, and the fourth position. And further determining whether the redundant area reaches a set size, that is, whether the distance between the first position and the second position is greater than the minimum transverse threshold and less than the maximum transverse threshold (which may also include a case where the distance between the first position and the second position is equal to the minimum transverse threshold or equal to the maximum transverse threshold), and when the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold (which may also include a case where the distance between the third position and the fourth position is equal to the minimum longitudinal threshold or equal to the maximum longitudinal threshold), determining that the redundant area is redundant for the target in the image, so as to eliminate noise in the image or avoid determining the target portion as the redundant portion.
Preferably, the grayscale image is a binary image, the first pixel value range is a first pixel value, and the second pixel value range is a second pixel value. If the image to be processed is a binary image, when the boundary position of the defect region or the redundant region is determined, it is only necessary to determine whether the change of the pixel value is changed from the first pixel value to the second pixel value or from the second pixel value to the first pixel value, so that the calculation amount can be reduced. In addition, when the image to be processed is a binary image and the image to be processed is subjected to fuzzy clustering, the number of the categories is two, and the clustering centers are respectively a pixel value 0 and a pixel value 1, so that the calculation amount in the image restoration process is further reduced, and the convenience of the image restoration method is improved.
Preferably, the size of the neighborhood window of the neighborhood pixels is determined according to the following parameters: a distance between the first and second positions and a distance between the third and fourth positions. In this embodiment, in order to determine the neighborhood pixels of each pixel, it may be implemented by setting a neighborhood window. When the pixel is in the center position of the neighborhood window, the pixels in other positions in the neighborhood window are the neighborhood pixels of the pixel. In order to give consideration to the accuracy and the calculated amount of fuzzy clustering and ensure that a proper number of neighborhood pixels are selected, the size of a neighborhood window is configured as follows: the size of the neighborhood window is determined according to the following parameters: a distance between the first and second positions and a distance between the third and fourth positions. In other words, the distance between the first position and the second position and the distance between the third position and the fourth position may represent the size of the defect region or the redundant region, and the size of the neighborhood window may be configured according to the size of the defect region or the redundant region.
Preferably, the image obtaining module 301 divides the original image into single character images, wherein the original image includes at least one character selected from the group consisting of chinese characters, letters and numbers. In order to ensure the accuracy and the rapidity of image restoration, the embodiment of the invention can divide the original image into single character images so as to avoid the influence of other characters on the characters to be restored currently.
Preferably, the image restoration device 30 may further include an image conversion module 307, and the image conversion module 307 is configured to convert the image into a grayscale image if the image is a color image. In this embodiment, in order to improve the accuracy and rapidity of image restoration, if the acquired image is a color image, the color image may be converted into a grayscale image, that is, an image with a single channel. Further, the color image may be converted into a binary image.
For more details of the operation principle and the operation mode of the image restoration device 30, reference may be made to the description of fig. 1 to 2, which is not repeated here.
The embodiment of the invention also discloses a readable storage medium, which stores computer instructions, and when the computer instructions are executed, the steps of the image restoration method shown in fig. 1 can be executed. The storage medium may include ROM, RAM, magnetic or optical disks, etc.
The embodiment of the invention also discloses a terminal which can comprise a memory and a processor, wherein the memory is stored with computer instructions capable of running on the processor. The processor, when executing the computer instructions, may perform the steps of the image restoration method shown in fig. 1. The user equipment includes but is not limited to a mobile phone, a computer, a tablet computer and other terminal equipment.
Although the present invention is disclosed above, the present invention is not limited thereto. Various changes and modifications may be effected therein by one skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (26)

1. An image restoration method, comprising:
acquiring an image to be processed;
for each pixel in the image, carrying out fuzzy clustering processing by using the pixel values of the pixels in the neighborhood of the pixel so as to determine the category of each pixel and the category pixel value corresponding to each category;
assigning the pixel values of all pixels in the same category to the category pixel values corresponding to the category to obtain a restored image;
the fuzzy clustering processing of each pixel in the image by using the pixel values of the pixels in the neighborhood of the pixel comprises the following steps:
determining the initial membership of each pixel in the image relative to each class and the initial clustering center of each class;
iteratively calculating a new clustering center and a new membership degree of each pixel based on the current clustering center and the current membership degree by utilizing the pixel value of the neighborhood pixel of each pixel in the neighborhood window until the iteration times reach the maximum iteration times, or the maximum value of the difference value between the new membership degree of all the pixels and the current membership degree is smaller than a set threshold value;
determining the class of each pixel according to the new membership degree of each pixel determined by the last iteration, and determining the class pixel value corresponding to each class according to the new clustering center of each class determined by the last iteration;
the new degree of membership for each pixel is calculated using the following formula:
Figure FDA0002289054210000011
wherein, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiIs the pixel value of pixel i, vkIs the pixel value of a cluster center k, m is a preset fuzzy index, c is the number of cluster centers, and W1 and W2 are the pixel information of the neighborhood pixels of the pixel iThe pixel information of the neighborhood pixels is determined according to the pixel values and the positions of the neighborhood pixels;
wherein, the calculation formula of W1 is:
Figure FDA0002289054210000021
where N is the total number of pixels in the image, xrA pixel value of a neighborhood pixel of pixel i;
w2 represents the similarity between the pixel i and its neighboring pixels, and the calculation formula is
Figure FDA0002289054210000022
Wherein x isrσ is a preset coefficient, and is a pixel value of a neighborhood pixel of the pixel i.
2. The image restoration method according to claim 1, wherein the performing fuzzy clustering processing on each pixel in the image by using the pixel values of the pixels in the neighborhood thereof comprises:
updating the pixel value of each pixel by using neighborhood information of each pixel, wherein the neighborhood information comprises neighborhood gray scale information and neighborhood distance information;
and carrying out fuzzy clustering processing by using the updated pixel values.
3. The image restoration method according to claim 1, wherein before performing the fuzzy clustering process on each pixel in the image by using the pixel values of the pixels in the neighborhood thereof, the method further comprises:
the image is pre-processed according to a predetermined classification of the image, the classification being selected from a defect classification and a redundant classification.
4. The image restoration method according to claim 1 or 3, wherein before performing the fuzzy clustering process on each pixel in the image by using the pixel values of the pixels in the neighborhood thereof, the method further comprises:
and determining the classification of the image as a defect classification, and performing expansion operation and then corrosion operation on the image.
5. The image restoration method according to claim 1 or 3, wherein before performing the fuzzy clustering process on each pixel in the image by using the pixel values of the pixels in the neighborhood thereof, the method further comprises:
and determining the classification of the image as redundant classification, and performing corrosion operation and then expansion operation on the image.
6. The image restoration method according to claim 1, wherein the new cluster center is calculated using the following formula:wherein v isiterThe new clustering center k at iter iteration, N is the total number of pixels in the image, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiW1 is pixel information of a neighborhood pixel of the pixel i, which is determined according to the pixel value and the position of the neighborhood pixel.
7. The image restoration method according to claim 4, wherein the image is a grayscale image, the pixel values of pixels of the target portion in the image are within a first pixel value range, and the pixel values of pixels of the background portion are within a second pixel value range, wherein the first pixel value range and the second pixel value range are adjacent domains; the determining that the classification of the image is defect classification, and performing expansion operation and then corrosion operation on the image comprises the following steps:
transversely scanning the image, determining a first position of a pixel value which is changed from the first pixel value range to the second pixel value range, and determining a second position of the pixel value which is changed from the second pixel value range to the first pixel value range;
longitudinally and bidirectionally scanning from the middle position between the first position and the second position, and determining a third position and a fourth position of a pixel value which is changed from the second pixel value range to the first pixel value range;
and if the distance between the first position and the second position is greater than a minimum transverse threshold and less than a maximum transverse threshold, and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold, performing expansion operation on the image, and then performing erosion operation on the image.
8. The image restoration method according to claim 5, wherein the image is a grayscale image, the pixel values of pixels of the target portion in the image are within a first pixel value range, and the pixel values of pixels of the background portion are within a second pixel value range; wherein the first pixel value range and the second pixel value range are adjacent domains, the determining that the classification of the image is redundant classification, and performing the erosion operation and then the expansion operation on the image comprises:
transversely scanning the image, determining a first position of a pixel value which is changed from the second pixel value range to the first pixel value range, and determining a second position of the pixel value which is changed from the first pixel value range to the second pixel value range;
longitudinally and bidirectionally scanning from the middle position between the first position and the second position, and determining a third position and a fourth position of a pixel value which is changed from the first pixel value range to the second pixel value range;
and if the distance between the first position and the second position is greater than a minimum transverse threshold and less than a maximum transverse threshold, and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold, performing erosion operation on the image, and then performing expansion operation on the image.
9. The image restoration method according to claim 7 or 8, wherein the grayscale image is a binary image, the first pixel value range is a first pixel value, and the second pixel value range is a second pixel value.
10. The image restoration method according to claim 7 or 8, wherein the size of the neighborhood window of the neighborhood pixels is determined according to the following parameters: a distance between the first and second positions and a distance between the third and fourth positions.
11. The image restoration method according to any one of claims 1 to 3 and 6 to 8, wherein the acquiring the image to be processed includes:
the method comprises the steps of dividing an original image into single-character images, wherein the original image comprises at least one character, and the character is selected from Chinese characters, letters and numbers.
12. The image restoration method according to any one of claims 1 to 3 and 6 to 8, wherein the acquiring the image to be processed further comprises:
and if the image is a color image, converting the image into a gray scale image.
13. An image restoration apparatus, comprising:
the image acquisition module is used for acquiring an image to be processed;
the fuzzy clustering module is used for carrying out fuzzy clustering processing on each pixel in the image by using the pixel values of the adjacent pixels so as to determine the category of each pixel and the category pixel value corresponding to each category;
the assignment module is used for assigning the pixel values of all the pixels in the same category to the category pixel values corresponding to the category so as to obtain a restored image;
the fuzzy clustering module comprises:
the determining unit is used for determining the initial membership degree of each pixel in the image relative to each class and the initial clustering center of each class;
the iteration calculation unit is used for utilizing the pixel value of each pixel in the neighborhood pixels in the neighborhood window of each pixel, and iteratively calculating a new clustering center and a new membership degree of each pixel based on the current clustering center and the current membership degree until the iteration times reach the maximum iteration times, or the maximum value of the difference value between the new membership degree of all the pixels and the current membership degree is smaller than a set threshold value;
the classification unit is used for determining the class of each pixel according to the new membership degree of each pixel determined by the last iteration and determining the class pixel value corresponding to each class according to the new clustering center of each class determined by the last iteration;
the iterative computation unit computes a new degree of membership for each pixel using the following formula:
wherein, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiIs the pixel value of pixel i, vkThe method comprises the steps that a pixel value of a clustering center k is obtained, m is a preset fuzzy index, c is the number of the clustering centers, W1 and W2 are pixel information of neighborhood pixels of a pixel i, and the pixel information of the neighborhood pixels is determined according to the pixel value and the position of the neighborhood pixels;
wherein, the calculation formula of W1 is:
where N is the total number of pixels in the image, xrA pixel value of a neighborhood pixel of pixel i;
w2 represents the similarity between the pixel i and its neighboring pixels, and the calculation formula is
Figure FDA0002289054210000053
Wherein x isrσ is a preset coefficient, and is a pixel value of a neighborhood pixel of the pixel i.
14. The image restoration device according to claim 13, wherein the fuzzy clustering module comprises:
the updating unit is used for updating the pixel value of each pixel by utilizing neighborhood information of the pixel, wherein the neighborhood information comprises neighborhood gray scale information and neighborhood distance information;
and the clustering processing unit is used for carrying out fuzzy clustering processing by using the updated pixel values.
15. The image restoration device according to claim 13, further comprising:
a pre-processing module to pre-process the image according to a predetermined classification of the image, the classification being selected from a defect classification and a redundancy classification.
16. The image restoration device according to claim 13 or 15, further comprising:
and the first processing module is used for determining that the classification of the image is defect classification, and performing expansion operation and then corrosion operation on the image.
17. The image restoration device according to claim 13 or 15, further comprising:
and the second processing module is used for determining that the image is classified into redundant classification, and performing corrosion operation and then expansion operation on the image.
18. The image restoration device according to claim 13, wherein the iterative computation unit computes the new cluster center using the following formula:
Figure FDA0002289054210000061
wherein v isiterThe new clustering center k at iter iteration, N is the total number of pixels in the image, Uiter(i, k) is the new degree of membership, x, of pixel i to the cluster center k at the iter iterationiW1 is pixel information of a neighborhood pixel of the pixel i, which is determined according to the pixel value and the position of the neighborhood pixel.
19. The image restoration device according to claim 16, wherein the image is a grayscale image, the pixel values of pixels of the target portion in the image are within a first pixel value range, and the pixel values of pixels of the background portion are within a second pixel value range, wherein the first pixel value range and the second pixel value range are adjacent domains; the first processing module comprises:
a first position determining unit, configured to scan the image laterally, determine a first position at which a pixel value changes from the first pixel value range to the second pixel value range, and determine a second position at which the pixel value changes from the second pixel value range to the first pixel value range;
a second position determination unit, configured to perform longitudinal bidirectional scanning from an intermediate position between the first position and the second position, and determine a third position and a fourth position at which a pixel value is changed from the second pixel value range to the first pixel value range;
a first processing unit, configured to perform a dilation operation on the image first and then perform a erosion operation if a distance between the first location and the second location is greater than a minimum lateral threshold and less than a maximum lateral threshold, and a distance between the third location and the fourth location is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold.
20. The image restoration device according to claim 17, wherein the image is a grayscale image, and the pixel values of the pixels of the target portion in the image are within a first pixel value range, and the pixel values of the pixels of the background portion are within a second pixel value range; wherein the first pixel value range and the second pixel value range are adjacent domains, and the second processing module comprises:
a third position determining unit, configured to scan the image laterally, determine a first position where the pixel value is changed from the second pixel value range to the first pixel value range, and determine a second position where the pixel value is changed from the first pixel value range to the second pixel value range;
a fourth position determination unit, configured to perform longitudinal bidirectional scanning from a middle position between the first position and the second position, and determine a third position and a fourth position at which a pixel value is changed from the first pixel value range to the second pixel value range;
and the second processing unit is used for carrying out erosion operation and then carrying out expansion operation on the image if the distance between the first position and the second position is greater than a minimum transverse threshold and less than a maximum transverse threshold, and the distance between the third position and the fourth position is greater than the minimum longitudinal threshold and less than the maximum longitudinal threshold.
21. The image restoration device according to claim 19 or 20, wherein the grayscale image is a binary image, the first pixel value range is a first pixel value, and the second pixel value range is a second pixel value.
22. The image restoration device according to claim 19 or 20, wherein the size of the neighborhood window of the neighborhood pixels is determined according to the following parameters: a distance between the first and second positions and a distance between the third and fourth positions.
23. The image restoration device according to any one of claims 13 to 15 and 18 to 20, wherein the image acquisition module divides an original image into single character images, the original image including at least one character selected from the group consisting of chinese characters, letters and numbers.
24. The image restoration device according to any one of claims 13 to 15 and 18 to 20, further comprising:
and the image conversion module is used for converting the image into a gray image if the image is a color image.
25. A computer readable storage medium having computer instructions stored thereon, wherein the computer instructions when executed perform the steps of the image restoration method according to any one of claims 1 to 12.
26. A terminal comprising a memory and a processor, the memory having stored thereon computer instructions executable on the processor, wherein the processor, when executing the computer instructions, performs the steps of the image restoration method according to any one of claims 1 to 12.
CN201710424945.XA 2017-06-07 2017-06-07 Image restoration method and device, computer-readable storage medium and terminal Active CN107292840B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710424945.XA CN107292840B (en) 2017-06-07 2017-06-07 Image restoration method and device, computer-readable storage medium and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710424945.XA CN107292840B (en) 2017-06-07 2017-06-07 Image restoration method and device, computer-readable storage medium and terminal

Publications (2)

Publication Number Publication Date
CN107292840A CN107292840A (en) 2017-10-24
CN107292840B true CN107292840B (en) 2020-01-17

Family

ID=60096182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710424945.XA Active CN107292840B (en) 2017-06-07 2017-06-07 Image restoration method and device, computer-readable storage medium and terminal

Country Status (1)

Country Link
CN (1) CN107292840B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109257647A (en) * 2018-10-31 2019-01-22 南昌努比亚技术有限公司 Video image compensation method, mobile terminal and readable storage medium storing program for executing
CN109543753B (en) * 2018-11-23 2024-01-05 中山大学 License plate recognition method based on self-adaptive fuzzy repair mechanism

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102945368A (en) * 2012-10-17 2013-02-27 西安理工大学 Method for positioning and identifying laser character of beer bottle cap
CN105654453A (en) * 2014-11-10 2016-06-08 华东师范大学 Robust FCM image segmentation method
CN106408569A (en) * 2016-08-29 2017-02-15 北京航空航天大学 Brain MRI (magnetic resonance image) segmentation method based on improved fuzzy C-means clustering algorithm
CN106504260A (en) * 2016-10-31 2017-03-15 上海智臻智能网络科技股份有限公司 A kind of FCM image partition methods and system
CN106600610A (en) * 2016-12-07 2017-04-26 上海智臻智能网络科技股份有限公司 FCM image segmentation method and apparatus

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102945368A (en) * 2012-10-17 2013-02-27 西安理工大学 Method for positioning and identifying laser character of beer bottle cap
CN105654453A (en) * 2014-11-10 2016-06-08 华东师范大学 Robust FCM image segmentation method
CN106408569A (en) * 2016-08-29 2017-02-15 北京航空航天大学 Brain MRI (magnetic resonance image) segmentation method based on improved fuzzy C-means clustering algorithm
CN106504260A (en) * 2016-10-31 2017-03-15 上海智臻智能网络科技股份有限公司 A kind of FCM image partition methods and system
CN106600610A (en) * 2016-12-07 2017-04-26 上海智臻智能网络科技股份有限公司 FCM image segmentation method and apparatus

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Jiangsheng Liu et al..An automatic Image Inpainting Algorithm Based on FCM.《Hindawi Publishing Corporation The Scientific World Journal Volume 2014》.2017, *
侯丽丽.面向图像分割的空间信息约束的模糊聚类算法研究.《中国优秀硕士学位论文全文数据库 信息科技辑》.2016,(第10期), *
王娜.基于数学形态学的行扫描相结合的车牌定位的研究.《电子制作》.2015, *
胡嘉骏 等.基于模糊C均值隶属度约束的图像分割算法.《计算机应用》.2016,第36卷(第S1期), *

Also Published As

Publication number Publication date
CN107292840A (en) 2017-10-24

Similar Documents

Publication Publication Date Title
KR102640237B1 (en) Image processing methods, apparatus, electronic devices, and computer-readable storage media
CN110322495B (en) Scene text segmentation method based on weak supervised deep learning
CN111640125B (en) Aerial photography graph building detection and segmentation method and device based on Mask R-CNN
JP7044898B2 (en) License plate recognition method and its system
CN110738207A (en) character detection method for fusing character area edge information in character image
CN110647795B (en) Form identification method
CN105631486A (en) Method and device for recognizing images and characters
CN110866529A (en) Character recognition method, character recognition device, electronic equipment and storage medium
WO2016068326A1 (en) Image processing device, character recognition device, image processing method, and program
CN108197567B (en) Method, apparatus and computer readable medium for image processing
CN111814905A (en) Target detection method, target detection device, computer equipment and storage medium
US20210248729A1 (en) Superpixel merging
CN115424017B (en) Building inner and outer contour segmentation method, device and storage medium
CN112800955A (en) Remote sensing image rotating target detection method and system based on weighted bidirectional feature pyramid
CN111507337A (en) License plate recognition method based on hybrid neural network
CN115131797A (en) Scene text detection method based on feature enhancement pyramid network
CN114332133A (en) New coronary pneumonia CT image infected area segmentation method and system based on improved CE-Net
CN107292840B (en) Image restoration method and device, computer-readable storage medium and terminal
CN116310095A (en) Multi-view three-dimensional reconstruction method based on deep learning
CN111985488B (en) Target detection segmentation method and system based on offline Gaussian model
CN115620321B (en) Table identification method and device, electronic equipment and storage medium
CN111860465A (en) Remote sensing image extraction method, device, equipment and storage medium based on super pixels
CN109117886B (en) Method for estimating target dimension and region in image frame
CN114219757B (en) Intelligent damage assessment method for vehicle based on improved Mask R-CNN
CN112837329B (en) Tibetan ancient book document image binarization method and system

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