Image inpainting method and apparatus, and electronic device and storage medium

Through recognition, repair and difference processing technology, the problem of detail loss in the repair process of large-size portrait photos is solved, the clarity and accuracy of the photos are improved, and the effect of image repair is improved.

WO2024222252A1PCT designated stage expired Publication Date: 2024-10-31BEIJING ZITIAO NETWORK TECH CO LTD

Patent Information

Application Number
PCT/CN2024/081261
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-28
Filing Date
2024-03-12
Publication Date
2024-10-31

AI Technical Summary

Technical Problem

When the existing technology performs portrait restoration on large-size portrait photos, image details are lost due to reduction, which affects the detail clarity and accuracy of the photos.

Method used

By identifying the target object in the original image, the target area image is obtained, and the repair process is performed to obtain the difference image between the area repair image and the target area image, and based on the difference image and the original image, the target image is obtained to improve Image detail clarity and accuracy.

Benefits of technology

It achieves detail preservation and repair effects on high-resolution portrait photos, and improves the ability and stability of image repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024081261_31102024_PF_FP_ABST
    Figure CN2024081261_31102024_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure relates to an image inpainting method and apparatus, and an electronic device and a storage medium. The image inpainting method comprises: identifying a target object in an original image, so as to obtain a target area image; performing inpainting processing on the target area image, so as to obtain an area-inpainted image; acquiring a difference image between the area-inpainted image and the target area image; and obtaining a target image on the basis of the difference image and the original image. By means of the present disclosure, the original image can be inpainted on the basis of the difference image between the area-inpainted image and the target area image, thus improving the detail definition and accuracy of the original image, and further improving the capability and stability of image inpainting.
Need to check novelty before this filing date? Find Prior Art

Description

Image restoration method, device, electronic device and storage medium

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

[0002] The present disclosure relates to the field of image processing technology, and in particular to an image restoration method, device, electronic device, and computer-readable storage medium. Background Art

[0003] As image processing technology continues to mature, users have placed higher demands on the quality of image restoration using image processing technology. Image restoration refers to restoring unknown or damaged information in an image based on known information in the image, thereby repairing missing or damaged parts of the image.

[0004] Taking portrait restoration as an example, related art portrait restoration methods only have good restoration effects when the face size in portrait photos is 512×512 (pixels) or smaller. However, for portrait photos with a resolution of 3024×4032 or larger, since the face size in the portrait photo is much larger than 512×512 (pixels), shrinking the face during the face alignment process will result in loss of image detail, and this loss will still exist in the restored portrait photo. Therefore, the clarity and accuracy of the portrait photo's details are affected.

[0005] Summary of the Invention

[0006] In view of this, the embodiments of the present disclosure provide an image restoration method, device, electronic device and computer-readable storage medium to solve the problem in the related art that when performing portrait restoration on large-size portrait photos, image details are lost due to reduction, thereby affecting the clarity and accuracy of the details of the portrait photos.

[0007] In a first aspect of an embodiment of the present disclosure, an image restoration method is provided, comprising: identifying a target object in an original image to obtain a target area image; performing restoration processing on the target area image to obtain a regional restoration image; obtaining a difference image between the regional restoration image and the target area image; and obtaining a target image based on the difference image and the original image.

[0008] According to a second aspect of an embodiment of the present disclosure, an image restoration device is provided, comprising: an identification module configured to identify a target object in an original image to obtain a target area image; a restoration module configured to perform restoration processing on the target area image to obtain a regional restoration image; an acquisition module configured to obtain a difference image between the regional restoration image and the target area image; and a processing module configured to obtain a target image based on the difference image and the original image.

[0009] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising at least one processor; and a memory for storing instructions executable by at least one processor; wherein the at least one processor is configured to execute instructions to implement the steps of the above method.

[0010] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the steps of the above method.

[0011] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which is tangibly stored in a computer storage medium and includes computer executable instructions. When the computer executable instructions are executed by a device, the device executes the steps of the above method. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0013] FIG1 is a flowchart of an image restoration method provided by an exemplary embodiment of the present disclosure.

[0014] FIG2 is a flowchart of an image restoration method provided by an exemplary embodiment of the present disclosure.

