Image restoration method, device, computer equipment and storage medium

By cropping and adjusting the image, generating cropped images for repair, the problem of inconsistent output results of the image repair model on computers with different computing power is solved, and the stable and rapid operation of the image repair model is achieved.

CN117392015BActive Publication Date: 2025-02-07深圳牛学长科技有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311335065.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-16
Publication Date
2025-02-07
Estimated Expiration
2043-10-16

AI Technical Summary

Technical Problem

When existing image repair models run on computers with different computing power, the output results are inconsistent and are easily affected by computer storage resources.

Method used

By obtaining the minimum external rectangle of the image to be repaired and its mask image, combining the computer's storage information to set the maximum runnable image size, and cropping and adjusting the rectangle to generate a cropped image for repair, and finally filling the repair results to the original In the image.

Benefits of technology

The consistency of the output results of the image repair model on computers with different computing power is achieved, the impact of storage resources on the repair results is avoided, and the stability and speed of the model are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117392015B_ABST
    Figure CN117392015B_ABST
Patent Text Reader

Abstract

The present invention discloses an image restoration method, device, computer equipment and storage medium, the method comprising: obtaining an image to be restored and its mask image, extracting the minimum bounding rectangle of the mask image; obtaining storage information of the computer, setting the maximum executable image size; comparing the size of the minimum bounding rectangle with the maximum executable image size, adjusting the minimum bounding rectangle according to the comparison result, and obtaining a cropping coordinate; cropping the image to be restored and the mask image respectively, obtaining a cropped image; inputting the cropped image into an image restoration model, and the image restoration model outputs a restoration result image, and then filling the restoration result image into the image to be restored. The present invention performs image adjustment according to the actual available computer resources, so that the image restoration model will not be affected by the input size when deployed and run, thereby stably and quickly running the algorithm model without affecting the model algorithm effect, and realizing image restoration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an image restoration method, device, computer equipment and storage medium. Background Art

[0002] Image restoration refers to the technology of analyzing, processing, and manipulating images to meet visual, psychological and other requirements. Image restoration is an application of signal processing in the image domain. Most images are stored in digital form, so image restoration in many cases refers to digital image restoration. There are currently a variety of image restoration models, and the restoration effects (such as accuracy, restoration efficiency, restoration cost, etc.) of each image restoration model are also different. In addition, the image restoration model has high requirements on the computing power of the running device. For example, due to the possible influence of the computer's storage resources, the output results of the same image restoration model running on computers with different computing powers may not be the same. Therefore, how to ensure that the restoration results produced by the image restoration model on computers with different computing powers are consistent and avoid being affected by the computing power device's own storage resources is a problem that technicians in this field need to solve. Summary of the invention

[0003] The embodiments of the present invention provide an image restoration method, apparatus, computer device and storage medium, aiming to achieve the effect that the image restoration model outputs consistent results on computers with different computing powers, thereby preventing the image restoration process from being affected by the computer's storage resources.

[0004] In a first aspect, an embodiment of the present invention provides an image restoration method, comprising:

[0005] Acquire the image to be repaired and its mask image, and extract the minimum circumscribed rectangle of the mask image;

[0006] Obtaining storage information of the computer, and setting a maximum executable image size according to the storage information;

[0007] Comparing the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjusting the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate;

[0008] Based on the cutting coordinates, the image to be repaired and the mask image are cut respectively to obtain a cut image;

[0009] The cropped image is input into an image restoration model, and the image restoration model outputs a restoration result image, which is then filled into the image to be restored.

[0010] In a second aspect, an embodiment of the present invention provides an image restoration device, comprising:

[0011] An image acquisition unit, used to acquire the image to be repaired and its mask image, and extract the minimum circumscribed rectangle of the mask image;

[0012] A storage information acquisition unit, used to acquire storage information of the computer and set a maximum executable image size according to the storage information;

[0013] A rectangle adjustment unit, used for comparing the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjusting the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate;

[0014] An image cutting unit, used for cutting the image to be repaired and the mask image based on the cutting coordinates to obtain a cut image;

