Image processing method and apparatus, device, and storage medium

The target image block repair technology through edge information extraction and matching degree determination solves the line alignment problem in image repair, improves the image repair effect, and ensures the integrity of the image.

WO2024179333A1PCT designated stage expired Publication Date: 2024-09-06BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/077809
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-28
Filing Date
2024-02-20
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

When existing image repair technology deals with the presence of lines in the area to be repaired, it is difficult to ensure that the lines in the original area to be repaired and the non-to-be repaired areas in the repaired image are aligned, resulting in poor repair results and a lack of effective solutions.

Method used

By acquiring the image, determine the area to be repaired, perform edge information extraction processing, generate an edge information image, and perform repairs based on the target image block with the highest matching degree between the area to be repaired and the edge information image block to ensure that the repaired lines are aligned.

Benefits of technology

It improves the line alignment effect of the areas to be repaired and the areas not to be repaired after image repair, improves the image repair effect, and ensures the integrity of the repaired image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024077809_06092024_PF_FP
    Figure CN2024077809_06092024_PF_FP
Patent Text Reader

Abstract

Embodiments of the present disclosure relate to an image processing method and apparatus, a device, and a storage medium. The method comprises: acquiring a first image; in response to an operation of a user, determining a region to be restored of the first image; extracting edge information of the first image to generate a second image; according to an image block to be restored of said region and an edge information image block in the second image, determining a target image block having the highest matching degree with the image block to be restored; and restoring said region on the basis of the target image block so as to obtain a target restored image.
Need to check novelty before this filing date? Find Prior Art

Description

Image processing method, device, equipment and storage medium

[0001] This application claims priority to the Chinese invention patent application entitled “Image processing method, device, equipment and storage medium” and application number 202310215037.5 filed on February 28, 2023. The entire contents of that application are incorporated by reference into this application. Technical Field

[0002] The embodiments of the present disclosure relate to the field of computer technology, and in particular to an image processing method, apparatus, device, and storage medium. Background Art

[0003] Image inpainting, which involves reconstructing missing parts of an image, has a wide range of applications. For example, if image content is missing due to erasures or data packet loss during image output, resulting in areas to be inpainted, image inpainting techniques can be used to restore the missing areas and obtain a complete image.

[0004] Currently, image inpainting typically involves searching for image content similar to the area to be inpainted in non-inpainted areas based on RGB information, and then filling the inpainted area with the found content. However, when the inpainted area contains lines, the lines in the original inpainted area and the original non-inpainted area in the inpainted image may not align after inpainting, resulting in poor image inpainting results. Currently, there is no effective solution to this problem.

[0005] Summary of the Invention

[0006] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide an image processing method, apparatus, device and storage medium.

[0007] A first aspect of the present disclosure provides an image processing method, the method comprising:

[0008] acquiring a first image;

[0009] In response to a user operation, determining a region to be repaired in the first image;

[0010] Performing edge information extraction processing on the first image to generate a second image;

[0011] Determine the target image block with the highest matching degree with the image block to be repaired based on the image block to be repaired in the area to be repaired and the edge information image block in the second image;

[0012] The area to be repaired is repaired based on the target image block to obtain a target repaired image.

[0013] A second aspect of the present disclosure provides an image processing apparatus, the apparatus comprising:

[0014] A first acquisition module, configured to acquire a first image;

[0015] A first determining module, configured to determine a to-be-repaired area of ​​the first image in response to a user operation;

[0016] A generating module, configured to perform edge information extraction processing on the first image to generate a second image;

[0017] A second determining module is configured to determine a target image block having the highest matching degree with the image block to be repaired based on the image block to be repaired in the area to be repaired and the edge information image block in the second image;

[0018] The restoration module is used to restore the area to be restored based on the target image block to obtain a target restored image.

[0019] A third aspect of an embodiment of the present disclosure provides an electronic device, which includes: a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method of the first aspect above.

[0020] A fourth aspect of an embodiment of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of the first aspect described above can be implemented.

[0021] A fifth aspect of an embodiment of the present disclosure provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, the method of the first aspect can be implemented.

[0022] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art:

[0023] The disclosed embodiment can acquire a first image; determine an area to be repaired in the first image in response to a user operation; perform edge information extraction processing on the first image to generate a second image; determine a target image block with the highest degree of match with the image block to be repaired based on the image block to be repaired in the area to be repaired and the edge information image block in the second image; and repair the area to be repaired based on the target image block to obtain a target repaired image. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0025] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0026] FIG1 is a flow chart of an image processing method provided by an embodiment of the present disclosure;