[0015] 3a to 3g are schematic diagrams of an image restoration process provided by an exemplary embodiment of the present disclosure.

[0016] FIG4 is a schematic block diagram of functional modules of an image restoration device provided by an exemplary embodiment of the present disclosure.

[0017] FIG5 is a structural block diagram of an electronic device provided by an exemplary embodiment of the present disclosure.

[0018] FIG6 is a structural block diagram of a computer system provided by an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] The following describes embodiments of the present disclosure in more detail 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 limited to the embodiments described herein. Rather, 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 for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.

[0020] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0021] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this 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.

[0022] It should be noted that the modifications of "one" and "multiple" 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, they should be understood as "one or more".

[0023] 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.

[0024] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0025] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the electronic device, application, server, storage medium, or other software or hardware that performs the operations of the disclosed technical solution based on the prompt message.

[0026] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device.

[0027] It is understandable that the above notification and user authorization process are merely illustrative and do not limit the implementation of the present disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0028] As image processing technology continues to mature, users have placed higher demands on the restoration effects of image restoration through image processing technology, and the imaging quality of photos has become one of the focuses of attention. Since the imaging quality of photos can be affected by the external environment and / or physical factors, restoration technology has also attracted more and more attention. Restoration technology is a technology that can enhance the details and clarity of photos, and can, to a certain extent, restore the details of photos with severely damaged image quality or poor clarity. The application scenarios of restoration technology are very wide, for example, repairing photos taken by early image capture devices, repairing photos that have been scanned and rephotographed multiple times, repairing photos that have been reposted and compressed multiple times on the Internet, and repairing photos taken by low-definition surveillance cameras.

[0029] In related art, portrait restoration methods use a face detection algorithm to detect the face and facial features in the original portrait photo and align the face based on the locations of the facial features. Specifically, the image area containing the face is cropped to a specified size, for example, 512×512 (pixels), to obtain an aligned portrait photo. The aligned portrait photo is then input into a portrait restoration model to obtain a restored portrait photo. Finally, the restored portrait photo is rotated and scaled to the size of the original portrait photo and added to the original portrait photo. This portrait restoration method only has a good restoration effect when the face size in the portrait photo is 512×512 or smaller. For portrait photos with a resolution of 3024×4032 or larger, since the face size in the portrait photo is much larger than 512×512 (pixels), shrinking the face during the face alignment process will result in a loss of image detail, and this loss still exists in the restored portrait photo, thus affecting the clarity and accuracy of the details in the portrait photo.

[0030] An image restoration method and apparatus according to an embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.

[0031] FIG1 is a flow chart of an image restoration method provided by an exemplary embodiment of the present disclosure. The image restoration method of FIG1 can be executed by a server or an electronic device. As shown in FIG1 , the image restoration method includes:

[0032] S101, identifying the target object in the original image to obtain a target area image;

[0033] S102, performing restoration processing on the target area image to obtain a regional restoration image;

[0034] S103, obtaining a difference image between the regional restoration image and the target region image;

[0035] S104: Obtain a target image based on the difference image and the original image.

[0036] Specifically, taking the server as an example, after receiving an image repair request, the server uses image recognition technology to identify the target object in the original image to determine the target area image of the target object, and repairs the target area image to obtain a regional repair image; further, the server obtains a difference image between the regional repair image and the target area image, and obtains the target image based on the difference image and the original image.

[0037] Here, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The embodiments of the present disclosure do not limit this.

[0038] Image recognition refers to the use of computers to process, analyze, and understand images to identify patterns of targets and objects within them. It is a practical application of deep learning algorithms. Image recognition can include facial recognition, object recognition, and distance detection. Facial recognition can be used in security checks and identity verification, object recognition in smart retail, and distance detection in object tracking.

[0039] The original image refers to an image obtained by directly photographing a real scene using an image acquisition device. Here, the image acquisition device may include but is not limited to a camera, a video camera, etc. In the embodiment of the present disclosure, the original image refers to an image that needs to be repaired. Preferably, the original image is a high-resolution image or an ultra-high-resolution image. Here, a high-resolution image is also called a high-definition image, which refers to an image with a vertical resolution greater than or equal to 720, for example, 1280×720, 1920×1080, etc., wherein the number before the multiplication sign indicates the width (i.e., horizontal resolution) and the number after the multiplication sign indicates the height (i.e., vertical resolution). It should be noted that the original image can be obtained by photographing an image acquisition device, or it can be collected based on an image library currently available on the Internet, and the embodiment of the present disclosure does not limit this.