[0015] The repair and filling unit is used to input the cropped image into an image repair model, and the image repair model outputs a repair result image, and then fill the repair result image into the image to be repaired.

[0016] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image restoration method as described in the first aspect when executing the computer program.

[0017] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the image restoration method as described in the first aspect is implemented.

[0018] The embodiment of the present invention provides an image restoration method, device, computer equipment and storage medium, the method comprising: obtaining an image to be restored and its mask image, and extracting the minimum bounding rectangle of the mask image; obtaining storage information of a computer, and setting the maximum executable image size according to the storage information; comparing the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjusting the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate; cropping the image to be restored and the mask image respectively based on the cropping coordinate to obtain a cropped image; inputting the cropped image into an image restoration model, and the image restoration model outputs a restoration result image, and then fills the restoration result image into the image to be restored. The embodiment of the present invention, based on the actual available computer resources, by cropping images and scaling images, makes the image restoration model not affected by the input size of the image to be restored during deployment and operation, thereby stably and quickly running the algorithm model without affecting the model algorithm effect to achieve image restoration, so as to enhance the versatility of the image restoration model deployment and reduce the threshold for the computing power requirements of computer equipment. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0020] Figure 1 A schematic diagram of a flow chart of an image restoration method provided by an embodiment of the present invention;

[0021] Figure 2 A schematic block diagram of an image restoration device provided by an embodiment of the present invention;

[0022] Figure 3 A schematic diagram of an image to be repaired in an image repair method provided by an embodiment of the present invention;

[0023] Figure 4 A schematic diagram of a mask image in an image restoration method provided by an embodiment of the present invention;

[0024] Figure 5 A schematic diagram of a cropped image of an image to be repaired in an image repair method provided by an embodiment of the present invention;

[0025] Figure 6 A schematic diagram of a cropped image of a mask image in an image restoration method provided by an embodiment of the present invention;

[0026] Figure 7 A schematic diagram of a repair result image in an image repair method provided by an embodiment of the present invention;

[0027] Figure 8 A schematic diagram of a repaired image in an image repair method provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0029] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0030] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0031] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0032] See below Figure 1 , Figure 1 A schematic flow chart of an image restoration method provided by an embodiment of the present invention specifically includes steps S101 to S105.

[0033] S101, obtaining an image to be repaired and its mask image, and extracting a minimum circumscribed rectangle of the mask image;

[0034] S102, obtaining storage information of the computer, and setting a maximum executable image size according to the storage information;

[0035] S103, comparing the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjusting the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate;

[0036] S104, cropping the image to be repaired and the mask image respectively based on the cropping coordinates to obtain a cropped image;

[0037] S105: input the cropped image into an image restoration model, and the image restoration model outputs a restoration result image, and then fills the restoration result image into the image to be restored.

[0038] In this embodiment, firstly, the image to be repaired and the corresponding mask image are obtained respectively, such as Figure 3 and Figure 4 As shown, the minimum bounding rectangle is then extracted from the mask image, and the storage information of the computer is obtained at the same time to set the maximum executable image size according to the storage information. After obtaining the minimum bounding rectangle and the maximum executable image size, the two are compared to adjust the minimum bounding rectangle to better ensure that the computer's storage resources will not be affected. After the adjustment is completed, a cropping coordinate can be obtained, and the cropping coordinate is used to crop the image to be repaired and the mask image, and then the cropped image obtained by cropping is repaired using the image repair model, and finally the output result of the image repair model is filled into the image to be repaired, and the image repair operation can be completed. Here, it can be understood that the computer described in this embodiment is a carrier for running the image repair model to achieve image repair. In other embodiments, a server or other computing power device can also be used instead.

[0039] This embodiment uses actually available computer resources to crop and scale images so that the image restoration model will not be affected by the input size of the image to be restored during deployment and operation. This allows the algorithm model to run stably and quickly to achieve image restoration without affecting the effect of the model algorithm. This can enhance the versatility of the deployment of the image restoration model and lower the threshold for the computing power requirements of computer equipment.