[0027] FIG2 is a schematic diagram of a first image provided by an embodiment of the present disclosure;

[0028] FIG3 is a schematic diagram of a second image provided by an embodiment of the present disclosure;

[0029] FIG4 is a schematic diagram of a first image after restoration provided by an embodiment of the present disclosure;

[0030] FIG5 is a flow chart of another image processing method provided by an embodiment of the present disclosure;

[0031] FIG6 is a logic diagram of determining a candidate matching area according to an embodiment of the present disclosure;

[0032] FIG7 is a schematic structural diagram of an image processing device provided by an embodiment of the present disclosure;

[0033] FIG8 is a schematic structural diagram of an electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0034] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0035] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0036] FIG1 is a flowchart of an image processing method provided by an embodiment of the present disclosure. The method can be performed by an electronic device and is applicable to image restoration scenarios. The electronic device can be exemplarily understood as a device such as a mobile phone, tablet computer, laptop computer, desktop computer, smart TV, etc., but is not limited thereto.

[0037] As shown in FIG1 , the method provided in this embodiment includes the following steps:

[0038] S110: Acquire a first image.

[0039] In some embodiments, S110 may include: receiving a first image sent by another electronic device; or reading the first image from a storage device, but is not limited thereto.

[0040] S120 : In response to a user operation, determine a region to be repaired in the first image.

[0041] Specifically, the area to be repaired refers to an area consisting of unknown pixels.

[0042] Correspondingly, the first image also includes a non-to-be-repaired area, wherein the non-to-be-repaired area refers to an area composed of known pixels in the first image.

[0043] In some embodiments, S120 may include: in response to a user erasing operation using an eraser pen, determining the area erased by the erasing operation as the area to be repaired; or, in response to a user triggering an operation on a control for identifying an area to be repaired, identifying the area to be repaired in the first image. However, the present invention is not limited thereto.

[0044] For example, FIG2 is a schematic diagram of a first image provided by an embodiment of the present disclosure. As shown in FIG2 , when photographing a playground track, a cat is located on the track, so the captured image includes the cat. The user can erase the cat from the image using an eraser pen. Since the pixels in the erased area become unknown pixels, the first image includes an area to be repaired 210 and an area not to be repaired 220.

[0045] S130: Perform edge information extraction processing on the first image to generate a second image.

[0046] Specifically, the second image is used to represent the line features of the first image. The second image includes a portion representing the line features of the area to be repaired and a portion representing the line features of the area not to be repaired. The "line features of the area to be repaired" herein refer to the line features corresponding to the area to be repaired if it is repaired.

[0047] Specifically, the second image and the first image have the same size, and the grayscale values ​​of the pixels corresponding to the lines in the second image are different from the grayscale values ​​of other pixels, so as to clearly display the lines.

[0048] For example, Figure 3 is a schematic diagram of a second image provided by an embodiment of the present disclosure. As shown in Figures 2 and 3, edge information extraction processing is performed on Figure 2 to generate Figure 3 representing the line features of Figure 2. Figure 3 includes not only image regions representing line features of the area to be repaired, but also image regions representing line features of the area not to be repaired. Figures 2 and 3 are the same size, and the grayscale value of the pixels corresponding to the lines in Figure 3 is 0 (black), while the grayscale value of the other pixels is 255 (white).

[0049] In some embodiments, the area to be repaired of the first image can be repaired at low resolution to obtain a third image, and the third image can be processed for edge information extraction to obtain line features of the area to be repaired and line features of the area not to be repaired, wherein the "low-resolution repair" mentioned here means that the resolution of the third image obtained by repair is smaller than the resolution of the first image; and the second image is generated based on the line features of the area to be repaired and the line features of the area not to be repaired.

[0050] In one example, a trained machine learning model may be used to perform low-resolution restoration on the area to be restored in the first image. Accordingly, S120 may include:

[0051] S121: Obtain a first model for performing low-resolution restoration on the area to be restored in the image.

[0052] Specifically, the first model is generated by pre-training based on the area to be repaired and the corresponding low-resolution repair area in the image sample set.

[0053] Specifically, the first model can adopt any possible type of machine learning model, which is not limited here.

[0054] Specifically, the training process of the first model may include: obtaining a sample image set, wherein the sample image set includes a first sample image and its corresponding first label image, the first sample image includes an area to be repaired and an area not to be repaired, and the first label image includes a low-resolution repaired area and an area not to be repaired obtained by performing low-resolution repair on the area to be repaired in the first sample image; inputting the first sample image into the first model for processing, outputting a low-resolution repaired image after low-resolution repair of the area to be repaired, and calculating the loss function of the first model based on the first label image and its corresponding low-resolution repaired image; if the loss function of the first model does not meet the preset training end condition of the first model, adjusting the parameters in the first model until the loss function of the first model meets the preset training end condition of the first model. However, the present invention is not limited to this.

