CN112508937A - Method and device for generating scratch data, electronic equipment and storage medium - Google Patents

Method and device for generating scratch data, electronic equipment and storage medium Download PDF

Info

Publication number
CN112508937A
CN112508937A CN202011531278.3A CN202011531278A CN112508937A CN 112508937 A CN112508937 A CN 112508937A CN 202011531278 A CN202011531278 A CN 202011531278A CN 112508937 A CN112508937 A CN 112508937A
Authority
CN
China
Prior art keywords
image
scratch
pixels
scratch data
preliminary
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.)
Pending
Application number
CN202011531278.3A
Other languages
Chinese (zh)
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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202011531278.3A priority Critical patent/CN112508937A/en
Publication of CN112508937A publication Critical patent/CN112508937A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence

Landscapes

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

Abstract

The disclosure provides a method and a device for generating scratch data, electronic equipment and a storage medium, and relates to the field of artificial intelligence, in particular to the field of computer vision and deep learning. The implementation scheme is as follows: a method of generating scratch data, comprising: comparing the image with the scratch with the image after the scratch is repaired to generate a primary scratch data image; acquiring candidate pixels meeting a first condition among all pixels in the preliminary scratch data image to generate a modulated preliminary scratch data image; calculating a connected region within the modulated preliminary scratch data image; and generating scratch data according to the candidate pixels corresponding to the connected region meeting the second condition.

Description