[0040] Specifically, the image restoration model adopts image restoration technology based on deep learning. Of course, in other embodiments, other image restoration models can also be used, and this embodiment does not limit the image restoration model used. For example, using a generative adversarial network GAN, when the GAN network is applied to image restoration, some noise is first randomly input, and the generator and discriminator of the GAN model are used to compete with each other, so that the generator can have the ability to generate a fake picture close to the original picture. However, the model at this time is not enough to generate the best fake picture for image restoration, because the probability distribution of the input of the fake picture is not necessarily consistent with the probability distribution of the picture to be restored, so the input noise of the fake picture is iteratively updated until the probability distribution of the input after training is consistent with the picture to be restored, so that the fake picture generated by the generator and the damaged original picture can be extracted. Figure 1For damaged blocks of the same size and position, the image restoration work can be completed by simply splicing the damaged blocks with the image to be restored.

[0041] In one embodiment, the step S101 includes:

[0042] Binarization is performed on the image to be repaired to obtain a binary image;

[0043] The findContours method is used to calculate the contour of the binary image to obtain a point set of the contour;

[0044] The boundingRect method is used to calculate the initial minimum bounding rectangle of the point set, and the coordinates of any corner of the initial minimum bounding rectangle and the width and height of the initial minimum bounding rectangle are obtained;

[0045] Constructing an initial minimum bounding rectangle based on any corner coordinates, width and height;

[0046] The boundary of the initial minimum bounding rectangle is expanded according to a preset pixel value to obtain the minimum bounding rectangle.

[0047] In this embodiment, the image to be repaired is first binarized, and then the contour of the binarized image and its point set, as well as the position and size information of the initial minimum enclosing rectangle are calculated respectively by the findContours method and the boundingRect method, and then the initial minimum enclosing rectangle can be constructed. Further, in order to improve the repair effect, the initial minimum enclosing rectangle is expanded to obtain the minimum enclosing rectangle. For example, the center point of the initial minimum enclosing rectangle is calculated, and the length of the four sides of the rectangle to be expanded is preset, such as the preset expansion pixels are 32, and a new rectangle, namely the minimum enclosing rectangle, is obtained. The findContours method described in this embodiment is to use the findContours function to perform contour retrieval on the binarized image, and the boundingRect method is to use the boundingRect function to calculate the horizontal coordinate, vertical coordinate, length and width of the measured object. The boundingRect function plays an important role in image processing because it can be used to measure the size and position of an object, thereby determining the range and configuration of the object and obtaining the minimum enclosing rectangle of the object.

[0048] In one embodiment, the step S102 includes:

[0049] Determine whether the computer is equipped with a discrete graphics card;

[0050] If the computer is provided with an independent graphics card, obtaining the video memory data of the independent graphics card;

[0051] If the computer is not equipped with an independent graphics card, the memory data of the computer is obtained;

[0052] The maximum executable image size of the computer is determined according to the video memory data or the internal memory data.

[0053] The storage information described in this embodiment specifically includes the video memory data and the memory data of the computer. Therefore, when the maximum executable image size of the computer is set by the storage information, the video memory data of the independent graphics card can be directly obtained when the computer is equipped with an independent graphics card, and then the maximum executable image size of the computer can be confirmed according to the video memory data. When the computer is not equipped with an independent graphics card, the maximum executable image size of the computer can be confirmed by obtaining the memory data.

[0054] In one embodiment, the step S103 includes:

[0055] When the size of the minimum bounding rectangle is within the range of the maximum executable image size, an expansion coefficient is calculated according to the size of the minimum bounding rectangle and the maximum executable image size, and the minimum bounding rectangle is expanded and adjusted according to the expansion coefficient;

[0056] When the size of the minimum bounding rectangle exceeds the maximum executable image size range, a reduction coefficient is calculated according to the size of the minimum bounding rectangle and the maximum executable image size, and the minimum bounding rectangle is reduced and adjusted according to the reduction coefficient;