[0055] S122: Input the first image into the first model to obtain a third image.

[0056] Specifically, the first image is input into the first model for processing, and a third image is output after the area to be repaired is repaired with low resolution.

[0057] S123: Perform edge information extraction processing on the third image to generate a second image.

[0058] Specifically, a preset edge extraction operator may be used to extract edge information from the third image to generate the second image. The preset edge extraction operator may be any possible edge extraction operator, such as, but not limited to, a Canny operator or a Sobel operator.

[0059] Of course, in another example, a preset low-resolution restoration algorithm may be used to perform low-resolution restoration on the image missing region of the first image, but the present invention is not limited thereto.

[0060] It can be understood that since low-resolution restoration is a relatively rough restoration, the restoration efficiency is higher and the required computing resources are less. In this way, the third image of the low-resolution restoration can be quickly obtained, which is conducive to improving the acquisition efficiency of the second image representing the line features of the first image, thereby improving the overall image restoration efficiency, and the performance requirements for electronic equipment are relatively low, which is conducive to the promotion of image restoration methods on low-end electronic devices.

[0061] It can also be understood that using a machine learning model (i.e., the first model) to perform low-resolution repair on the area to be repaired can make the low-resolution repair more accurate, which is conducive to extracting more accurate line features of the area to be repaired, thereby laying the foundation for subsequent fine and accurate repair of the first image.

[0062] In other embodiments, line features of the area to be repaired can be inferred based on the area not to be repaired, and edge information extraction processing can be performed on the area not to be repaired to obtain line features of the area not to be repaired; and a second image can be generated based on the line features of the area to be repaired and the line features of the area not to be repaired.

[0063] In one example, a trained machine learning model can be used to infer line features of the area to be repaired and to extract edge information from the area not to be repaired. Accordingly, S120 may include:

[0064] S1221. Obtain a second model for performing edge extraction on an image including an area to be repaired.

[0065] Specifically, the second model is generated by pre-training based on the missing image sample set and the image line features corresponding to the complete image.

[0066] Specifically, the second model can adopt any possible type of machine learning model and is not limited here.

[0067] Specifically, the training process of the second model may include: obtaining a set of missing sample images including a second sample image and image line features corresponding to a complete image, wherein the second sample image includes an area to be repaired and an area not to be repaired, and the second sample image is obtained by erasing a portion of the image area of ​​the complete image; inputting the second sample image into the second model for processing, outputting an image representing the line features of the second sample image, and calculating a loss function of the second model based on the image representing the line features of the second sample image and the image line features corresponding to the complete image; if the loss function of the second model does not meet a preset training end condition of the second model, adjusting parameters in the second model until the loss function of the second model meets the preset training end condition of the second model. However, the present invention is not limited to this.

[0068] S1222: Input the first image into the second model to obtain a second image.

[0069] Specifically, the first image is input into the second model for processing, and a second image representing the line features of the first image is output.

[0070] It can be understood that by inferring the line features of the area to be repaired based on the area not to be repaired and performing edge information extraction processing on the area not to be repaired, a second image representing the line features of the first image can be directly obtained. This is conducive to improving the efficiency of obtaining the second image, and thus improving the overall image restoration efficiency.

[0071] It can also be understood that by processing the first image using a machine learning model (i.e., the second model), the line features of the area to be repaired can be more accurately extracted, thereby laying the foundation for subsequent fine and accurate repair of the first image.

[0072] S140 , determining a target image block with the highest matching degree with the image block to be repaired based on the image block to be repaired in the area to be repaired and the edge information image block in the second image.

[0073] Specifically, the image block to be repaired is partially in the area to be repaired and partially in the area not to be repaired, so the image block to be repaired includes known pixels and unknown pixels. Adjacent image blocks to be repaired may or may not overlap, and this is not limited.

[0074] Specifically, the position of the edge information image block in the second image is the same as the position of its corresponding image block to be repaired in the first image. The position of the image block to be repaired in the first image can be represented by the coordinates of all pixels in the image block to be repaired in the first image, the coordinates of the pixels at each vertex of the image block to be repaired in the first image, or the coordinates of the pixels at the center of the image block to be repaired in the first image and the size of the image block to be repaired, but is not limited to these. The position of the edge information image block in the second image is similar and will not be further described here.