Method and device for generating scratch data, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of artificial intelligence, in particular to the field of computer vision and deep learning, and more particularly to a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for generating scratch data, and a scratch segmentation training method.
Background
In early video images, such as old movies, scratches often appear on the screen, which seriously affects the quality of the images. The scratches usually occur because these early audiovisual images are stored in conventional analog storage media (e.g., film), which are easily knocked by hard objects during storage or moving, resulting in scratches being formed in the image. Conventionally, a scratch in a screen is generally divided by a scratch division technique to repair the screen.
The approaches described in this section are not necessarily approaches that have been previously conceived or pursued. Unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Similarly, unless otherwise indicated, the problems mentioned in this section should not be considered as having been acknowledged in any prior art.
Disclosure of Invention
The present disclosure provides a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for generating scratch data, and a scratch segmentation training method.
According to an aspect of the present disclosure, there is provided a method of generating scratch data, including: comparing the image with the scratch with the repaired image to generate a primary scratch data image; acquiring candidate pixels meeting a first condition among all pixels in the preliminary scratch data image to generate a modulated preliminary scratch data image; calculating a connected region within the modulated preliminary scratch data image; and generating the scratch data according to the candidate pixels corresponding to the connected region meeting the second condition.
According to another aspect of the present disclosure, there is provided a scratch segmentation training method including: the scratch segmentation training is performed using the scratch data obtained by the method of generating scratch data as described above.
According to another aspect of the present disclosure, there is provided an apparatus for generating scratch data, including: a first image generation module configured to compare an image with a scratch with the repaired image to generate a preliminary scratch data image; a second image generation module configured to acquire candidate pixels satisfying a first condition among all pixels within the preliminary scratch data image to generate a modulated preliminary scratch data image; a connected region calculation module configured to calculate a connected region within the modulated preliminary scratch data image; and the scratch data generation module is configured to generate the scratch data according to the candidate pixels corresponding to the communication areas meeting the second condition.
According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method as described above.
According to another aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method as described above.
According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program realizes the method as described above when executed by a processor.
According to one or more embodiments of the present disclosure, clean scratch data that only contains a scratch can be acquired for scratch segmentation training, thereby improving the repairing effect on the picture.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate exemplary embodiments of the embodiments and, together with the description, serve to explain the exemplary implementations of the embodiments. The illustrated embodiments are for purposes of illustration only and do not limit the scope of the claims. Throughout the drawings, identical reference numbers designate similar, but not necessarily identical, elements.
Fig. 1 shows a flow diagram of a method of generating scratch data according to an embodiment of the present disclosure;
fig. 2(a) and 2(b) illustrate examples of an image with a scratch and an image after repairing the scratch according to an embodiment of the present disclosure;
FIG. 3 illustrates an example of a preliminary scratch data image according to an embodiment of the present disclosure;
FIG. 4 illustrates an example of an image-converted preliminary scratch data image in accordance with an embodiment of the present disclosure;
fig. 5 illustrates an example of a modulated preliminary scratch data image in accordance with an embodiment of the present disclosure;
fig. 6 illustrates an example of scratch data according to an embodiment of the present disclosure;
fig. 7 is a block diagram illustrating a structure of an apparatus for generating scratch data according to an embodiment of the present disclosure;
FIG. 8 illustrates a block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the present disclosure, unless otherwise specified, the use of the terms "first", "second", etc. to describe various elements is not intended to limit the positional relationship, the timing relationship, or the importance relationship of the elements, and such terms are used only to distinguish one element from another. In some examples, a first element and a second element may refer to the same instance of the element, and in some cases, based on the context, they may also refer to different instances.
The terminology used in the description of the various described examples in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the elements may be one or more. Furthermore, the term "and/or" as used in this disclosure is intended to encompass any and all possible combinations of the listed items.
For an early video image such as an old movie, in order to repair a scratch in a picture, the scratch in the picture can be generally segmented by using a scratch segmentation technology to realize the repair of the picture. For this reason, scratch segmentation training may need to be performed using training data including scratches. However, such training data for scratch segmentation training may often contain various noises such as thermal noise, block noise, color noise, and the like, in addition to scratch data. If the unclean training data is used for scratch segmentation training, an ideal scratch segmentation model is difficult to obtain, and then the effect of scratch segmentation is affected, so that the repairing effect of the picture is difficult to ensure.
According to an embodiment of the present disclosure, there is provided a method of generating scratch data. Fig. 1 shows a flowchart of a method of generating scratch data according to an embodiment of the present disclosure. As shown in fig. 1, the method of generating scratch data may include:
step S101, comparing the image with the scratch with the repaired image to generate a primary scratch data image;
step S102, obtaining candidate pixels meeting a first condition from all pixels in the preliminary scratch data image to generate a modulated preliminary scratch data image;
step S103, calculating a communication area in the modulated preliminary scratch data image; and
and step S104, generating the scratch data according to the candidate pixels corresponding to the communication areas meeting the second condition.
According to the method for generating the scratch data, the original unclean scratch data including the scratch and possible noise is obtained through the image with the scratch and the image after repairing the scratch; and then, accurately distinguishing scratches and noise contained in original unclean scratch data by two-stage screening, namely modulating the image and calculating a connected region in the image, and correspondingly removing the noise. From this, can acquire the clean mar data that only contain the mar and cut apart the training in order to be used for the mar, and then promote the restoration effect to the picture.
A method of generating scratch data according to an embodiment of the present disclosure is described in detail below with reference to the flowchart of fig. 1 and the examples of fig. 2 to 6.
In step S101, the image with the scratch may be compared with the scratch-repaired image to generate a preliminary scratch data image. Here, the preliminary scratch data image is the original unclean scratch data as described above, in which various noises may be contained in addition to the scratch.
Fig. 2(a) and 2(b) illustrate examples of an image with a scratch and an image after repairing the scratch according to an embodiment of the present disclosure, and fig. 3 illustrates an example of a preliminary scratch data image according to an embodiment of the present disclosure. As an example, the image with the scratch shown in fig. 2(a) may be, for example, one frame image in an old movie. As shown in fig. 2(a), a plurality of white regions having a long shape, a dot shape, a block shape, or the like are interposed in the screen. These areas may correspond to scratches as described above, however, also including parts belonging to noise. The image after the scratch repair shown in fig. 2(b) may be an image after the image shown in fig. 2(a) is repaired to a clear picture in advance. In this case, the scratch data can be obtained by comparing the image with the scratch shown in fig. 2(a) with the image after the scratch is repaired shown in fig. 2(b), however, the scratch data at this time also includes noise. In other words, the preliminary scratch data image shown in fig. 3 is the original unclean scratch data, which includes scratches and possibly noise.
Alternatively, as an embodiment of comparing the images, the comparing step in step S101 may include: and subtracting the pixel values of the corresponding pixels in the image with the scratch and the image after the scratch is repaired, and taking an absolute value of the subtraction result, wherein the preliminary scratch data image is generated based on the absolute value.
In one example, the image shown in fig. 2(a) and the image shown in fig. 2(b) may be subtracted from each other, and the absolute value of the subtraction result may be taken, wherein the image shown in fig. 3 is generated based on the absolute value. Here, taking the absolute value of the result of the subtraction means paying attention only to the magnitude of the difference in pixel value between the pixels of the image shown in fig. 2(a) and the image shown in fig. 2(b), and not paying attention to the directionality, i.e., the positive and negative, of the difference. Therefore, the difference between the two images can be simply reflected from only one dimension, and the original unclean scratch data can be conveniently acquired.
In one example, as shown in fig. 3, there are several white areas in the preliminary scratch data image, such as stripes, dots, or blocks, which may correspond to scratches, however, as described above, noise is also included therein.
Optionally, the step of generating the preliminary scratch data image in step S101 may further include: the preliminary scratch data image is converted from an RGB image to a grayscale image. Therefore, the image processing of three channels can be converted into the image processing of a single channel, and the image processing process is simplified.
In one example, the conversion from an RGB image to a grayscale image may be implemented using various known grayscale conversion algorithms, for example, by the known conversion formula Gray 0.299+ G0.587 + B0.114, where R, G, B represents the values of the three color components of the RGB image, respectively, and Gray represents the pixel values in the grayscale image. Fig. 4 illustrates an example of an image-converted preliminary scratch data image according to an embodiment of the present disclosure. Note that the image-converted preliminary scratch data image of fig. 4 at this time appears indistinguishable from the image shown in fig. 3, but has actually been converted from an RGB image to a grayscale image.
After the original unclean scratch data (containing scratches and possibly noise) is acquired according to step S101 as described above, it may be subjected to a first level of screening. To this end, in step S102, candidate pixels satisfying the first condition among all pixels within the preliminary scratch data image may be acquired to generate a modulated preliminary scratch data image. Fig. 5 shows an example of a modulated preliminary scratch data image according to an embodiment of the present disclosure. As shown in fig. 5, a white area (a shape such as a long stripe, a dot, or a block) in the image may be a candidate pixel satisfying the first condition obtained from among the pixels of the image shown in fig. 4, thereby generating the modulated preliminary scratch data image shown in fig. 5.
Alternatively, the step of acquiring a candidate pixel satisfying the first condition among all pixels within the preliminary scratch data image may include: comparing pixel values of all pixels within the preliminary scratch data image to a first conditional threshold; and determining pixels having pixel values greater than or equal to the first conditional threshold as candidate pixels, and determining pixels having pixel values less than the first conditional threshold as noise pixels. Thereby, pixels in the preliminary scratch data image that are clearly noisy and pixels that may be scratches can be resolved.
The first conditional threshold may be an empirical value obtained by means of experiments or the like. Those skilled in the art will appreciate that the first conditional threshold may be selected according to the actual application.
In one example, a relatively large threshold value means that it is possible to be a candidate pixel for a scratch only when the difference in pixel values between the pixels of the two images (i.e., the image with the scratch and the image after repairing the scratch) is large enough, i.e., the judgment on the scratch is more strict. At the same time, it also shows that the modulated preliminary scratch data image generated in this step will contain relatively few white areas. For example, assume that the first conditional threshold is 240, meaning that it is possible to be a candidate pixel for a scratch only when the difference in pixel values of the pixels of the two images is greater than or equal to 240.
In one example, considering that this step is a first level screening for noise, a relatively small threshold may also be set at this point to ensure that only pixels that are significantly noisy are excluded. For example, the first conditional threshold may take 13. Thus, the pixel values of all pixels within the preliminary scratch data image of fig. 4 may be compared to the threshold 13; and determining pixels having a pixel value greater than or equal to 13 as candidate pixels, and determining pixels having a pixel value less than 13 as noise pixels.
After distinguishing between pixels in the preliminary scratch data image that are clearly noisy and pixels that may be scratches, a modulated preliminary scratch data image may be generated, thereby reflecting the results of the first level of screening. Optionally, the generating the modulated preliminary scratch data image may include: setting the pixel value of the candidate pixel to a first predetermined value and the pixel value of the noise pixel to a second predetermined value; the modulated preliminary scratch data image is generated according to the first predetermined value and the second predetermined value.
In one example, the first predetermined value may be 255 and the second predetermined value may be 0, so that the result of the first level of filtering may be reflected in a pure black and white image. As shown in fig. 5, the pixel value of the candidate pixel is set to 255, i.e., a white area in the image; the pixel value of the noise pixel is set to 0, i.e. coincides with the black color of the image background. Thus, pixels in the first stage of screening that are considered to be clearly noisy are removed. As described above, the white areas in the image shown in fig. 5 represent candidate pixels for scratches, which include both scratches and possibly noise.
After the first level screening is performed according to step S102 as described above, more accurate second level screening may be performed. For this purpose, in step S103, a connected region within the modulated preliminary scratch data image may be first calculated.
In one example, the connected components of a pixel may be calculated by a known connected components function. The scratch and noise can be further resolved by calculating the connected regions within the modulated preliminary scratch data image, taking into account that the connected regions of the pixels corresponding to the scratch are relatively large, e.g., long stripes, while the connected regions of the pixels corresponding to the noise are relatively small, e.g., relatively small dots.
Next, in step S104, scratch data may be generated according to the candidate pixel corresponding to the connected region satisfying the second condition. Fig. 6 shows an example of scratch data according to an embodiment of the present disclosure. A white region (a shape such as a stripe, a dot, or a block) shown in fig. 6 may be a candidate pixel in which the connected region satisfies the second condition, that is, a pixel that is confirmed as a scratch.
Optionally, this step may include comparing the number of candidate pixels included within the communication region with a second conditional threshold; determining candidate pixels with the number larger than or equal to a second condition threshold value as scratch pixels, and determining candidate pixels with the number smaller than the second condition threshold value as noise pixels; and removing the noise pixel and generating scratch data according to the scratch pixel. That is, by calculating the link area within the modulated preliminary scratch data image shown in fig. 5 and comparing it with the second conditional threshold, the corresponding scratch pixel, e.g., the white area in the form of a bar, dot or block shown in fig. 6, is determined. Meanwhile, a large number of white dots in the image shown in fig. 5 are determined as noise pixels, and thus these noise pixels are removed to obtain scratch data shown in fig. 6.
The second conditional threshold may also be an empirical value obtained by experiment or the like, which represents the number of pixels in the communication region. In one example, the second conditional threshold may be taken to be 12, meaning that a link region containing 12 or more than 12 pixels may be considered a scratch.
Thus, a second level of screening can be performed by the size of the link area to distinguish scratches from noise and obtain final scratch data based on the determined scratches.
As described above, according to the method for generating scratch data of the embodiment of the present disclosure, original unclean scratch data, which includes a scratch and possible noise, is first obtained through an image with the scratch and an image after repairing the scratch; and then, accurately distinguishing scratches and noise contained in original unclean scratch data by two-stage screening, namely modulating the image and calculating a connected region in the image, and correspondingly removing the noise. From this, can acquire the clean mar data that only contain the mar and cut apart the training in order to be used for the mar, and then promote the restoration effect to the picture.
According to another aspect of the present disclosure, there is also provided a scratch segmentation training method, including: scratch segmentation training is performed using scratch data obtained using the method of generating scratch data described above. When clean scratch data including only scratches is used, an ideal scratch segmentation model can be obtained, and the effect of repairing a screen can be ensured.
According to another aspect of the present disclosure, there is also provided an apparatus for generating scratch data. Fig. 7 illustrates a block diagram of an apparatus for generating scratch data according to an embodiment of the present disclosure. As shown in fig. 7, the apparatus 700 for generating scratch data may include: the method comprises the following steps:
a first image generation module 701 configured to compare an image with a scratch with the repaired image to generate a preliminary scratch data image;
a second image generation module 702 configured to obtain candidate pixels satisfying a first condition among all pixels within the preliminary scratch data image to generate a modulated preliminary scratch data image;
a connected region calculation module 703 configured to calculate a connected region within the modulated preliminary scratch data image; and
a scratch data generating module 704 configured to generate the scratch data according to the candidate pixel corresponding to the connected region satisfying the second condition.
The operations of the modules 701, 702, 703 and 704 of the apparatus 700 for generating scratch data may correspond to the operations of the steps S101, S102, S103 and S104 described in conjunction with fig. 1 and fig. 2 to 6, respectively, and are not described again here.
Optionally, the first image generation module 701 comprises a subtraction module 7010, said subtraction module 7010 being configured to: subtracting the pixel values of the corresponding pixels in the image with the scratch and the image after the scratch is repaired, and taking an absolute value of the subtraction result, wherein the preliminary scratch data image is generated based on the absolute value.
Optionally, the first image generating module 701 further comprises an image converting module 7012, the image converting module 7012 is configured to: converting the preliminary scratch data image from an RGB image to a grayscale image.
Optionally, the second image generation module 702 comprises a first comparison module 7020, the first comparison module 7020 being configured to: comparing pixel values of all pixels within the preliminary scratch data image to a first conditional threshold; and determining pixels having pixel values greater than or equal to the first conditional threshold as the candidate pixels, and determining pixels having pixel values less than the first conditional threshold as noise pixels.
Optionally, the second image generation module 702 further comprises a modulation module 7022, the modulation module 7022 being configured to: setting the pixel value of the candidate pixel to a first predetermined value and the pixel value of the noise pixel to a second predetermined value; generating the modulated preliminary scratch data image according to the first predetermined value and the second predetermined value.
Optionally, the scratch data generation module 704 comprises a second comparison module 7040 configured to: comparing the number of candidate pixels included within the communication region to a second conditional threshold; determining the candidate pixels with the number larger than or equal to a second condition threshold value as scratch pixels, and determining the candidate pixels with the number smaller than the second condition threshold value as noise pixels; and removing the noise pixel and generating the scratch data according to the scratch pixel.
According to another aspect of the present disclosure, there is also provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method as described above.
According to another aspect of the present disclosure, there is also provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method as described above.
According to another aspect of the present disclosure, there is also provided a computer program product comprising a computer program, wherein the computer program, when executed by a processor, is the method as described above.
Referring to fig. 8, a block diagram of a structure of an electronic device 800, which is an example of a hardware device that may be applied to aspects of the present disclosure, which may be applied to the present disclosure, will now be described. Electronic device is intended to represent various forms of digital electronic computer devices, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 8, the electronic device 800 includes a computing unit 801 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM)802 or a computer program loaded from a storage unit 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic apparatus 800 can also be stored. The calculation unit 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
A number of components in the electronic device 800 are connected to the I/O interface 805, including: an input unit 806, an output unit 807, a storage unit 808, and a communication unit 809. The input unit 806 may be any type of device capable of inputting information to the electronic device 800, and the input unit 806 may receive input numeric or character information and generate key signal inputs related to user settings and/or function controls of the electronic device, and may include, but is not limited to, a mouse, a keyboard, a touch screen, a track pad, a track ball, a joystick, a microphone, and/or a remote controller. Output unit 807 can be any type of device capable of presenting information and can include, but is not limited to, a display, speakers, a video/audio output terminal, a vibrator, and/or a printer. The storage unit 808 may include, but is not limited to, a magnetic disk, an optical disk. The communication unit 809 allows the electronic device 800 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and/or chipsGroups, e.g. BluetoothTMDevices, 1302.11 devices, WiFi devices, WiMax devices, cellular communication devices, and/or the like.
Computing unit 801 may be a variety of general and/or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and the like. The calculation unit 801 executes the respective methods and processes described above, such as the method of generating scratch data. For example, in some embodiments, the method of generating scratch data may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and/or installed onto the electronic device 800 via the ROM 802 and/or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the method of generating scratch data described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the method of generating scratch data in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be performed in parallel, sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
Although embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it is to be understood that the above-described methods, systems and apparatus are merely exemplary embodiments or examples and that the scope of the present invention is not limited by these embodiments or examples, but only by the claims as issued and their equivalents. Various elements in the embodiments or examples may be omitted or may be replaced with equivalents thereof. Further, the steps may be performed in an order different from that described in the present disclosure. Further, various elements in the embodiments or examples may be combined in various ways. It is important that as technology evolves, many of the elements described herein may be replaced with equivalent elements that appear after the present disclosure.