[0057] The cropping coordinates are extracted based on the minimum bounding rectangle after the expansion adjustment or the reduction adjustment.

[0058] In this embodiment, when comparing the size of the minimum bounding rectangle and the maximum executable image size, if the size of the minimum bounding rectangle is smaller than the maximum executable image size, then the size of the minimum bounding rectangle can be expanded to the maximum executable image size. Conversely, if the size of the minimum bounding rectangle is larger than the maximum executable image size, then the size of the minimum bounding rectangle can be reduced to the maximum executable image size. By the above-mentioned expansion or reduction method, it can be ensured that the subsequent image restoration model will not be affected by the input size when performing image restoration, thereby ensuring the image restoration effect.

[0059] In one embodiment, in combination Figure 5 and Figure 6 As shown, the step S104 includes:

[0060] Cutting the image to be repaired according to the cutting coordinates to obtain a first cut image of the image to be repaired; and cutting the mask image according to the cutting coordinates to obtain a second cut image of the mask;

[0061] Determining whether the first cropped image and the second cropped image need to be scaled according to computer storage information;

[0062] When it is determined that the first cropped image and / or the second cropped image needs to be scaled, the scaling ratio is calculated in combination with computer storage information and the size of the minimum circumscribed rectangle, and the first cropped image and / or the second cropped image is scaled according to the scaling ratio.

[0063] In this embodiment, the image to be repaired and the mask image are cut according to the cutting coordinates to obtain the first cut images corresponding to each of them (such as Figure 5 as shown) and the second cropped image (as Figure 6 As shown), then determine whether to perform scaling processing on it, and after determining that scaling processing is required, a scaling ratio can be calculated through computer storage information, the size of the minimum bounding rectangle and other information, and the scaling processing can be implemented using the scaling ratio. For example, according to the video memory or memory resource situation, when running a 512×512 model, 2048Mb of video memory or memory is required. If the computer has a graphics card, the available graphics card memory size will be calculated. For example, if the available video memory size is 4096Mb and the cropped image size is 640×640, then the scaling ratio S can be calculated according to the following formula:

[0064] S = (512*512) / (640*640)*√(4096 / 2048) = 0.91; where √ represents the square root.

[0065] If your computer does not have a graphics card, the cropped image can be scaled to 512×512 by default.

[0066] In one embodiment, the step S105 includes:

[0067] Acquire the repair result image output by the image repair model, and restore the size of the repair result image to the size of the cropped image;

[0068] The image to be repaired is filled according to the cropping coordinates.

[0069] After obtaining the repair result image, this embodiment restores its size so that its size matches the size of the cropped image, so that it can match the to-be-filled area of ​​the to-be-repaired image. Figure 7 After the repair result image is filled into the image to be repaired, the image repair operation is completed. The repaired result is as follows: Figure 8 shown.

[0070] Figure 2A schematic block diagram of an image restoration device 200 provided in an embodiment of the present invention, the device 200 includes:

[0071] The image acquisition unit 201 is used to acquire the image to be repaired and its mask image, and extract the minimum circumscribed rectangle of the mask image;

[0072] The storage information acquisition unit 202 is used to acquire the storage information of the computer and set the maximum executable image size according to the storage information;

[0073] The rectangle adjustment unit 203 is used to compare the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjust the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate;

[0074] An image cropping unit 204, configured to crop the image to be repaired and the mask image based on the cropping coordinates to obtain a cropped image;

[0075] The repair filling unit 205 is used to input the cropped image into an image repair model, and the image repair model outputs a repair result image, and then fill the repair result image into the image to be repaired.

[0076] In one embodiment, the image acquisition unit 201 includes:

[0077] A binarization processing unit, used for performing binarization processing on the image to be repaired to obtain a binarized image;

[0078] A contour calculation unit, used to calculate the contour of the binary image using a findContours method to obtain a point set of the contour;