[0075] In some embodiments, the method further includes: dividing an image block to be repaired containing known pixels and unknown pixels according to the edge of the area to be repaired; and obtaining an edge information image block corresponding to the image block to be repaired at the same position in the second image based on the position of the image block to be repaired in the first image.

[0076] For example, referring again to Figures 2 and 3 , a plurality of image blocks to be repaired are divided according to the edge of the area to be repaired 210, and based on the position of the image block to be repaired in the first image, an edge information image block corresponding to the image block to be repaired is obtained at the same position in the second image. It should be noted that, for ease of drawing, Figure 2 only shows the first image block to be repaired 221 and the second image block to be repaired 222. Accordingly, Figure 3 only shows the first edge information image block 231 corresponding to the first image block to be repaired 221 and the second edge information image block 232 corresponding to the second image block to be repaired 222, and does not show the remaining image blocks to be repaired and all edge information image blocks.

[0077] In other embodiments, the method further includes: in response to a user's division operation on the image block to be repaired in the first image, dividing the image block to be repaired containing known pixels and unknown pixels; and based on the position of the image block to be repaired in the first image, obtaining an edge information image block corresponding to the image block to be repaired at the same position in the second image.

[0078] Specifically, the target image block is an image block located in a non-to-be-repaired area and having the highest matching degree with the image block to be repaired, wherein the "matching degree" mentioned here refers to the combination of the matching degree with the known pixels of the image block to be repaired and the matching degree with the edge information of the edge information image block.

[0079] In some embodiments, S140 may include: obtaining a third model for matching the target image block, wherein the third model is pre-trained and generated based on the image block to be repaired, the edge information image block, and the corresponding image block with the highest matching degree in the image sample set; inputting the image block to be repaired and the edge information image block into the third model for processing, and outputting the target image block with the highest matching degree with the image block to be repaired.

[0080] For example, referring again to Figures 2 and 3 , based on the known pixels of the first image block to be repaired 221 and the edge information of the first edge information image block 231, a first target image block 241 with the highest degree of match to the first image block to be repaired 221 is determined. Based on the known pixels of the second image block to be repaired 222 and the edge information of the second edge information image block 232, a second target image block 242 with the highest degree of match to the second image block to be repaired 222 is determined. The same applies to other image blocks to be repaired not shown in Figure 2 and will not be described in detail here.

[0081] S150 , repairing the to-be-repaired area based on the target image block to obtain a target repaired image.

[0082] In some embodiments, repairing the image block to be repaired based on the target image block may include: determining, in the target image block, a first pixel region corresponding to known pixels in the image block to be repaired, and a second pixel region corresponding to unknown pixels in the image block to be repaired; filling the corresponding positions of the unknown pixels in the image block to be repaired with pixel values ​​of the second pixel region; and updating the corresponding positions of the known pixels in the image block to be repaired based on the pixel values ​​of the first pixel region. Of course, updating the known pixels in the image block to be repaired is not necessary, and this is not limited to this.

[0083] It can be understood that updating both unknown pixels and known pixels in the image block to be repaired can make the pixel values ​​of the image block to be repaired more matched and more harmonious.

[0084] Optionally, after S150 , the repair process may be continued based on the new area to be repaired.

[0085] Specifically, after the image block to be repaired is repaired based on the target image block, some unknown pixels in the area to be repaired are repaired and turned into known pixels. Therefore, the area to be repaired is reduced and becomes a new area to be repaired. At this time, based on the new area to be repaired, according to the image block to be repaired in the new area to be repaired and the edge information image block in the second image, the target image block with the highest matching degree with the image block to be repaired in the new area to be repaired can be determined, and the new area to be repaired can be repaired based on the target image block. This cycle is repeated, the area to be repaired will continue to shrink, and eventually the first image can be repaired into a complete image.

[0086] In the embodiment of the present disclosure, when determining a target image block that matches an image block to be repaired in an area not to be repaired, not only the known pixels of the image block to be repaired are considered, but also the edge information of the edge information image block corresponding to the image block to be repaired. In this way, the edge information in the determined target image block can be more closely matched with the edge information of the edge information image block. As a result, after the image block to be repaired is repaired based on the target image block, the alignment effect of the lines in the repaired image block to be repaired and the lines in its adjacent image blocks is better, thereby improving the problem of the lines in the original area to be repaired and the original area not to be repaired being unable to be aligned after image repair, and improving the image repair effect.