Claims (16)

1. A method of generating scratch data, comprising:
comparing the image with the scratch with the repaired image to generate a primary scratch data image;
acquiring candidate pixels meeting a first condition among all pixels in the preliminary scratch data image to generate a modulated preliminary scratch data image;
calculating a connected region within the modulated preliminary scratch data image; and
and generating the scratch data according to the candidate pixels corresponding to the communication areas meeting the second condition.
2. The method of claim 1, wherein the comparing comprises: subtracting the pixel values of the corresponding pixels in the image with the scratch and the image after the scratch is repaired, and taking an absolute value of the subtraction result, wherein the preliminary scratch data image is generated based on the absolute value.
3. The method of claim 1, wherein said generating a preliminary scratch data image further comprises: converting the preliminary scratch data image from an RGB image to a grayscale image.
4. The method according to claim 1, wherein said acquiring a candidate pixel satisfying a first condition among all pixels within the preliminary scratch data image comprises:
comparing pixel values of all pixels within the preliminary scratch data image to a first conditional threshold; and
determining pixels having pixel values greater than or equal to the first conditional threshold as the candidate pixels, and determining pixels having pixel values less than the first conditional threshold as noise pixels.
5. The method of claim 4, wherein the generating the modulated preliminary scratch data image comprises:
setting the pixel value of the candidate pixel to a first predetermined value and the pixel value of the noise pixel to a second predetermined value;
generating the modulated preliminary scratch data image according to the first predetermined value and the second predetermined value.
6. The method according to claim 1, wherein the generating the scratch data according to the candidate pixel corresponding to the connected region satisfying the second condition comprises:
comparing the number of candidate pixels included within the communication region to a second conditional threshold;
determining the candidate pixels with the number larger than or equal to a second condition threshold value as scratch pixels, and determining the candidate pixels with the number smaller than the second condition threshold value as noise pixels; and
and removing the noise pixel, and generating the scratch data according to the scratch pixel.
7. A scratch segmentation training method, comprising: performing scratch segmentation training using the scratch data obtained by the method of generating scratch data according to any one of claims 1-6.
8. An apparatus for generating scratch data, comprising:
a first image generation module configured to compare an image with a scratch with the repaired image to generate a preliminary scratch data image;
a second image generation module configured to acquire candidate pixels satisfying a first condition among all pixels within the preliminary scratch data image to generate a modulated preliminary scratch data image;
a connected region calculation module configured to calculate a connected region within the modulated preliminary scratch data image; and
and the scratch data generation module is configured to generate the scratch data according to the candidate pixels corresponding to the communication areas meeting the second condition.
9. The apparatus of claim 8, wherein the first image generation module comprises a subtraction module configured to: subtracting the pixel values of the corresponding pixels in the image with the scratch and the image after the scratch is repaired, and taking an absolute value of the subtraction result, wherein the preliminary scratch data image is generated based on the absolute value.
10. The apparatus of claim 8, the first image generation module further comprising an image conversion module configured to: converting the preliminary scratch data image from an RGB image to a grayscale image.
11. The apparatus of claim 8, wherein the second image generation module comprises a first comparison module configured to:
comparing pixel values of all pixels within the preliminary scratch data image to a first conditional threshold; and
determining pixels having pixel values greater than or equal to the first conditional threshold as the candidate pixels, and determining pixels having pixel values less than the first conditional threshold as noise pixels.
12. The apparatus of claim 11, wherein the second image generation module further comprises a modulation module configured to:
setting the pixel value of the candidate pixel to a first predetermined value and the pixel value of the noise pixel to a second predetermined value;
generating the modulated preliminary scratch data image according to the first predetermined value and the second predetermined value.
13. The apparatus of claim 8, wherein the scratch data generation module comprises a second comparison module configured to:
comparing the number of candidate pixels included within the communication region to a second conditional threshold;
determining the candidate pixels with the number larger than or equal to a second condition threshold value as scratch pixels, and determining the candidate pixels with the number smaller than the second condition threshold value as noise pixels; and
and removing the noise pixel, and generating the scratch data according to the scratch pixel.
14. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
15. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-7.
16. A computer program product comprising a computer program, wherein the computer program realizes the method of any one of claims 1-7 when executed by a processor.
CN202011531278.3A 2020-12-22 2020-12-22 Method and device for generating scratch data, electronic equipment and storage medium Pending CN112508937A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011531278.3A CN112508937A (en) 2020-12-22 2020-12-22 Method and device for generating scratch data, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011531278.3A CN112508937A (en) 2020-12-22 2020-12-22 Method and device for generating scratch data, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112508937A true CN112508937A (en) 2021-03-16

