Method, device, apparatus and computer-readable medium for repairing images
By extracting the mask image and edge image of image cracks, and combining the two to describe the texture of the image content, the problem that existing technology cannot effectively repair the details of image cracks is solved, and more detailed repair of image cracks is achieved.
Patent Information
- Application Number
- CN202011392205.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-02
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2040-12-02
AI Technical Summary
Existing image repair methods cannot effectively repair the detailed parts of image cracks because they cannot accurately extract the texture features of the cracked parts.
By extracting the mask image of image cracks and the edge image of the image to be repaired, and combining the two to describe the texture of the image content, more detailed repair of image cracks can be achieved.
By extracting the edge image, the pixel area of the crack can be determined more accurately, and the image crack can be repaired in more detail, improving the detail of the image repair.
Smart Images

Figure CN112488942B
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of image processing, and in particular to a method, apparatus, device, and computer-readable medium for repairing an image. Background Art
[0002] In the process of acquiring, transmitting and saving images, various factors (such as electromagnetic interference) may cause image cracks. For example, when taking an image, the object itself may have cracks, resulting in a cracked image. However, existing methods for repairing cracked images cannot repair the details of the image cracks well. Summary of the invention
[0003] The content of this disclosure is used to introduce concepts in a brief form, and these concepts will be described in detail in the detailed implementation section below. The content of this disclosure is not intended to identify the key features or essential features of the technical solution claimed for protection, nor is it intended to limit the scope of the technical solution claimed for protection. Some embodiments of the present disclosure propose methods, devices, equipment and computer-readable media for repairing images to solve the technical problems mentioned in the above background technology section.
[0004] In a first aspect, some embodiments of the present disclosure provide a method for repairing an image, the method comprising: acquiring an image to be repaired, where the image to be repaired is an image with image cracks; extracting a mask image of the image cracks; extracting an edge image of the image to be repaired, where the edge image is used to characterize the texture of the image content of the image to be repaired; and obtaining a target image based on the image to be repaired, the mask image and the edge image.
[0005] In a second aspect, some embodiments of the present disclosure provide a device for repairing an image, the device comprising: an acquisition unit, configured to acquire an image to be repaired, where the image to be repaired is an image with image cracks; a first extraction unit, configured to extract a mask image of the image cracks; a second extraction unit, configured to extract an edge image of the image to be repaired, where the edge image is used to characterize the texture of the image content of the image to be repaired; and a generation unit, configured to obtain a target image based on the image to be repaired, the mask image and the edge image.
[0006] In a third aspect, some embodiments of the present disclosure provide an electronic device comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for repairing an image as in the first aspect.
[0007] In a fourth aspect, some embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for repairing an image according to the first aspect is implemented.
[0008] The above-mentioned various embodiments of the present disclosure have the following beneficial effects: through the image repair method of some embodiments of the present disclosure, the image cracks are repaired in more detail. Specifically, the inventors found that the reason why the image cracks cannot be repaired in detail is that the existing methods cannot extract the texture features of the cracked part well. Based on this, the image repair method of some embodiments of the present disclosure not only extracts the mask image of the image cracks, but also extracts the edge image of the image to be repaired. Because of the participation of the edge image, the cracked part of the cracked image can be effectively described, thereby achieving a more detailed repair of the image cracks. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.
[0010] Figure 1 is a schematic diagram of an application scenario of a method for repairing an image according to some embodiments of the present disclosure;
[0011] Figure 2 are flow charts of some embodiments of methods for repairing images according to the present disclosure;
[0012] Figure 3 are flow charts of other embodiments of methods for repairing images according to the present disclosure;
[0013] Figure 4 are flow charts of still further embodiments of the method for repairing an image according to the present disclosure;
[0014] Figure 5 is a schematic structural diagram of some embodiments of an apparatus for repairing an image according to the present disclosure;
[0015] Figure 6 It is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure.
[0016] Figure 7 It is a schematic diagram of judging the validity of pixels based on gradient values. DETAILED DESCRIPTION
[0017] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0018] It should also be noted that, for ease of description, only the parts related to the invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other.
[0019] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0020] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0021] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0022] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0023] Figure 1 100 is a schematic diagram of an application scenario of a method for repairing an image according to some embodiments of the present disclosure.
[0024] exist Figure 1 In the application scenario, first, the electronic device 101 can receive the image to be repaired 102. Then, the electronic device 101 extracts the image cracks of the image to be repaired 102 to obtain the mask image 103. In this way, the mask image 103 of the image cracks is obtained. The electronic device 101 extracts the texture of the entire image of the image to be repaired 102 to obtain the edge image 104. In this way, not only the texture of the image cracks but also the texture of the non-image cracks is obtained. Comparing the texture of the non-image cracks makes the details of the texture of the image cracks more prominent. Next, according to the image to be repaired 102, the mask image 103 and the edge image 104, the target image 105 is obtained.
[0025] It should be noted that the electronic device 101 can be hardware or software. When the electronic device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or it can be implemented as a single server or a single terminal device. When the electronic device is embodied as software, it can be installed in the hardware devices listed above. It can be implemented as multiple software or software modules for providing distributed services, for example, or it can be implemented as a single software or software module. No specific limitation is made here.
[0026] It should be understood that Figure 1 The number of electronic devices in the embodiment is only for illustration. Any number of electronic devices may be provided according to implementation requirements.
[0027] Continue to refer Figure 2 , shows a process 200 of some embodiments of the method for repairing an image according to the present disclosure. The method for repairing an image comprises the following steps:
[0028] Step 201: Obtain an image to be restored.
[0029] In some embodiments, the execution subject (eg Figure 1 The electronic device 101 shown in the figure can receive the image to be repaired through a wired connection or a wireless connection. The image to be repaired is an image with image cracks. It should be noted that the wireless connection method can include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0030] In some embodiments, the image to be repaired is generally an image with cracks. As an example, the image to be repaired can be obtained by scanning a photo with cracks, or can be an image of a photographed object with cracks, such as a cracked glass or a cracked road surface due to disrepair.
[0031] Step 202: extracting a mask image of image cracks.
[0032] In some embodiments, the mask image may be a binary image consisting of pixel 0 and pixel 1. The execution subject may obtain the mask image by specifying data value, data range, region of interest and annotation file, or may apply any combination of the above options to obtain the mask image.
[0033] Step 203: extracting the edge image of the image to be restored.
[0034] In some embodiments, the edge image can be obtained by extracting the texture of the entire image to be repaired. The edge image not only shows the texture of the image cracks, but also shows the texture of the image content in the image to be repaired. As an example, the edge image can be obtained by the following methods: LBP method (Local binary patterns, local binary patterns), gray level co-occurrence matrix, wavelet transform, etc.
[0035] Step 204, obtaining a target image according to the image to be repaired, the mask image and the edge image.
[0036] In some embodiments, the image to be repaired, the mask image and the edge image may be processed through a tool library to obtain a target image. As an example, the tool library may be an OpenCV (open source computer vision) library, a FreeImage library, a CImg library, etc.
[0037] The methods provided by some embodiments of the present disclosure can perform more detailed repairs on the image to be repaired. Specifically, the inventors found that the reason why the image cracks cannot be well repaired in detail is that the texture of the image cracks is not accurately extracted. Based on this, the method of repairing images in some embodiments of the present disclosure not only extracts the mask image of the image cracks, but also extracts the edge image of the image to be repaired. Among them, the edge image is used to characterize the texture of the image content of the image to be repaired. Combining the mask image and the edge image can more accurately determine the pixel area of the crack, and then repair the crack in more detail.
[0038] Further references Figure 3 , which shows a process 300 of another embodiment of a method for repairing an image. The process 300 of the method for repairing an image comprises the following steps:
[0039] Step 301: Obtain an image to be restored.
[0040] Step 302: extracting the image crack region of the image to be repaired.
[0041] In some embodiments, the image crack region of the image to be repaired may be extracted by using existing image processing software, or the image crack region may be extracted by using color features.
[0042] Step 303: Generate a mask image according to the image crack area.
[0043] In some embodiments, the mask image can be obtained by binary processing the image crack region. The pixels of the extracted image crack region can be set to 1, and the pixels not in the image crack region can be set to 0, so as to obtain the mask image.
[0044] Step 304: extracting the edge image of the image to be repaired.
[0045] Step 305: Obtain a target image according to the image to be repaired, the mask image and the edge image.
[0046] In some embodiments, the specific implementation of steps 301, 304, and 305 and the technical effects thereof can be referred to in Figure 2 Steps 201, 203, and 204 in the corresponding embodiment are not described in detail here.
[0047] from Figure 3 It can be seen that Figure 2 Compared with the description of some corresponding embodiments, Figure 3 The process 300 of the method for repairing an image in some corresponding embodiments embodies how to obtain a mask image. The image crack region of the image to be repaired is extracted, and then a mask image is generated according to the image crack region, so that the generated mask image can more accurately display the details of the image crack.
[0048] Further references Figure 4 , which shows a process 400 of another embodiment of a method for repairing an image. The process 400 of the method for repairing an image comprises the following steps:
[0049] Step 401: Acquire an image to be restored.
[0050] Step 402: extracting a mask image of image cracks.
[0051] Step 403: remove noise from the image to be repaired to obtain a denoised image.
[0052] In some optional implementations of some embodiments, the image to be repaired is subjected to noise removal through a Gaussian filter to obtain a denoised image.
[0053] Step 404: determine at least one gradient parameter group for each pixel of the denoised image.
[0054] In some embodiments, the gradient parameter group includes a gradient value and a gradient angle, and the gradient value can represent the change in the pixel difference between the pixel point and the adjacent pixel point. The gradient angle can represent the angle between the pixel point and the adjacent pixel point, and the gradient value corresponds to the gradient angle one by one. As an example, the gradient angle can be 0 degrees, 45 degrees, and 90 degrees. The gradient value can be 23, 42, and 78. The gradient parameter group can be [23, 0 degrees], [42, 45 degrees], and [78, 90 degrees].
[0055] Step 405: Determine an edge image of the image to be restored according to at least one gradient parameter group.
[0056] In some optional implementations of some embodiments, for a pixel in a denoised image, the number of gradient values in at least one gradient parameter group corresponding to the pixel that is greater than the gradient value of the pixel is determined, and the validity of the pixel is determined based on the number; and the edge image is determined based on the validity. Figure 7 As shown, the pixel value of a certain pixel A in the denoised image is 29, the coordinate axis is centered on pixel A, and the gradient parameter group of pixel A can be [50, 0 degrees], [30, 45 degrees], [20, 90 degrees], [10, 135 degrees], [40, 180 degrees], [10, 225 degrees], [20, 270 degrees], [30, 315 degrees]. Select any two gradient angles, compare the gradient values corresponding to the gradient angles with the pixel value of pixel A, if the pixel value of pixel A is greater than the gradient values corresponding to the two gradient angles, it is recorded as 1, otherwise it is recorded as 0. As an example, select a gradient angle of 270 degrees and a gradient angle of 90 degrees, and the corresponding gradient values can be obtained as 20 and 20 according to the gradient parameter group. The pixel value 29 of pixel A is greater than the gradient values corresponding to the gradient angles of 270 degrees and 90 degrees, so the number is recorded as 1. Selecting a gradient angle of 0 degrees and a gradient angle of 135 degrees, the corresponding gradient values of 50 and 10 can be obtained according to the gradient parameter group. The pixel value 29 of pixel A is greater than the gradient value of the gradient angle of 135 degrees, and less than the gradient value corresponding to the gradient angle of 0 degrees, so the number is recorded as 0. Through multiple comparisons, the comparison results are statistically compared, and finally the total number of corresponding pixels A is obtained. When the above-mentioned pixel A is located at the image corner of the denoised image, the number of neighboring pixels may be 3, etc. In this way, the various directions of the neighboring pixels of pixel A can be judged to improve the accuracy and effectiveness of the judgment of the effectiveness of pixel A.
[0057] In some optional implementations of some embodiments, determining the validity of the pixel point according to the number includes: in response to the number being greater than a preset threshold, determining the pixel point as a valid pixel, otherwise, determining the pixel point as an invalid pixel. The valid pixel corresponds to the texture of the image. As an example, the preset threshold value may be 2, the number may be 4, and the pixel point is determined to be a valid pixel. As an example, the preset threshold value may be 3, the number may be 2, and the pixel point is determined to be an invalid pixel.
[0058] In some optional implementations of some embodiments, determining the edge image according to the validity includes: activating valid pixels to obtain an activation feature matrix; suppressing invalid pixels to obtain a suppression feature matrix; and constructing the edge image according to the activation feature matrix and the suppression feature matrix. Activating valid pixels means setting valid pixels to 1, and suppressing invalid pixels means setting invalid pixels to 0. In this way, the obtained edge image can be an image composed of pixels with pixel values of 1 and 0.
[0059] Step 406: convert the image to be restored, the mask image and the edge image into corresponding matrix of the image to be restored, the mask image matrix and the edge image matrix.
[0060] Step 407 , obtaining a target image based on the to-be-repaired image matrix, the mask image matrix, and the edge image matrix.
[0061] In some optional implementations of some embodiments, the image matrix to be repaired, the mask image matrix and the edge image matrix are spliced to obtain a spliced matrix; the spliced matrix and the edge image matrix are input into the target network to obtain a target image. As an example, the image matrix to be repaired, the mask image matrix and the edge image matrix can be spliced by increasing the dimension.
[0062] In some optional implementations of some embodiments, the target network includes a feature extraction layer, a downsampling layer, and an upsampling layer; and the splicing matrix and the edge image matrix are input into the target network to obtain a target image, including: inputting the splicing matrix into the feature extraction layer to obtain an image feature matrix, and performing the following steps: inputting the image feature matrix and the edge image matrix into the downsampling layer to obtain an image feature matrix corresponding to the downsampling layer; inputting the image feature matrix of the downsampling layer into the upsampling layer to obtain the target image. The target network can be a generative adversarial network or other network. In practice, the target network can include multiple downsampling layers and upsampling layers. As an example, the target network can include one feature extraction layer, two downsampling layers, and two upsampling layers. Correspondingly, the stitching matrix and the edge image matrix are input into the target network, and the steps of obtaining the target image can be: inputting the stitching matrix into the feature extraction layer to obtain the image feature matrix; inputting the image feature matrix and the edge image matrix into the first downsampling layer to obtain the image feature matrix corresponding to the first downsampling layer; inputting the image feature matrix and the edge image matrix corresponding to the first downsampling layer into the second downsampling layer to obtain the image feature matrix corresponding to the second downsampling layer; inputting the image feature matrix corresponding to the second downsampling layer into the first upsampling layer; using the output of the first upsampling layer as the input of the second upsampling layer; and the output of the second upsampling layer is the target image.
[0063] In some embodiments, the specific implementation of steps 401 and 402 and the technical effects thereof can be referred to in Figure 2 Steps 201 and 202 in the corresponding embodiment will not be described in detail here.
[0064] from Figure 4 It can be seen that Figure 3 Compared with the description of some corresponding embodiments, Figure 4The process 400 of the method for repairing an image in some corresponding embodiments embodies a method for extracting an edge image and a method for obtaining a target image based on an image to be repaired, a mask image and an edge image. The method for extracting an edge image is to remove noise from the image to be repaired to obtain a denoised image, so that the image is smoother. Thus, a gradient parameter group is obtained more accurately. By selecting any two gradient angles, the gradient value corresponding to the gradient angle is compared with the pixel value of the central pixel to obtain comparison results at different angles, so that the judgment of the effective pixel can be more accurate. Thus, a more detailed edge image can be obtained. A method for obtaining a target image is obtained by inputting a splicing matrix and an edge image matrix into a target network. Because the edge image matrix is used as part of the input in each step of downsampling of the target network, the details of the texture of the crack are not lost during the downsampling process, thereby obtaining a more detailed repaired target image.
[0065] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of an apparatus for repairing an image. These apparatus embodiments are similar to Figure 2 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.
[0066] like Figure 5 As shown, the apparatus 500 for repairing an image in some embodiments includes: an acquisition unit 501, a first extraction unit 502, a second extraction unit 503 and a generation unit 504. The acquisition unit 501 is configured to acquire an image to be repaired, where the image to be repaired is an image with image cracks; the first extraction unit 502 is configured to extract a mask image of the image cracks; the second extraction unit 503 is configured to extract an edge image of the image to be repaired, where the edge image is used to characterize the texture of the image content of the image to be repaired; and the generation unit 504 is configured to obtain a target image according to the image to be repaired, the mask image and the edge image.
[0067] In an optional implementation of some embodiments, the first extraction unit 502 is further configured to: extract an image crack region of the image to be repaired; and generate a mask image according to the image crack region.
[0068] In an optional implementation of some embodiments, the second extraction unit 503 is further configured to: remove noise from the image to be repaired to obtain a denoised image; determine at least one gradient parameter group for each pixel point of the denoised image, the gradient parameter group includes a gradient value and a gradient angle, the gradient value represents the change in the pixel difference between the pixel point and the adjacent pixel points, the gradient angle represents the angle between the pixel point and the adjacent pixel points, and the gradient value and the gradient angle correspond one-to-one; determine the edge image of the image to be repaired based on at least one gradient parameter group.
[0069] In an optional implementation of some embodiments, the second extraction unit 503 is further configured to: remove noise from the image to be repaired by using a Gaussian filter to obtain a denoised image.
[0070] In an optional implementation of some embodiments, the second extraction unit 503 is further configured to: for a pixel point in the denoised image, determine the number of gradient values in at least one gradient parameter group corresponding to the pixel point that is greater than the gradient value of the pixel point, and determine the validity of the pixel point based on the number; determine the edge image based on the validity.
[0071] In an optional implementation of some embodiments, the second extraction unit 503 is further configured to: in response to the number being greater than a preset threshold, determine that the pixel point is a valid pixel; otherwise, determine that the pixel point is an invalid pixel.
[0072] In an optional implementation of some embodiments, the second extraction unit 503 is further configured to: activate valid pixels to obtain an activation feature matrix; suppress invalid pixels to obtain a suppression feature matrix; and construct an edge image based on the activation feature matrix and the suppression feature matrix.
[0073] In an optional implementation of some embodiments, the generation unit 504 is further configured to: convert the image to be repaired, the mask image and the edge image into corresponding matrices of the image to be repaired, the mask image matrix and the edge image matrix; and obtain the target image based on the matrix of the image to be repaired, the mask image matrix and the edge image matrix.
[0074] In an optional implementation of some embodiments, the generation unit 504 is further configured to: splice the image matrix to be repaired, the mask image matrix and the edge image matrix to obtain a spliced matrix; and input the spliced matrix and the edge image matrix into the target network to obtain a target image.
[0075] In an optional implementation of some embodiments, the target network includes a feature extraction layer, a downsampling layer and an upsampling layer, and the generation unit 504 is further configured to: input the splicing matrix into the feature extraction layer to obtain an image feature matrix, and perform the following steps: input the image feature matrix and the edge image matrix into the downsampling layer to obtain the image feature matrix of the corresponding downsampling layer; input the image feature matrix of the downsampling layer into the upsampling layer to obtain the target image.
[0076] It is understood that the storage units described in the device 500 are similar to those described in the reference Figure 2 Therefore, the operations, features and beneficial effects described above for the method are also applicable to the device 500 and the units included therein, and will not be described in detail here.
[0077] Reference below Figure 6 , which shows an electronic device (eg, Figure 1 The electronic devices in some embodiments of the present disclosure may include but are not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0078] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0079] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 6 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0080] In particular, according to some embodiments of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of some embodiments of the present disclosure are executed.
[0081] It should be noted that the computer-readable medium recorded in some embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In some embodiments of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0082] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0083] The computer-readable medium may be included in the electronic device; or it may exist independently without being assembled into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains the image to be repaired, the image to be repaired is an image with image cracks; extracts the mask image of the image cracks; extracts the edge image of the image to be repaired, the edge image is used to characterize the texture of the image content of the image to be repaired; obtains the target image according to the image to be repaired, the mask image and the edge image. The computer program code for performing the operations of some embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, the programming languages including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. The program code may be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0084] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0085] The units described in some embodiments of the present disclosure may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes an acquisition unit, a first extraction unit, a second extraction unit, and a generation unit. The names of these units do not constitute limitations on the units themselves in some cases, for example, the acquisition unit may also be described as a "unit for acquiring an image to be restored".
[0086] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0087] According to one or more embodiments of the present disclosure, a method for repairing an image is provided, comprising: acquiring an image to be repaired, where the image to be repaired is an image with image cracks; extracting a mask image of the image cracks; extracting an edge image of the image to be repaired, where the edge image is used to characterize the texture of the image content of the image to be repaired; and obtaining a target image based on the image to be repaired, the mask image and the edge image.
[0088] According to one or more embodiments of the present disclosure, extracting a mask image of an image crack includes: extracting an image crack region of an image to be repaired; and generating a mask image according to the image crack region.
[0089] According to one or more embodiments of the present disclosure, extracting an edge image of an image to be repaired includes: removing noise from the image to be repaired to obtain a denoised image; determining at least one gradient parameter group for each pixel point of the denoised image, the gradient parameter group including a gradient value and a gradient angle, the gradient value indicating a change in a pixel difference between a pixel point and adjacent pixels, the gradient angle indicating an angle between a pixel point and adjacent pixels, the gradient value and the gradient angle corresponding one to one; and determining an edge image of the image to be repaired based on at least one gradient parameter group.
[0090] According to one or more embodiments of the present disclosure, removing noise from the image to be repaired to obtain a denoised image includes: removing noise from the image to be repaired through a Gaussian filter to obtain a denoised image.
[0091] According to one or more embodiments of the present disclosure, an edge image of an image to be repaired is determined based on at least one gradient parameter group, including: for a pixel point in the denoised image, determining the number of gradient values in at least one gradient parameter group corresponding to the pixel point that are greater than the gradient value of the pixel point, and determining the validity of the pixel point based on the number; and determining the edge image based on the validity.
[0092] According to one or more embodiments of the present disclosure, determining the validity of the pixel point according to the quantity includes: in response to the number being greater than a preset threshold, determining the pixel point as a valid pixel, otherwise, determining the pixel point as an invalid pixel.
[0093] According to one or more embodiments of the present disclosure, determining an edge image based on validity includes: activating valid pixels to obtain an activation feature matrix; suppressing invalid pixels to obtain a suppression feature matrix; and constructing an edge image based on the activation feature matrix and the suppression feature matrix.
[0094] According to one or more embodiments of the present disclosure, a target image is obtained based on an image to be repaired, a mask image and an edge image, including: converting the image to be repaired, the mask image and the edge image into corresponding matrices of the image to be repaired, the mask image matrix and the edge image matrix; and obtaining the target image based on the matrix of the image to be repaired, the mask image matrix and the edge image matrix.
[0095] According to one or more embodiments of the present disclosure, a target image is obtained based on an image matrix to be repaired, a mask image matrix and an edge image matrix, including: splicing the image matrix to be repaired, the mask image matrix and the edge image matrix to obtain a spliced matrix; and inputting the spliced matrix and the edge image matrix into a target network to obtain a target image.
[0096] According to one or more embodiments of the present disclosure, a target network includes a feature extraction layer, a downsampling layer and an upsampling layer, and a stitching matrix and an edge image matrix are input into the target network to obtain a target image, including: inputting the stitching matrix into the feature extraction layer to obtain an image feature matrix, and performing the following steps: inputting the image feature matrix and the edge image matrix into the downsampling layer to obtain an image feature matrix corresponding to the downsampling layer; inputting the image feature matrix of the downsampling layer into the upsampling layer to obtain the target image.
[0097] According to one or more embodiments of the present disclosure, there is provided a device for repairing an image, comprising: an acquisition unit, configured to acquire an image to be repaired, where the image to be repaired is an image with image cracks; a first extraction unit, configured to extract a mask image of the image cracks; a second extraction unit, configured to extract an edge image of the image to be repaired, where the edge image is used to characterize the texture of the image content of the image to be repaired; and a generation unit, configured to obtain a target image based on the image to be repaired, the mask image and the edge image.
[0098] According to one or more embodiments of the present disclosure, the first extraction unit is further configured to: extract an image crack region of the image to be repaired; and generate a mask image according to the image crack region.
[0099] According to one or more embodiments of the present disclosure, the second extraction unit is further configured to: remove noise from the image to be repaired to obtain a denoised image; determine at least one gradient parameter group for each pixel point of the denoised image, the gradient parameter group includes a gradient value and a gradient angle, the gradient value represents the change in the pixel difference between the pixel point and the adjacent pixel points, the gradient angle represents the angle between the pixel point and the adjacent pixel points, and the gradient value and the gradient angle correspond one to one; determine the edge image of the image to be repaired based on at least one gradient parameter group.
[0100] According to one or more embodiments of the present disclosure, the second extraction unit is further configured to: remove noise from the image to be repaired through a Gaussian filter to obtain a denoised image.
[0101] According to one or more embodiments of the present disclosure, the second extraction unit is further configured to: for a pixel point in the denoised image, determine the number of gradient values in at least one gradient parameter group corresponding to the pixel point that is greater than the gradient value of the pixel point, and determine the validity of the pixel point based on the number; determine the edge image based on the validity.
[0102] According to one or more embodiments of the present disclosure, the second extraction unit is further configured to: in response to the number being greater than a preset threshold, determine the pixel point as a valid pixel; otherwise, determine the pixel point as an invalid pixel.
[0103] According to one or more embodiments of the present disclosure, the second extraction unit is further configured to: activate valid pixels to obtain an activation feature matrix; suppress invalid pixels to obtain a suppression feature matrix; and construct an edge image based on the activation feature matrix and the suppression feature matrix.
[0104] According to one or more embodiments of the present disclosure, the generation unit is further configured to: convert the image to be repaired, the mask image and the edge image into corresponding image matrix to be repaired, the mask image matrix and the edge image matrix; and obtain the target image based on the image matrix to be repaired, the mask image matrix and the edge image matrix.
[0105] According to one or more embodiments of the present disclosure, the generation unit is further configured to: splice the image matrix to be repaired, the mask image matrix and the edge image matrix to obtain a spliced matrix; input the spliced matrix and the edge image matrix into the target network to obtain a target image.
[0106] According to one or more embodiments of the present disclosure, the target network includes a feature extraction layer, a downsampling layer and an upsampling layer, and the generation unit is further configured to: input the splicing matrix into the feature extraction layer to obtain an image feature matrix, and perform the following steps: input the image feature matrix and the edge image matrix into the downsampling layer to obtain the image feature matrix of the corresponding downsampling layer; input the image feature matrix of the downsampling layer into the upsampling layer to obtain the target image.
[0107] The above descriptions are only some preferred embodiments of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) and the technical solutions formed.
Claims
1. A method for repairing an image, comprising: Acquire an image to be repaired, where the image to be repaired is an image with image cracks; extracting a mask image of cracks in the image; Extracting an edge image of the image to be restored, wherein the edge image is used to represent the texture of the image content of the image to be restored; Converting the image to be repaired, the mask image and the edge image into a corresponding matrix of the image to be repaired, a matrix of the mask image and a matrix of the edge image; Splicing the to-be-repaired image matrix, the mask image matrix and the edge image matrix to obtain a spliced matrix; inputting the spliced matrix and the edge image matrix into a target network to obtain a target image; Wherein, the target network includes a feature extraction layer, a downsampling layer and an upsampling layer; and The step of inputting the stitching matrix and the edge image matrix into a target network to obtain a target image comprises: Input the stitching matrix into the feature extraction layer to obtain an image feature matrix, and perform the following steps: input the image feature matrix and the edge image matrix into the downsampling layer to obtain an image feature matrix corresponding to the downsampling layer; The image feature matrix of the down-sampling layer is input into the up-sampling layer to obtain the target image.
2. The method according to claim 1, wherein: The extracting the mask image of the image cracks comprises: Extracting an image crack region of the image to be repaired; The mask image is generated according to the image crack area.
3. The method according to claim 1, wherein: The step of extracting the edge image of the image to be repaired comprises: Denoising the image to be repaired to obtain a denoised image; Determine at least one gradient parameter group for each pixel of the denoised image, the gradient parameter group including a gradient value and a gradient angle, the gradient value represents a change in a pixel difference between a pixel and an adjacent pixel, the gradient angle represents an angle between a pixel and an adjacent pixel, and the gradient value corresponds to the gradient angle one by one; An edge image of the image to be restored is determined according to the at least one gradient parameter group.
4. The method according to claim 3, wherein: The step of removing noise from the image to be repaired to obtain a denoised image comprises: The image to be repaired is subjected to noise removal through a Gaussian filter to obtain the denoised image.
5. The method according to claim 3, wherein: The step of determining the edge image of the image to be repaired according to the at least one gradient parameter group comprises: For a pixel in the denoised image, determining the number of gradient values in the at least one gradient parameter group corresponding to the pixel that are greater than the gradient value of the pixel, and determining the validity of the pixel according to the number; The edge image is determined according to the validity.
6. The method according to claim 5, wherein: Determining the validity of the pixel point according to the quantity includes: In response to the number being greater than a preset threshold, the pixel is determined to be a valid pixel; otherwise, the pixel is determined to be an invalid pixel.
7. The method according to claim 6, wherein: The step of determining the edge image according to the validity comprises: Activating the effective pixels to obtain an activation feature matrix; Suppressing the invalid pixels to obtain a suppression feature matrix; The edge image is constructed according to the activation feature matrix and the inhibition feature matrix.
8. A device for repairing an image, comprising: An acquisition unit is configured to acquire an image to be repaired, wherein the image to be repaired is an image with image cracks; A first extraction unit is configured to extract a mask image of the image crack; A second extraction unit is configured to extract an edge image of the image to be restored, wherein the edge image is used to represent a texture of an image content of the image to be restored; A generating unit configured to convert the image to be repaired, the mask image and the edge image into a corresponding matrix of the image to be repaired, a matrix of the mask image and a matrix of the edge image; Splicing the to-be-repaired image matrix, the mask image matrix and the edge image matrix to obtain a spliced matrix; inputting the spliced matrix and the edge image matrix into a target network to obtain a target image; Wherein, the target network includes a feature extraction layer, a downsampling layer and an upsampling layer; and The step of inputting the stitching matrix and the edge image matrix into a target network to obtain a target image comprises: Input the stitching matrix into the feature extraction layer to obtain an image feature matrix, and perform the following steps: input the image feature matrix and the edge image matrix into the downsampling layer to obtain an image feature matrix corresponding to the downsampling layer; The image feature matrix of the down-sampling layer is input into the up-sampling layer to obtain the target image.
9. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