[0040] The target object refers to the object or subject in the original image. The target object may include people, animals, plants, buildings, objects, etc., which are not limited in the present embodiment. The target area image refers to the image of the area where the target object is located in the original image.

[0041] Image inpainting is the process of reconstructing lost or damaged portions of an image or video. Image inpainting techniques can be used to remove noise, scratches, missing images, and occlusions, improving image quality. Image inpainting uses Generative Adversarial Networks (GANs) or diffusion models to repair the target object. A regional inpainted image is a restored image obtained by inpainting the target region using image inpainting techniques.

[0042] A difference refers to the difference between two images. A difference image is a scatter plot with a certain difference as the vertical axis and another appropriate quantity as the horizontal axis. In the disclosed embodiments, a difference image refers to the deviation between the inpainted image and the target image. In other words, the difference image is used to represent the difference between the inpainted image and the target image.

[0043] According to the technical solution provided by the embodiments of the present disclosure, a target area image is obtained by identifying a target object in an original image, and then the target area image is inpainted. A difference image is obtained between the inpainted area image and the target area image, and the target image is obtained based on the difference image and the original image. The original image can then be inpainted based on the difference image between the inpainted area image and the target area image. This improves the detail clarity and accuracy of the original image, and further enhances the capability and stability of image inpainting.

[0044] In some embodiments, the target object in the original image is identified to obtain a target area image, including: detecting the target object in the original image; generating an initial area image based on the image area where the target object is located; detecting key points in the initial area image to obtain key point information; and aligning the target object based on the key point information to obtain the target area image.

[0045] Specifically, image detection is performed on the original image to determine whether a target object exists in the original image; when the target object is detected to exist in the original image, the image area where the target object is located can be determined based on the position of the target object in the original image, and an initial area image is generated based on the image area where the target object is located; further, key point detection is performed on key points in the initial area image, and the target object is aligned based on the detected key point information to obtain a target area image.

[0046] Here, image detection refers to processing images using computer vision, etc., to identify and select various objects in the image. Image detection algorithms may include those based on a cascade classifier framework, those based on template matching, and those based on regression, and are not limited in the present disclosure.

[0047] The initial region image refers to an image generated based on the image region where the target object in the original image is located. Taking the target object as an example, the image region where the target object is located refers to the image region where the face in the original image is located, that is, the face region. To locate the face region and obtain the corresponding position information of the face region, a face detection algorithm can be used to detect the face in the original image and obtain a face point set. Furthermore, the circumscribed rectangle of the face shape represented by the face point set is calculated and expanded outward to obtain the cropping rectangle of the face. That is, the face region is separately cut out from the original image to generate the initial region image. Here, the position information corresponding to the face region is used to represent the coordinates of the face position, and the face point set is used to represent information such as the posture, position, and face shape of the face in the image. The initial region image refers to the cropped face image obtained by cropping the original image, for example, by subtracting the redundant parts of the original image other than the face.

[0048] It should be noted that if the face in the original image is not horizontal, for example, if the head is tilted, raised, or lying down, the resulting cropping rectangle will also be horizontal. Therefore, it is necessary to compare the cropping rectangle with a preset standard rectangle to determine the rotation angle of the face in the original image relative to the horizontal. Here, the preset standard rectangle can be a pre-set horizontal standard rectangle.

[0049] In order to make the obtained cropping rectangle horizontal, key point detection can be performed on the key points in the initial area image, and based on the coordinates of each key point detected, the positional relationship of each key point in the initial area image can be obtained using the affine transformation method; further, the positional relationship of each key point in the initial area image is aligned with the positional relationship of each key point in a standard frontal face to obtain an aligned face image, that is, the target area image.