[0087] For example, Figure 4 is a schematic diagram of a first image after restoration provided by an embodiment of the present disclosure. As shown in Figures 2 and 4, after performing image restoration on Figure 2, a complete image is obtained as shown in Figure 4.

[0088] In the embodiment of the present disclosure, when determining a target image block that matches an image block to be repaired in an area not to be repaired, not only the known pixels of the image block to be repaired are considered, but also the edge information of the edge information image block corresponding to the image block to be repaired. In this way, the edge information in the determined target image block can be more closely matched with the edge information of the edge information image block. As a result, after the image block to be repaired is repaired based on the target image block, the alignment effect of the lines in the repaired image block to be repaired and the lines in its adjacent image blocks is better, thereby improving the problem of the lines in the original area to be repaired and the original area not to be repaired being unable to be aligned after image repair, and improving the image repair effect.

[0089] Figure 5 is a flow chart of another image processing method provided by an embodiment of the present disclosure. The present disclosure embodiment is optimized based on the above embodiment, and the present disclosure embodiment can be combined with various optional solutions in one or more of the above embodiments.

[0090] As shown in FIG5 , the image processing method may include the following steps.

[0091] S510: Acquire a first image.

[0092] Specifically, S510 is similar to S110 and will not be described in detail here.

[0093] S520: In response to a user operation, determine a region to be repaired in the first image.

[0094] Specifically, S520 is similar to S120 and will not be described in detail here.

[0095] S530: Perform edge information extraction processing on the first image to generate a second image.

[0096] Specifically, S530 is similar to S130 and will not be described in detail here.

[0097] S540: Determine, in the non-to-be-repaired area, a plurality of first candidate image blocks to be matched with the to-be-repaired image block.

[0098] Specifically, the first candidate image block has the same size as the image block to be repaired.

[0099] In some embodiments, S540 may include: randomly selecting a plurality of first candidate image blocks in the non-to-be-repaired area to match the to-be-repaired image block.

[0100] In some other embodiments, S540 may include: S541, determining a candidate matching area in the non-to-be-repaired area according to the position of the to-be-repaired image block.

[0101] Specifically, the candidate matching area belongs to a non-to-be-repaired area.

[0102] In an example, S541 may include: taking a region of a preset shape that is at a preset distance from the position of the image block to be repaired as a candidate matching region.

[0103] Specifically, the preset distance and the preset shape can be set by those skilled in the art according to actual conditions and are not limited here.

[0104] In another example, S541 may include: determining a candidate matching area corresponding to the image block to be repaired based on a position of a target image block corresponding to the image block to be repaired adjacent to the image block to be repaired, wherein the target image block corresponding to the image block to be repaired adjacent to the image block to be repaired is located within the candidate matching area corresponding to the image block to be repaired.

[0105] For example, Figure 6 is a schematic diagram of a logic for determining candidate matching regions according to an embodiment of the present disclosure. As shown in Figure 6, a third image block to be repaired 611 corresponds to a third target image block 621. Based on the position of the third target image block 621, a candidate matching region 620 corresponding to the fourth image block to be repaired 612 is determined.

[0106] It can be understood that local areas in an image usually have structural consistency, that is, the similarity between different image blocks in a local area is relatively high. Therefore, determining a candidate matching area in an area not to be repaired based on the position of the image block to be repaired is beneficial for making the candidate matching area located near the image block to be repaired or the two are in the same local area. In this way, the first candidate image block determined in the candidate matching area has a high similarity with the image block to be repaired, which is beneficial for subsequently searching for the target image block with fewer searches.

[0107] S542 : Determine a plurality of first candidate image blocks that match the image block to be repaired in the candidate matching area according to a preset random algorithm and pixel adjustment value based on the size of the image block to be repaired.

[0108] Specifically, any possible random algorithm can be used, and this is not limited. In addition, the specific value of the pixel adjustment value can be set by those skilled in the art according to actual conditions, and is not limited here.

[0109] In an example, S542 may include: randomly selecting at least one first candidate image block in the candidate matching area according to a preset random algorithm based on the size of the image block to be repaired; and obtaining the first candidate image block at a position offset by a pixel adjustment value in a preset direction based on the position of the randomly selected first candidate image block, according to the size of the image block to be repaired, wherein the pixel adjustment values ​​corresponding to different preset directions may be the same or different, and are not limited here.

[0110] Exemplarily, referring to FIG6 , three first candidate image blocks 622 that match the fourth image block 612 to be repaired are determined in the candidate matching area 620 according to a preset random algorithm and pixel adjustment value based on the size of the fourth image block 612 to be repaired.