[0079] An initial rectangle calculation unit, used to calculate the initial minimum bounding rectangle of the point set by using a boundingRect method, and obtain any corner coordinate of the initial minimum bounding rectangle and the width and height of the initial minimum bounding rectangle;

[0080] An initial rectangle construction unit, used to construct an initial minimum bounding rectangle based on any corner coordinates, width and height;

[0081] The boundary expansion unit is used to expand the boundary of the initial minimum bounding rectangle according to a preset pixel value to obtain the minimum bounding rectangle.

[0082] In one embodiment, the storage information acquisition unit 202 includes:

[0083] A graphics card determination unit, used to determine whether the computer is equipped with an independent graphics card;

[0084] A video memory acquisition unit, used for acquiring video memory data of an independent graphics card if the computer is provided with the independent graphics card;

[0085] A memory acquisition unit, used for acquiring memory data of the computer if the computer is not provided with an independent graphics card;

[0086] The size confirmation unit is used to confirm the maximum executable image size of the computer according to the video memory data or the internal memory data.

[0087] In one embodiment, the rectangle adjustment unit 203 includes:

[0088] A rectangle expansion unit, configured to calculate an expansion coefficient according to the size of the minimum circumscribed rectangle and the maximum executable image size when the size of the minimum circumscribed rectangle is within the range of the maximum executable image size, and to expand and adjust the minimum circumscribed rectangle according to the expansion coefficient;

[0089] A rectangle reduction unit, configured to calculate a reduction coefficient according to the size of the minimum circumscribed rectangle and the maximum executable image size when the size of the minimum circumscribed rectangle exceeds the maximum executable image size range, and to reduce and adjust the minimum circumscribed rectangle according to the reduction coefficient;

[0090] The coordinate extraction unit is used to extract the cropping coordinates based on the minimum bounding rectangle after the expansion adjustment or the reduction adjustment.

[0091] In one embodiment, the image cropping unit 204 includes:

[0092] A cropped image acquisition unit, configured to crop the image to be repaired according to the cropped coordinates to obtain a first cropped image of the image to be repaired; and crop the mask image according to the cropped coordinates to obtain a second cropped image of the mask;

[0093] A scaling judgment unit, used for judging whether the first cropped image and the second cropped image need to be scaled according to computer storage information;

[0094] A scaling processing unit is used to calculate a scaling ratio by combining computer storage information and the size of a minimum circumscribed rectangle when determining that the first cropped image and / or the second cropped image needs to be scaled, and scale the first cropped image and / or the second cropped image according to the scaling ratio.

[0095] In one embodiment, the repair filling unit 205 includes:

[0096] A size grayscale unit, used for obtaining the repair result image output by the image repair model, and restoring the size of the repair result image to the size of the cropped image;

[0097] An image filling unit is used to fill the image to be repaired according to the cropping coordinates.

[0098] In one embodiment, the image restoration model adopts image restoration technology based on deep learning.

[0099] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0100] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0101] The embodiment of the present invention also provides a computer device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the computer device may also include various network interfaces, power supplies and other components.

[0102] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

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

Claims

1. An image restoration method, characterized in that: include: Acquire the image to be repaired and its mask image, and extract the minimum circumscribed rectangle of the mask image; Obtaining storage information of the computer, and setting a maximum executable image size according to the storage information; Comparing the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjusting the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate; Based on the cutting coordinates, the image to be repaired and the mask image are cut respectively to obtain a cut image; The cropped image is input into an image restoration model, and the image restoration model outputs a restoration result image, and then the restoration result image is filled into the image to be restored; The step of comparing the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjusting the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate includes: When the size of the minimum bounding rectangle is within the range of the maximum executable image size, an expansion coefficient is calculated according to the size of the minimum bounding rectangle and the maximum executable image size, and the minimum bounding rectangle is expanded and adjusted according to the expansion coefficient; When the size of the minimum bounding rectangle exceeds the maximum executable image size range, a reduction coefficient is calculated according to the size of the minimum bounding rectangle and the maximum executable image size, and the minimum bounding rectangle is reduced and adjusted according to the reduction coefficient; The cropping coordinates are extracted based on the minimum bounding rectangle after the expansion adjustment or the reduction adjustment.