[0050] Here, key points refer to key parts that can represent the target object. For example, when the target object is a person, the key points can be the person's eyebrows, eyes, nose, mouth and other iconic facial parts; when the target object is a puppy, the key points can be the puppy's tail, limbs, ears and other iconic parts. Key point information may include but is not limited to the coordinates and confidence of the key points. Key point detection refers to the detection of the key area position of the key point. The key point detection algorithm may include the Active Shape Model (ASM) algorithm, the Active Appearance Model (AAM) algorithm, the Cascaded Pose Regression (CPR) algorithm, the Deep Learning (DL) algorithm, etc., and the embodiments of the present disclosure are not limited to this.

[0051] Alignment processing refers to correcting the angle of the target object in the image. The target object in the original image may be tilted at a certain angle. Alignment processing can straighten the target object in the image to facilitate subsequent image recognition processing. Alignment algorithms can include scaling and rotation algorithms, affine transformation algorithms, etc., which are not limited in the embodiments of this disclosure.

[0052] According to the technical solution provided by the embodiments of the present disclosure, by generating an initial area image based on the image area where the detected target object is located, detecting key points in the initial area image, and aligning the target object based on the detected key point information, the angle of the detected target object with an incorrect horizontal angle can be corrected, thereby eliminating the errors caused by different postures and improving the accuracy of subsequent image restoration.

[0053] In some embodiments, the target object is aligned based on the key point information to obtain a target area image, including: rotating the initial area image based on the key point information; adjusting the size of the rotated initial area image to a preset size to obtain the target area image.

[0054] Specifically, after obtaining the key point information, the initial area image can be rotated based on the key point information to correct the angle of the target object in the initial area image; further, the rotated initial area image is compressed and / or cropped to obtain a target area image of a preset size.

[0055] Here, the preset size can be pre-set according to actual needs. For example, the preset size can be 64×64, 128×128, 160×160, 200×200, 224×224 and other pixel ratios, and the embodiments of the present disclosure are not limited to this. The target area image refers to an image of a preset size obtained by adjusting the size of the rotated initial area image. It should be understood that the size of the target area image is the same as the preset size. For example, if the preset size is 128×128 (pixels), the size of the target area image is also 128×128 (pixels).

[0056] In some embodiments, performing restoration processing on the target region image to obtain the region restoration image includes: inputting the target region image into an image restoration model to obtain the region restoration image.

[0057] Specifically, after obtaining the target area image, the target area image can be used as the input of the image restoration model, and the image restoration model is used to perform image restoration on the target area image to obtain a regional restoration image.

[0058] Here, the image restoration model is the generator in a generative adversarial network, including an encoding network and a decoding network. The encoding network is used to extract image features, and the decoding network is used to restore the image. The image restoration model can be obtained using deep learning algorithms, which can include convolutional neural networks (CNNs) with various structures, but this disclosure does not limit this.

[0059] The image restoration model is used to restore low-quality images. Specifically, a low-quality image dataset is fed into the image restoration model to be trained. The model then restores the images through processing by the encoding and decoding networks, generating training images corresponding to the low-quality images, which form the training generated image dataset. Furthermore, by continuously adjusting the network parameters of the image restoration model, the quality of the restored training generated images is continuously improved.

[0060] In an embodiment of the present disclosure, the image restoration model is obtained by training a neural network model multiple times based on sample images. The sample images may include images that meet the screening criteria, and the neural network model may be a convolutional neural network model. Here, the images that meet the screening criteria may include images after data perturbation, and the data perturbation may include at least one of noise, mosaic, and blur. For example, the image is a high-quality image, and the high-quality image is subjected to data perturbations such as noise, mosaic, and blur that reduce the image quality. The resulting image is an image that meets the screening criteria. It should be noted that the high-quality image is a high-definition image without noise.

[0061] According to the technical solution provided by the embodiment of the present disclosure, by using the image restoration model to perform image restoration on the target area image, a higher-quality regional restoration image can be obtained, thereby improving the accuracy of the subsequent difference calculation.

[0062] In some embodiments, obtaining a difference image between the region repair image and the target region image includes: performing difference processing on the pixel values ​​of the region repair image and the target region image based on the positions of the pixel points to obtain a difference image, wherein the pixel values ​​include one or more of RGB values, UV values, and brightness values.

[0063] Specifically, after obtaining the regional repair image and the target area image, the pixel values ​​of each pixel in the regional repair image and the target area image can be further obtained, and based on the position of the pixel points, the pixel values ​​corresponding to each pixel in the regional repair image and the pixel values ​​of the corresponding pixel points in the target area image are subtracted (i.e., the difference between the pixel pairs is calculated) to obtain a difference image.