[0111] In another example, S542 may include: randomly selecting multiple first candidate image blocks in the candidate matching area according to a preset random algorithm based on the size of the image block to be repaired, wherein the distance between any two first candidate image blocks is greater than or equal to the pixel adjustment value.

[0112] It can be understood that by determining multiple first candidate image blocks in the candidate matching area according to a preset random algorithm and pixel adjustment value, the multiple first candidate image blocks can be scattered more evenly in the candidate matching area, avoiding the aggregation of multiple first candidate image blocks, and thus avoiding the risk of difficulty in finding a target image block with a higher degree of matching due to the multiple first candidate image blocks being too similar.

[0113] S550 . Based on the position of the first candidate image block in the first image, obtain a corresponding second candidate image block at the same position in the second image.

[0114] Specifically, the method for obtaining the second candidate image block is similar to the method for obtaining the edge information image block, and will not be described in detail here.

[0115] S560 : Filter out a target image block from a plurality of first candidate image blocks according to the image block to be repaired and the first candidate image block, as well as the edge information image block and the second candidate image block.

[0116] In some embodiments, S560 may include: obtaining a fourth model for screening the image block with the highest matching degree with the image block to be repaired, wherein the fourth model is pre-trained and generated based on the image block to be repaired in the image sample set, and its corresponding multiple first candidate image blocks, multiple second candidate image blocks, and the image block with the highest matching degree; the image block to be repaired, and its corresponding multiple first candidate image blocks, and multiple second candidate image blocks are input into the fourth model for processing, and the target image block with the highest matching degree with the image block to be repaired is output.

[0117] In some other embodiments, S560 may include: S561, obtaining pixel difference values ​​based on known pixels of the image block to be repaired and pixel values ​​of each first candidate image block.

[0118] Specifically, based on the known pixels of the image block to be restored and the pixel values ​​of each first candidate image block, the pixel difference between the image block to be restored and each first candidate image block is obtained.

[0119] S562 : Obtain an edge difference based on the edge value of the edge information image block and the edge value of each second candidate image block.

[0120] Specifically, edge values ​​are used to characterize line features of an image.

[0121] Specifically, based on the edge value of the edge information image block and the edge value of each second candidate image block, an edge difference value between the edge information image block and each second candidate image block is obtained.

[0122] S563 : Obtain loss values ​​of the image block to be repaired and each first candidate image block based on the pixel difference and the edge difference, and use the first candidate image block corresponding to the minimum loss value as the target image block.

[0123] Specifically, the minimum loss value is the minimum value among the loss values ​​corresponding to multiple first candidate image blocks.

[0124] In an example, S563 may include: calculating the square of the pixel difference to obtain a first calculation result; calculating the square of the edge difference to obtain a second calculation result; summing the first calculation result and the second calculation result to obtain the loss value of the image block to be repaired and each first candidate image block, and taking the first candidate image block corresponding to the minimum loss value as the target image block with the highest matching degree with the image block to be repaired.

[0125] Of course, the first calculation result may be obtained by calculating the cube or the fourth power of the pixel difference, and the second calculation result may be obtained by calculating the cube or the fourth power of the edge difference, but the present invention is not limited thereto.

[0126] It can be understood that using the first candidate image block corresponding to the minimum loss value as the target image block can simplify the method of screening the target image block, which is conducive to reducing the performance requirements of the electronic device.

[0127] S570 , repairing the area to be repaired based on the target image block to obtain a target repaired image.

[0128] Specifically, S570 is similar to S150 and will not be described again here.

[0129] In the disclosed embodiment, a plurality of first candidate image blocks that match the image block to be repaired and second candidate image blocks corresponding to the plurality of first candidate image blocks are determined, and based on the known pixels of the image block to be repaired and the pixels of each first candidate image block, as well as the edge information image block and the edge information of each second candidate image block, a target image block with the highest degree of match with the image block to be repaired is screened out from the plurality of first candidate image blocks. This allows the target image block to be screened out from the plurality of first candidate image blocks, which is conducive to finding a target image block that is more matched with the image block to be repaired, or more suitable for repairing the image block to be repaired. This helps to further improve the alignment effect of the lines in the repaired image block to be repaired and the lines in its adjacent image blocks, thereby further improving the image repair effect.

[0130] FIG7 is a schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure, which can be understood as the above-mentioned electronic device or a part of the functional modules in the above-mentioned electronic device. As shown in FIG7 , the image processing device 700 includes:

[0131] A first acquisition module 710 is configured to acquire a first image;