Family

ID=74921998

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011531278.3A Pending CN112508937A (en) 2020-12-22 2020-12-22 Method and device for generating scratch data, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112508937A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113724152A (en) * 2021-07-30 2021-11-30 杭州当虹科技股份有限公司 Video inpainting method based on deep learning and computer readable storage medium
CN114266768A (en) * 2022-03-01 2022-04-01 聚时科技(江苏)有限公司 Method for generating surface scratch defect image

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102129670A (en) * 2011-02-25 2011-07-20 上海交通大学 Method for detecting and repairing movie scratch damage
CN105388162A (en) * 2015-10-28 2016-03-09 镇江苏仪德科技有限公司 Raw material silicon wafer surface scratch detection method based on machine vision
CN106157303A (en) * 2016-06-24 2016-11-23 浙江工商大学 A kind of method based on machine vision to Surface testing
CN107991309A (en) * 2017-11-27 2018-05-04 歌尔股份有限公司 Product quality detection method, device and electronic equipment
CN110378902A (en) * 2019-09-11 2019-10-25 征图新视(江苏)科技股份有限公司 A kind of scratch detection method under strong noise background

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102129670A (en) * 2011-02-25 2011-07-20 上海交通大学 Method for detecting and repairing movie scratch damage
CN105388162A (en) * 2015-10-28 2016-03-09 镇江苏仪德科技有限公司 Raw material silicon wafer surface scratch detection method based on machine vision
CN106157303A (en) * 2016-06-24 2016-11-23 浙江工商大学 A kind of method based on machine vision to Surface testing
CN107991309A (en) * 2017-11-27 2018-05-04 歌尔股份有限公司 Product quality detection method, device and electronic equipment
CN110378902A (en) * 2019-09-11 2019-10-25 征图新视(江苏)科技股份有限公司 A kind of scratch detection method under strong noise background

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113724152A (en) * 2021-07-30 2021-11-30 杭州当虹科技股份有限公司 Video inpainting method based on deep learning and computer readable storage medium
CN114266768A (en) * 2022-03-01 2022-04-01 聚时科技(江苏)有限公司 Method for generating surface scratch defect image