[0064] Here, a pixel pair refers to matching pixels in two images. In the disclosed embodiments, a pixel pair refers to pixels in the target region image and the inpainted region image that have a one-to-one correspondence. Since the inpainted region image and the inpainted region image have the same resolution, i.e., the pixels in the inpainted region image and the inpainted region image have a one-to-one correspondence, when calculating the difference, the difference between each pair of pixels can be calculated, and all the differences obtained can form an image, i.e., a difference image.

[0065] Optionally, when calculating the difference, since the difference is an integer type in the range of [-255, 255], the difference can be converted to a low-precision numerical type to represent it. For example, by setting the offset, the difference of each pixel point can be distributed around 128, so that the data is more concentrated.

[0066] According to the technical solution provided by the embodiments of the present disclosure, by performing pixel-by-pixel subtraction operations on the regional repair image and the target area image, the difference between each pair of pixels in the regional repair image and the target area image can be accurately calculated, thereby clearly determining the difference between the regional repair image and the target area image, thereby improving the accuracy of subsequent image fusion.

[0067] In some embodiments, a target image is obtained based on the difference image and the original image, including: reversely rotating the difference image; adjusting the size of the reversely rotated difference image to the size of the original image to obtain an adjusted difference image; and fusing the adjusted difference image with the original image to obtain the target image.

[0068] Specifically, after obtaining the difference image, the difference image can be reversely rotated, and the size of the reversely rotated difference image can be adjusted to the size of the original image to obtain an adjusted difference image; further, the adjusted difference image can be fused with the original image to obtain the target image.

[0069] Here, inverse rotation is the inverse of the rotation process described above, and the angle of inverse rotation is the same as the angle of rotation described above. In other words, if the initial region image is rotated, the difference image is inversely rotated. For example, if the initial region image is rotated 30° to the left, the difference image is rotated 30° to the right.

[0070] Image fusion refers to fusing the pixel values ​​of identically located pixels in at least two images. This pixel value fusion may include, but is not limited to, performing at least one of weighted calculations and summation on the pixel values. The target image is the final image generated by fusing the adjusted difference image and the original image.

[0071] According to the technical solution provided by the embodiment of the present disclosure, by reversely rotating and adjusting the difference image, the angle and position of the adjusted difference image can be kept consistent with those of the original image.

[0072] In some embodiments, the adjusted difference image is fused with the original image to obtain a target image, including: adding the pixel values ​​of the adjusted difference image and the original image based on the position of the pixel points to obtain the target image; wherein the pixel values ​​include one or more of RGB values, UV values, and brightness values.

[0073] Specifically, after obtaining the adjusted difference image, the pixel values ​​of each pixel in the adjusted difference image and the original image can be obtained, and the pixel value of each pixel in the adjusted difference image and the pixel value of the corresponding pixel in the original image are added based on the position of the pixel (i.e., the sum of the pixel pairs is calculated) to obtain the target image.

[0074] Here, a pixel pair refers to a one-to-one correspondence between the original image and the adjusted difference image. Since the original image and the adjusted difference image have the same resolution, after obtaining the pixel values ​​corresponding to each pixel in the adjusted difference image, they can be added to the original image. In other words, the adjusted difference image and the original image are fused, thereby enhancing the pixel values ​​corresponding to each pixel in the original image to obtain an enhanced image corresponding to the original image. In other words, the pixel value corresponding to each pixel (i.e., image pixel) can be added to the original pixel value, and the resulting image is determined as the target image.

[0075] Image addition is primarily used to superimpose the content of one image onto another to create a stacked image effect, or to add a constant to each pixel in an image to change its brightness. In the disclosed embodiments, addition refers to a point-by-point addition operation between the pixel value of each pixel in the adjusted difference image and the pixel value of the corresponding pixel in the original image.

[0076] According to the technical solution provided by the embodiment of the present disclosure, by using the adjusted difference image to repair the original image, the detail clarity of the original image can be improved, thereby achieving detail preservation after high-resolution image repair.

[0077] All of the above optional technical solutions can be combined in any way to form optional embodiments of the present disclosure, and will not be described in detail here. In addition, the order of the sequence numbers of the steps in the above embodiments does not imply a specific order of execution. The order of execution of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.