[0132] A first determining module 720 is configured to determine a region to be repaired in the first image in response to a user operation;

[0133] A generating module 730 is configured to perform edge information extraction processing on the first image to generate a second image;

[0134] A second determining module 740 is configured to determine a target image block having the highest matching degree with the image block to be repaired based on the image block to be repaired in the area to be repaired and the edge information image block in the second image;

[0135] The restoration module 750 is configured to restore the to-be-restored area based on the target image block to obtain a target restored image.

[0136] In another embodiment of the present disclosure, the generation module 730 may include:

[0137] A first acquisition submodule is used to acquire a first model for performing low-resolution restoration on the area to be restored in the image;

[0138] A second acquisition submodule is used to input the first image into the first model to obtain a third image;

[0139] The extraction submodule is used to perform edge information extraction processing on the third image to generate a second image.

[0140] In another embodiment of the present disclosure, the device may further include:

[0141] A division module is used to divide the image blocks to be repaired into known pixels and unknown pixels according to the edges of the area to be repaired;

[0142] The second acquisition module is configured to acquire an edge information image block corresponding to the image block to be repaired at the same position in the second image based on the position of the image block to be repaired in the first image.

[0143] In yet another embodiment of the present disclosure, the second determining module 740 may include:

[0144] A first determining submodule, configured to determine, in the non-to-be-repaired area, a plurality of first candidate image blocks to be matched with the to-be-repaired image block;

[0145] A third acquisition submodule, configured to acquire, based on the position of the first candidate image block in the first image, a corresponding second candidate image block at the same position in the second image;

[0146] The screening submodule is configured to screen out a target image block from a plurality of first candidate image blocks according to the image block to be repaired and the first candidate image block, the edge information image block and the second candidate image block.

[0147] In yet another embodiment of the present disclosure, the first determining submodule may include:

[0148] A first determining unit, configured to determine a candidate matching area in the non-to-be-repaired area according to a position of the to-be-repaired image block;

[0149] The second determining unit is configured to determine a plurality of first candidate image blocks to be matched with the image block to be repaired in the candidate matching area according to a preset random algorithm and pixel adjustment value based on the size of the image block to be repaired.

[0150] In another embodiment of the present disclosure, the screening submodule may include:

[0151] A first acquiring unit, configured to acquire pixel difference values ​​based on known pixels of the image block to be repaired and pixel values ​​of each first candidate image block;

[0152] a second acquiring unit, configured to acquire an edge difference value based on an edge value of the edge information image block and an edge value of each second candidate image block;

[0153] The third determining unit is configured to obtain loss values ​​of the image block to be repaired and each first candidate image block based on pixel differences and edge differences, and to use the first candidate image block corresponding to the minimum loss value as the target image block.

[0154] In yet another embodiment of the present disclosure, the repair module 750 may include:

[0155] A second determining submodule is configured to determine, in the target image block, a first pixel region corresponding to known pixels in the image block to be repaired, and a second pixel region corresponding to unknown pixels in the image block to be repaired;

[0156] The updating submodule is used to fill the pixel values ​​of the second pixel area into the corresponding positions of the unknown pixels in the image block to be repaired, and to update the corresponding positions of the known pixels in the image block to be repaired based on the pixel values ​​of the first pixel area.

[0157] The device provided in this embodiment can execute the method of any of the above embodiments, and its execution method and beneficial effects are similar, which will not be repeated here.

[0158] An embodiment of the present disclosure further provides an electronic device, comprising: a memory storing a computer program; and a processor for executing the computer program. When the computer program is executed by the processor, the method of any of the above embodiments can be implemented.

[0159] For example, FIG8 is a schematic diagram of the structure of an electronic device in an embodiment of the present disclosure. Specific reference is made below to FIG8 , which shows a schematic diagram of the structure of an electronic device 800 suitable for implementing an embodiment of the present disclosure. The electronic device 800 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop 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. The electronic device shown in FIG8 is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.

[0160] As shown in Figure 8, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the electronic device 800 are also stored in the RAM 803. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0161] Typically, the following devices may be connected to the I / O interface 805: an input device 806 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 808 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although FIG8 shows the electronic device 800 with various devices, it should be understood that not all of the devices shown are required to be implemented or present. More or fewer devices may alternatively be implemented or present.

[0162] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0163] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, 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 the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a 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. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport 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 thereof.

[0164] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and can 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 later developed network.

[0165] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0166] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:

[0167] acquiring a first image;

[0168] In response to a user operation, determining a region to be repaired in the first image;

[0169] Performing edge information extraction processing on the first image to generate a second image;