2. The image restoration method according to claim 1, characterized in that: The step of obtaining the image to be repaired and its mask image, and extracting the minimum bounding rectangle of the mask image, includes: Binarization is performed on the image to be repaired to obtain a binary image; The findContours method is used to calculate the contour of the binary image to obtain a point set of the contour; The boundingRect method is used to calculate the initial minimum bounding rectangle of the point set, and the coordinates of any corner of the initial minimum bounding rectangle and the width and height of the initial minimum bounding rectangle are obtained; Constructing an initial minimum bounding rectangle based on any corner coordinates, width and height; The boundary of the initial minimum bounding rectangle is expanded according to a preset pixel value to obtain the minimum bounding rectangle.

3. The image restoration method according to claim 1, characterized in that: The obtaining of storage information of the computer and setting the maximum executable image size according to the storage information includes: Determine whether the computer is equipped with a discrete graphics card; If the computer is provided with an independent graphics card, obtaining the video memory data of the independent graphics card; If the computer is not equipped with an independent graphics card, the memory data of the computer is obtained; The maximum executable image size of the computer is determined according to the video memory data or the internal memory data.

4. The image restoration method according to claim 1, characterized in that: The step of respectively cutting the image to be repaired and the mask image based on the cutting coordinates to obtain a cut image includes: Cutting the image to be repaired according to the cutting coordinates to obtain a first cut image of the image to be repaired; and cutting the mask image according to the cutting coordinates to obtain a second cut image of the mask; Determining whether the first cropped image and the second cropped image need to be scaled according to computer storage information; When it is determined that the first cropped image and / or the second cropped image needs to be scaled, the scaling ratio is calculated in combination with computer storage information and the size of the minimum circumscribed rectangle, and the first cropped image and / or the second cropped image is scaled according to the scaling ratio.

5. The image restoration method according to claim 1, characterized in that: The step of inputting the cropped image into an image restoration model, outputting a restoration result image by the image restoration model, and then filling the restoration result image into the image to be restored comprises: Acquire the repair result image output by the image repair model, and restore the size of the repair result image to the size of the cropped image; The image to be repaired is filled according to the cropping coordinates.

6. The image restoration method according to claim 1, characterized in that: The image restoration model adopts image restoration technology based on deep learning.

7. An image restoration device, characterized in that: include: An image acquisition unit, used to acquire the image to be repaired and its mask image, and extract the minimum circumscribed rectangle of the mask image; A storage information acquisition unit, used to acquire storage information of the computer and set a maximum executable image size according to the storage information; A rectangle adjustment unit, used for comparing the size of the minimum bounding rectangle with the maximum executable image size to obtain a comparison result, and adjusting the minimum bounding rectangle according to the comparison result to obtain a cropping coordinate; An image cutting unit, used for cutting the image to be repaired and the mask image based on the cutting coordinates to obtain a cut image; A repair and filling unit, used for inputting the cropped image into an image repair model, and having the image repair model output a repair result image, and then filling the repair result image into the image to be repaired; The rectangle adjustment unit comprises: A rectangle expansion unit, configured to calculate an expansion coefficient according to the size of the minimum circumscribed rectangle and the maximum executable image size when the size of the minimum circumscribed rectangle is within the range of the maximum executable image size, and to expand and adjust the minimum circumscribed rectangle according to the expansion coefficient; A rectangle reduction unit, configured to calculate a reduction coefficient according to the size of the minimum circumscribed rectangle and the maximum executable image size when the size of the minimum circumscribed rectangle exceeds the maximum executable image size range, and to reduce and adjust the minimum circumscribed rectangle according to the reduction coefficient; The coordinate extraction unit is used to extract the cropping coordinates based on the minimum bounding rectangle after the expansion adjustment or the reduction adjustment.

8. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the image restoration method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image restoration method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Image elimination and restoration method and device thereof, equipment, medium and product

    CN114049280A