[0078] FIG2 is a flow chart of an image restoration method provided by an exemplary embodiment of the present disclosure. The image restoration method of FIG2 can be executed by a server or an electronic device. As shown in FIG2 , the image restoration method includes:

[0079] S201, detecting a target object in an original image, wherein the original image is a high-resolution image or an ultra-high-resolution image;

[0080] S202, generating an initial region image based on the image region where the target object is located;

[0081] S203, detecting key points in the initial region image to obtain key point information;

[0082] S204, rotating the initial region image based on the key point information;

[0083] S205, adjusting the size of the rotated initial region image to a preset size to obtain a target region image;

[0084] S206, inputting the target region image into the image restoration model to obtain a region restoration image;

[0085] S207, performing a difference process on the pixel values ​​of the regional restoration image and the target regional image based on the positions of the pixel points to obtain a difference image;

[0086] S208, reversely rotating the difference image;

[0087] S209, adjusting the size of the inversely rotated difference image to the size of the original image to obtain an adjusted difference image;

[0088] S210 , adding the pixel values ​​of the adjusted difference image and the original image based on the positions of the pixels to obtain a target image.

[0089] According to the technical solution provided in the embodiments of the present disclosure, by calculating the difference between the target area image obtained by detecting and aligning the original image and the area repaired image obtained by repairing the target area image, and repairing the original image based on the difference, the detail clarity of the original image can be improved, thereby achieving detail preservation after high-resolution image repair, and further improving the ability and stability of image repair.

[0090] Figures 3a to 3g are schematic diagrams of an image restoration process provided by an exemplary embodiment of the present disclosure. The image restoration method provided by an embodiment of the present disclosure will be described in detail below with reference to Figures 3a to 3g.

[0091] Specifically, FIG3a is a high-resolution original image. First, the target object (e.g., a face) in the original image is detected, and an initial region image is generated based on the image region where the detected target object is located, as shown in FIG3b. Next, key points in the initial region image are detected to obtain key point information, the initial region image is rotated based on the detected key point information, and the rotated initial region image is cropped to obtain a target region image, as shown in FIG3c. Continuing, the target region image is input into the image restoration model to obtain a region restoration image, as shown in FIG3d. The pixel values ​​of the region restoration image and the target region image are subtracted based on the positions of the pixels to obtain a difference image, as shown in FIG3e. Further, the difference image is inversely rotated, and the size of the inversely rotated difference image is adjusted to the size of the original image to obtain an adjusted difference image, as shown in FIG3f. Finally, the pixel values ​​of the adjusted difference image and the original image are added based on the positions of the pixels to obtain the target image, as shown in FIG3g.

[0092] At least one of the above-mentioned technical solutions adopted in the embodiments of the present disclosure can achieve the following beneficial effects: a target area image is obtained by identifying the target object in the original image, the target area image is repaired to obtain a regional repair image, a difference image between the regional repair image and the target area image is obtained, and a target image is obtained based on the difference image and the original image; the original image can be repaired based on the difference image between the regional repair image and the target area image, thereby improving the detail clarity and accuracy of the original image, and further improving the ability and stability of image repair.

[0093] In the case of dividing each functional module according to each function, an embodiment of the present disclosure provides an image restoration device, which can be a server or a chip applied to a server. Figure 4 is a schematic block diagram of the functional modules of an image restoration device provided by an exemplary embodiment of the present disclosure. As shown in Figure 4, the image restoration device includes:

[0094] The recognition module 401 is configured to recognize the target object in the original image and obtain a target area image;

[0095] The restoration module 402 is configured to perform restoration processing on the target region image to obtain a region restoration image;

[0096] An acquisition module 403 is configured to acquire a difference image between the regional restoration image and the target region image;

[0097] The processing module 404 is configured to obtain a target image based on the difference image and the original image.

[0098] According to the technical solution provided by the embodiments of the present disclosure, a target area image is obtained by identifying a target object in an original image, the target area image is repaired to obtain a regional repair image, a difference image between the regional repair image and the target area image is obtained, and a target image is obtained based on the difference image and the original image. The original image can be repaired based on the difference image between the regional repair image and the target area image, thereby improving the detail clarity and accuracy of the original image and further enhancing the ability and stability of image repair.