[0170] Determine the target image block with the highest matching degree with the image block to be repaired based on the image block to be repaired in the area to be repaired and the edge information image block in the second image;

[0171] The area to be repaired is repaired based on the target image block to obtain a target repaired image.

[0172] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the 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).

[0173] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two 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 box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0174] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.

[0175] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and 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 chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0176] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, 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 foregoing.

[0177] The embodiments of the present disclosure further provide a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of any of the above embodiments can be implemented. The execution method and beneficial effects are similar and will not be repeated here.

[0178] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0179] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. An image processing method, include: acquiring a first image; In response to a user operation, determining a region to be repaired of the first image; Performing edge information extraction processing on the first image to generate a second image; Determine, according to the image block to be repaired in the area to be repaired and the edge information image block in the second image, a target image block with the highest matching degree with the image block to be repaired; The to-be-repaired area is repaired based on the target image block to obtain a target repaired image.

2. The method according to claim 1, wherein the first image is subjected to edge information extraction processing to generate a second image, include: Acquire a first model for performing low-resolution restoration on the area to be restored in the image; Inputting the first image into the first model to obtain a third image; Perform edge information extraction processing on the third image to generate the second image.

3. The method according to claim 1, further comprising: include: Dividing the image blocks to be repaired including known pixels and unknown pixels according to the edge of the area to be repaired; Based on the position of the image block to be repaired in the first image, an edge information image block corresponding to the image block to be repaired is acquired at the same position in the second image.

4. The method according to claim 1, wherein the target image block having the highest matching degree with the image block to be repaired is determined based on the image block to be repaired in the area to be repaired and the edge information image block in the second image, include: Determine, in the non-to-be-repaired area, a plurality of first candidate image blocks to be matched with the to-be-repaired image block; Based on the position of the first candidate image block in the first image, acquiring a corresponding second candidate image block at the same position in the second image; According to the image block to be repaired and the first candidate image block, and the edge information The target image block is selected from the plurality of first candidate image blocks and the second candidate image blocks, and the target image block is selected from the plurality of first candidate image blocks.

5. The method according to claim 4, wherein the determining of a plurality of first candidate image blocks matching the image block to be repaired in the non-repaired area, include: Determine a candidate matching area in the non-to-be-repaired area according to the position of the to-be-repaired image block; According to the size of the image block to be repaired, a plurality of first candidate image blocks to be matched with the image block to be repaired are determined in the candidate matching area according to a preset random algorithm and a pixel adjustment value.

6. The method according to claim 4, wherein the target image block is selected from the plurality of first candidate image blocks according to the image block to be repaired and the first candidate image block, and the edge information image block and the second candidate image block. include: Obtaining pixel difference values ​​based on known pixels of the image block to be repaired and pixel values ​​of each of the first candidate image blocks; Acquire an edge difference value based on the edge value of the edge information image block and the edge value of each of the second candidate image blocks; The loss values ​​of the image block to be repaired and each of the first candidate image blocks are obtained based on the pixel difference value and the edge difference value, and the first candidate image block corresponding to the minimum loss value is used as the target image block.

7. The method according to any one of claims 1 to 6, wherein the image block to be repaired is repaired based on the target image block. include: Determining, in the target image block, a first pixel region corresponding to known pixels in the image block to be restored, and a second pixel region corresponding to unknown pixels in the image block to be restored; The pixel values ​​of the second pixel area are filled into corresponding positions of unknown pixels in the image block to be repaired, and the corresponding positions of known pixels in the image block to be repaired are updated based on the pixel values ​​of the first pixel area.

8. An image processing device, include: A first acquisition module, used for acquiring a first image; A first determining module, configured to determine a to-be-repaired area of ​​the first image in response to a user operation; A generating module, used for performing edge information extraction processing on the first image to generate a second image; A second determination module is used to determine a target image block having the highest matching degree with the image block to be repaired according to the image block to be repaired in the area to be repaired and the edge information image block in the second image; A repair module is used to repair the to-be-repaired area based on the target image block to obtain a target repaired image.

9. An electronic device, include: A processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

11. A computer program product, comprising a computer program or instructions, wherein when the computer program or instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Image restoration method and device, electronic equipment and storage medium

    CN111445415A

  • Image restoration method and device, electronic equipment and storage medium

    CN113674176A

  • Image restoration method and device, electronic equipment and storage medium

    CN113989135A

  • Image processing method and device, equipment and storage medium

    CN115994873A

  • Systems and Methods for Performing Image Inpainting

    US20140126833A1