Similar Documents

Publication Publication Date Title
US11151712B2 (en) Method and apparatus for detecting image defects, computing device, and computer readable storage medium
US20190347824A1 (en) Method and apparatus for positioning pupil, storage medium, electronic device
CN109697724B (en) Video image segmentation method and device, storage medium and electronic equipment
CN113436100B (en) Method, apparatus, device, medium, and article for repairing video
CN111507914A (en) Training method, repairing method, device, equipment and medium of face repairing model
WO2019041842A1 (en) Image processing method and device, storage medium and computer device
CN111105375A (en) Image generation method, model training method and device thereof, and electronic equipment
CN110516598B (en) Method and apparatus for generating image
CN113177451A (en) Training method and device of image processing model, electronic equipment and storage medium
CN113033346B (en) Text detection method and device and electronic equipment
CN111192190A (en) Method and device for eliminating image watermark and electronic equipment
CN111179276A (en) Image processing method and device
CN111783777A (en) Image processing method, image processing device, electronic equipment and computer readable medium
CN111724396A (en) Image segmentation method and device, computer-readable storage medium and electronic device
CN112508937A (en) Method and device for generating scratch data, electronic equipment and storage medium
CN110147765B (en) Image processing method and device
EP3675503B1 (en) Display apparatus and image processing method thereof
US20200334865A1 (en) Image display apparatus and method of controlling the same
CN113628192B (en) Image blur detection method, apparatus, device, storage medium, and program product
KR20220146663A (en) Video recovery methods, devices, appliances, media and computer programs
CN115018734A (en) Video restoration method and training method and device of video restoration model
CN115376137A (en) Optical character recognition processing and text recognition model training method and device
CN113556575A (en) Method, apparatus, device, medium and product for compressing data
CN114723855A (en) Image generation method and apparatus, device and medium
CN114494686A (en) Text image correction method, text image correction device, electronic equipment and storage medium

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