[0099] In some embodiments, the recognition module 401 of Figure 4 detects the target object in the original image; generates an initial area image based on the image area where the target object is located; detects key points in the initial area image to obtain key point information; and aligns the target object based on the key point information to obtain a target area image.

[0100] In some embodiments, the recognition module 401 of FIG. 4 rotates the initial region image based on the key point information; and adjusts the size of the rotated initial region image to a preset size to obtain the target region image.

[0101] In some embodiments, the restoration module 402 of FIG. 4 inputs the target region image into the image restoration model to obtain a region restoration image.

[0102] In some embodiments, the acquisition module 403 of Figure 4 performs difference processing on the pixel values ​​of the regional repair image and the target area image based on the position of the pixel points to obtain a difference image, and the pixel values ​​include: one or more of: RGB values, UV values, and brightness values.

[0103] In some embodiments, the processing module 404 of FIG. 4 reversely rotates the difference image; adjusts the size of the reversely rotated difference image to the size of the original image to obtain an adjusted difference image; and fuses the adjusted difference image with the original image to obtain a target image.

[0104] In some embodiments, the processing module 404 of FIG4 adds the pixel values ​​of the adjusted difference image and the original image based on the positions of the pixels to obtain a target image; the pixel values ​​include: one or more of RGB values, UV values, and brightness values.

[0105] In some embodiments, the original image is a high-resolution image or an ultra-high-resolution image.

[0106] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0107] An embodiment of the present disclosure further provides an electronic device, comprising: at least one processor; and a memory for storing instructions executable by at least one processor; wherein the at least one processor is configured to execute instructions to implement the steps of the above-mentioned image restoration method disclosed in the embodiment of the present disclosure.

[0108] Figure 5 is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present disclosure. As shown in Figure 5, the electronic device 500 includes at least one processor 501 and a memory 502 coupled to the processor 501. The processor 501 can execute the corresponding steps of the above method disclosed in the embodiment of the present disclosure.

[0109] The processor 501 may also be referred to as a central processing unit (CPU), which may be an integrated circuit chip with signal processing capabilities. Each step in the method disclosed in the embodiment of the present disclosure may be performed by hardware integrated logic circuits in the processor 501 or by software instructions. The processor 501 may be a general-purpose processor, a digital signal processor (DSP), an ASIC, a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiment of the present disclosure may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in the memory 502, such as a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The processor 501 reads the information in the memory 502 and performs the steps of the method in combination with its hardware.

[0110] In addition, when various operations / processes according to the present disclosure are implemented via software and / or firmware, the programs constituting the software can be installed from a storage medium or a network to a computer system having a dedicated hardware structure, such as the computer system 600 shown in FIG6 . When the various programs are installed, the computer system can perform various functions, including those described above. FIG6 is a block diagram of the structure of a computer system provided by an exemplary embodiment of the present disclosure.

[0111] Computer system 600 is intended to represent various forms of digital electronic computer equipment, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic equipment can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0112] As shown in FIG6 , a computer system 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the computer system 600 may also be stored in the RAM 603. The computing unit 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.

[0113] Multiple components within computer system 600 are connected to I / O interface 605, including an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. Input unit 606 can be any type of device capable of inputting information into computer system 600. Input unit 606 can receive input numeric or character information and generate key input signals related to user settings and / or function control of an electronic device. Output unit 607 can be any type of device capable of presenting information and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. Storage unit 608 may include, but is not limited to, a magnetic disk or an optical disk. Communication unit 609 allows computer system 600 to exchange information / data with other devices over a network, such as the Internet, and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver and / or chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0114] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units for running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above. For example, in some embodiments, the above-mentioned method disclosed in the embodiments of the present disclosure may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. In some embodiments, the computing unit 601 may be configured to perform the above-mentioned method disclosed in the embodiments of the present disclosure by any other appropriate means (e.g., by means of firmware).

[0115] An embodiment of the present disclosure further provides a computer-readable storage medium, wherein when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the above method disclosed in the embodiment of the present disclosure.

[0116] The computer-readable storage medium in the embodiments of the present disclosure can be a tangible medium that can contain or store a program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. The above-mentioned computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the above. More specifically, the above-mentioned computer-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 above.

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

[0118] The embodiments of the present disclosure further provide a computer program product, including a computer program, wherein when the computer program is executed by a processor, the method disclosed in the embodiments of the present disclosure is implemented.

[0119] In embodiments of the present disclosure, computer program code for performing the operations of the present disclosure can be written in one or more programming languages ​​or combinations thereof, including but not limited to 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 can be executed entirely 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 entirely on a remote computer or server. In situations involving a remote computer, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer.

[0120] 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.

[0121] The modules, components, or units described in the embodiments of the present disclosure may be implemented in software or hardware. The names of the modules, components, or units do not necessarily limit the modules, components, or units themselves.

[0122] 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 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.

[0123] The above descriptions are merely some embodiments of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in the present disclosure.

[0124] Although some specific embodiments of the present disclosure have been described in detail by way of examples, those skilled in the art will appreciate that the above examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Those skilled in the art will appreciate that modifications may be made to the above embodiments without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.

Claims

1. An image restoration method, characterized in that: The method comprises: Identify the target object in the original image and obtain the target area image; Performing restoration processing on the target area image to obtain a regional restoration image; Acquire a difference image between the regional restoration image and the target regional image; A target image is obtained based on the difference image and the original image.

2. The method according to claim 1, characterized in that: The step of identifying the target object in the original image to obtain the target area image includes: Detecting a target object in the original image; Generate an initial region image based on the image region where the target object is located; Detecting key points in the initial area image to obtain key point information; The target object is aligned based on the key point information to obtain the target area image.

3. The method according to claim 2, characterized in that The step of performing alignment processing on the target object based on the key point information to obtain the target area image includes: Rotating the initial region image based on the key point information; The size of the rotated initial region image is adjusted to a preset size to obtain the target region image.

4. The method according to claim 1, characterized in that: The performing restoration processing on the target area image to obtain the area restoration image includes: The target area image is input into an image restoration model to obtain the area restoration image.

5. The method according to claim 1, characterized in that The step of obtaining a difference image between the regional restoration image and the target regional image includes: Based on the positions of the pixels, the pixel values ​​of the regional restoration image and the target regional image are subjected to difference processing to obtain the difference image. The pixel value includes: one or more of an RGB value, a UV value, and a brightness value.

6. The method according to claim 1, wherein obtaining a target image based on the difference image and the original image comprises: Inversely rotating the difference image; Adjusting the size of the inversely rotated difference image to the size of the original image to obtain an adjusted difference image; The adjusted difference image is fused with the original image to obtain the target image.

7. The method according to claim 6, characterized in that The step of fusing the adjusted difference image with the original image to obtain the target image includes: Adding the pixel values ​​of the adjusted difference image and the original image based on the positions of the pixels to obtain the target image; The pixel value includes: one or more of an RGB value, a UV value, and a brightness value.

8. The method according to any one of claims 1 to 7, characterized in that The original image is a high-resolution image or an ultra-high-resolution image.

9. An image restoration device, characterized in that: The device comprises: A recognition module is configured to recognize a target object in an original image and obtain a target area image; A restoration module is configured to perform restoration processing on the target area image to obtain a regional restoration image; An acquisition module is configured to acquire a difference image between the regional restoration image and the target regional image; The processing module is configured to obtain a target image based on the difference image and the original image.

10. An electronic device, characterized in that: include: at least one processor; a memory for storing the at least one processor-executable instruction; The at least one processor is configured to execute the instructions to implement the method as claimed in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as claimed in any one of claims 1 to 8.

12. A computer program product tangibly stored in a computer storage medium and comprising computer executable instructions which, when executed by a device, cause the device to perform the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Face image processing method and device, electronic device and storage medium

    CN110689500A

  • Image processing method, image processing device, electronic equipment and computer readable storage medium

    CN110992284A

  • Face image restoration method and device, restoration model, medium and equipment

    CN113066034A

  • Image generation method and device, equipment and storage medium

    CN115131464A

  • Action recognition method and device for target object, and electronic apparatus

    US20210281744A1

Cited By

  • Image processing method and device, equipment and storage medium

    CN119863402A

  • Identification photo generation method and electronic equipment

    CN120526003A