CN114298937B - JPEG photo restoration method and device and related components - Google Patents

JPEG photo restoration method and device and related components Download PDF

Info

Publication number
CN114298937B
CN114298937B CN202111638119.8A CN202111638119A CN114298937B CN 114298937 B CN114298937 B CN 114298937B CN 202111638119 A CN202111638119 A CN 202111638119A CN 114298937 B CN114298937 B CN 114298937B
Authority
CN
China
Prior art keywords
pixel
pixel value
mask
target
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111638119.8A
Other languages
Chinese (zh)
Other versions
CN114298937A (en
Inventor
李盛
肖琳琳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Ruan Niu Technology Group Co ltd
Original Assignee
Shenzhen Ruan Niu Technology Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Ruan Niu Technology Group Co ltd filed Critical Shenzhen Ruan Niu Technology Group Co ltd
Priority to CN202111638119.8A priority Critical patent/CN114298937B/en
Publication of CN114298937A publication Critical patent/CN114298937A/en
Application granted granted Critical
Publication of CN114298937B publication Critical patent/CN114298937B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses a method, a device and related components for repairing a JPEG photo, wherein the method comprises the steps of extracting a thumbnail of the JPEG photo and obtaining a superresolution picture; reading an original image of the JPEG photo, and filling lost pixels in the original image; acquiring an initial mask of an original image, searching and recording a damage target area with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to 0; filling the corresponding positions of the initial mask to obtain a target mask; performing pixel value conversion on the target mask to obtain a matched mask; updating all pixel points in the region with the pixel value of 255 in the target mask corresponding to the original image to 0; updating all pixel points in the region with the pixel value of 255 in the matching mask corresponding to the superdivision graph to 0; matrix adding is carried out on the superdivision graph and the original graph, and a target photo is output; the target photo obtained by the method has better visual effect than the superresolution graph, and more comprehensive effective information is obtained by utilizing reserved data.

Description

JPEG photo restoration method and device and related components
Technical Field
The present invention relates to the field of image processing, and in particular, to a method and apparatus for repairing a JPEG photograph, and related components.
Background
At present, photos shot by Android or iphone mobile phones are in jpeg format, and basically have thumbnail images; in the case that a network transmission terminal or a local disk loses part of data, an original photo is damaged, and then a thumbnail is extracted instead of an original image, and it is to be noted that the information contained in the thumbnail loses a lot of details.
Therefore, the thumbnail is processed by the super-resolution technology at present to obtain the super-resolution graph with obviously improved effect, but the obtained super-resolution graph is compared with the original graph and has obvious gap, and the retained data cannot be utilized to the greatest extent to obtain the effective information as comprehensive as possible.
Disclosure of Invention
The invention aims to provide a method, a device and related components for repairing a JPEG photo, and aims to solve the problem that the existing superresolution graph cannot utilize reserved data to the greatest extent to acquire effective information as comprehensive as possible.
In order to solve the technical problems, the aim of the invention is realized by the following technical scheme: provided is a method for repairing a JPEG photo, comprising:
Extracting a thumbnail of a JPEG photo, and performing superprocessing on the thumbnail to obtain a superresolution picture;
Reading an original image of the JPEG photo, and filling lost pixels in the original image to fill the pixel value of each lost pixel point to 128;
acquiring an initial mask of the filled original graph, searching and recording a damage target area with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to 0;
Filling the corresponding position of the initial mask after the initial mask is set to 0 based on the recorded damage target area, and updating the pixel value of each pixel point of the damage target area to 255 to obtain a target mask;
Performing pixel value conversion on all pixel points with the pixel value of 0 and the pixel value of 255 in the target mask, converting the pixel point with the pixel value of 0 into the pixel point with the pixel value of 255, and converting the pixel point with the pixel value of 255 into the pixel point with the pixel value of 0 to obtain a matching mask;
updating the pixel values of all the pixel points in the region with the pixel value of 255 in the target mask corresponding to the original image to be 0, and updating the pixel values of all the pixel points in the region with the pixel value of 255 in the matching mask corresponding to the super-resolution image to be 0;
And carrying out matrix addition on the updated superdivision graph and the original graph, and outputting a target photo.
In addition, the technical problem to be solved by the invention is to provide a repairing device for JPEG photo, comprising:
The superdivision unit is used for extracting the thumbnail of the JPEG photo and performing superprocessing on the thumbnail to obtain a superdivision diagram;
The filling unit is used for reading an original image of the JPEG photo, filling lost pixels in the original image, and filling pixel values of lost pixels to 128;
The searching unit is used for acquiring an initial mask of the filled original image, searching and recording a damage target area with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to 0;
an updating unit, configured to fill the corresponding position of the initial mask after the position 0 is set based on the recorded damage target area, so that the pixel value of each pixel point of the damage target area is updated to 255, and a target mask is obtained;
a first conversion unit, configured to obtain a matching mask of the hyperresolution graph, update, based on the recorded damage target area, a pixel value of each pixel of an area corresponding to the damage target area in the matching mask to be 0, and update a pixel value of each pixel of the remaining areas in the matching mask to be 255;
A second conversion unit, configured to update the pixel values of all the pixel points in the area where the pixel value in the original image corresponds to 255 in the target mask to 0, and update the pixel values of all the pixel points in the area where the pixel value in the super-resolution image corresponds to 255 in the matching mask to 0;
And the output unit is used for carrying out matrix addition on the updated superdivision graph and the original graph and outputting a target photo.
In addition, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the method for repairing a JPEG photograph according to the first aspect when executing the computer program.
In addition, an embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores a computer program, where the computer program when executed by a processor causes the processor to execute the method for repairing a JPEG photograph according to the first aspect.
The embodiment of the invention discloses a method, a device and related components for repairing a JPEG photo, wherein the method comprises the following steps: extracting a thumbnail of a JPEG photo, and performing superprocessing on the thumbnail to obtain a superresolution picture; reading an original image of the JPEG photo, and filling lost pixels in the original image to fill the pixel value of each lost pixel point to 128; acquiring an initial mask of the filled original graph, searching and recording a damage target area with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to 0; filling the corresponding position of the initial mask after the initial mask is set to 0 based on the recorded damage target area, and updating the pixel value of each pixel point of the damage target area to 255 to obtain a target mask; performing pixel value conversion on all pixel points with the pixel value of 0 and the pixel value of 255 in the target mask, converting the pixel point with the pixel value of 0 into the pixel point with the pixel value of 255, and converting the pixel point with the pixel value of 255 into the pixel point with the pixel value of 0 to obtain a matching mask; updating the pixel values of all the pixel points in the region with the pixel value of 255 in the target mask corresponding to the original image to be 0, and updating the pixel values of all the pixel points in the region with the pixel value of 255 in the matching mask corresponding to the super-resolution image to be 0; matrix adding the updated superdivision graph and the original graph, and outputting a target photo; the method comprises the steps of reserving a non-damaged area in an original image, selecting a damaged area in the original image from a superdivision image, and combining the two partial areas, so that a better visual effect is obtained compared with the superdivision image, and the reserved data is utilized to obtain and display the effective information as comprehensively as possible to the greatest extent.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for repairing a JPEG photograph according to an embodiment of the present invention;
FIG. 2 is a display view of a thumbnail provided by an embodiment of the present invention;
FIG. 3 is an illustration of an original diagram provided by an embodiment of the present invention;
FIG. 4 is an illustration of a supergraph provided by an embodiment of the present invention;
FIG. 5 is a diagram showing a target mask provided by an embodiment of the present invention;
FIG. 6 is a display diagram of a target photo provided by an embodiment of the present invention;
FIG. 7 is a schematic block diagram of a repair device for JPEG photos provided by an embodiment of the present invention;
fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, fig. 1 is a flow chart of a method for repairing a JPEG photograph according to an embodiment of the present invention;
as shown in fig. 1, the method includes steps S101 to S107.
S101, extracting a thumbnail of a JPEG photo, and performing superprocessing on the thumbnail to obtain a superresolution diagram;
s102, reading an original image of the JPEG photo, and filling lost pixels in the original image to enable pixel values of lost pixels to be 128;
S103, acquiring an initial mask of the original image after filling, searching and recording a damage target area with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to 0;
S104, filling the corresponding positions of the initial masks after the positions of 0 are set on the basis of the recorded damage target areas, and updating the pixel values of all pixel points of the damage target areas to 255 to obtain target masks;
S105, performing pixel value conversion on all the pixels with the pixel value of 0 and the pixel value of 255 in the target mask, converting the pixel with the pixel value of 0 into the pixel with the pixel value of 255, and converting the pixel with the pixel value of 255 into the pixel with the pixel value of 0 to obtain a matching mask;
s106, updating the pixel values of all the pixel points in the region with the pixel value of 255 in the target mask corresponding to the original image to be 0, and updating the pixel values of all the pixel points in the region with the pixel value of 255 in the matching mask corresponding to the super-resolution image to be 0;
107. and carrying out matrix addition on the updated superdivision graph and the original graph, and outputting a target photo.
In the prior art, only the thumbnail of the JPEG photo is processed in a super-division manner to obtain a corresponding super-division map, and the corresponding super-division map is output, because the detail loss in the thumbnail is serious, even if the super-division map with good visual effect is obtained after the thumbnail is processed by the super-resolution technology, the output requirement of the image cannot be met, so that in order to maximally utilize the reserved data to acquire and display the effective information as comprehensively as possible, the application searches the SOI (FFD 8) and the EOI (FFD 9) according to the identifier markers of the JPEG standard to obtain the corresponding thumbnail of the JPEG photo (shown in fig. 2), and then the super-resolution technology is utilized to perform the super-division processing on the obtained thumbnail to obtain the corresponding super-division map (shown in fig. 4), and the description is that the super-resolution technology is a depth learning algorithm such as realsr.
Reading an original image (shown in fig. 3) of the JPEG photo, it should be noted that the original image of the present application is an original image with local damage, that is, an area where a part of lost pixels exist in the original image, and in the opencv library, the original image is also a data type of matrix Mat, and has various attributes such as size, element type, etc.; the application fills the areas of the missing pixels with gray RGB (128, 128, 128), where the boundary between the areas of the missing pixels and the areas of the non-missing pixels will be different, but also gray, and the gray values will float in a small range.
In order to initially divide the gray area, namely the damaged area, the application firstly obtains the initial mask of the original image after filling, and because the initial mask can have more or less noise points in the corresponding undamaged area, each gray area needs to be found in the initial mask, and the gray area with the largest area is taken as the damaged target area based on the condition that the possibility of the occurrence of a large pure gray area in an actual photo is small, so that the original image is eliminated from the gray area, and the damaged part is circled; and simultaneously recording the damage target area, setting the pixel value of each pixel point in the initial mask to 0, wherein the whole initial mask is black, and updating the pixel value of each pixel point in the damage target area of the initial mask from 0 to 255 based on the previously recorded damage target area, wherein the damage target area of the initial mask becomes white to obtain a target mask, namely, the target mask becomes an image with black and white phases.
Then, performing pixel value conversion on all pixel points with the pixel value of 0 and the pixel value of 255 in the target mask, so that the pixel point with the pixel value of 0 is converted into the pixel point with the pixel value of 255, and the pixel point with the pixel value of 255 is converted into the pixel point with the pixel value of 0, thereby obtaining a matched mask; and updating the pixel values of all the pixel points in the region with the pixel value of 255 in the target mask corresponding to the original image to be 0, updating the pixel values of all the pixel points in the region with the pixel value of 255 in the matching mask corresponding to the superdivision image to be 0, namely setting the region with the superdivision image corresponding to the damage target region to be 0, for the original image, selecting the region with the pixel value of 255 in each pixel point in the target mask, finally integrally adding the processed original image and the superdivision image, wherein the region with the pixel value of 0 in the original image and the superdivision image are just not overlapped, namely the region with the pixel value of 0 in the original image does not change the value of the region corresponding to the superdivision image, and the region with the pixel value of 0 in the superdivision image does not change the value of the region corresponding to the original image.
The target photo (shown in figure 6) obtained by the JPEG photo restoration method can furthest utilize the reserved data to acquire and display the effective information as comprehensively as possible, and the photo detail is far better than the superresolution graph.
In one embodiment, the step S102 includes the steps of:
S10, reading an original graph by utilizing imread functions;
And S11, filling the lost pixels in the original graph by utilizing imread functions.
It should be noted that the imread function in this embodiment is a function in the opencv library, which is used to read the data in the picture file, and the gray value of the actual data loss may be filled with the imread function.
In an embodiment, before the step S103, the method includes the following steps:
S20, downsampling the original image by utilizing pyrDown functions to enable the size of the original image to reach a preset threshold;
S21, adjusting the size of the original image after downsampling to enable the size of the original image to be the same as that of the super-resolution image;
S22, converting the original graph into an HSV color space by utilizing cvtColor functions.
It should be noted that pyrDown is a downsampling operation, and the size of the resize is a size-adjusting operation, because the aspect ratio of the thumbnail (corresponding super-resolution image is the same) is not necessarily the same as that of the original image, if the thumbnail is directly resize to be combined, there may be a phenomenon that the boundary is obvious and cannot be found, so the application downsamples the original image through pyrDown function, the size of the original image is close to the size of the super-resolution image, or one or an integer multiple is larger than the super-resolution image, but the general multiple is not more than 4, and then the downsampled original image resize is up to the target size, namely the size of the super-resolution image, so as to avoid the problem that the boundary is not found when the thumbnail is combined.
In step S22, cvCvtColor is a color space conversion function in Opencv, which can realize conversion from RGB colors to HSV, HSI and other color spaces, and also can convert the RGB colors to gray images, and the parameters used in the present application are BRG2HSV, and it should be noted that the HSV color space is easy to quickly divide different color areas, and the RGB space is difficult to divide different color areas.
In one embodiment, the step S103 includes the steps of:
s30, acquiring an initial mask of the original graph by utilizing inRange functions;
S31, searching all gray areas of the initial mask by utilizing findContours functions;
S32, calculating the area of each gray area by utilizing contourArea functions;
s33, comparing and judging the area of each gray area, finding the gray area with the largest area, and taking the gray area as a damage target area.
In the present embodiment, the "inRange function" can implement a binarization function, setting the pixel values within the two thresholds to white (255) and the pixel values not within the threshold section to black (0), thereby preliminarily dividing the gray region.
It should be noted that FindContuors, contourArea is a function in the opencv library, the former finds the outline of the possible region in the picture, and the latter calculates the area of each region, and thus finds the largest, i.e., the actual data loss portion. Considering that in an actual photograph, there is a small possibility that a large block of pure gray regions appear, the gray region with the largest area is taken as the damage target region.
In one embodiment, the step S104 includes:
and S40, filling the corresponding positions of the initial mask by utilizing drawContours functions, and updating the pixel value of each pixel point of the damage target area to 255.
In this embodiment, the drawContours functions are functions in the opencv library, and the noise points in the initial mask can be removed by filling drawContours functions in the corresponding positions of the initial mask, so as to obtain the target mask.
Referring to fig. 5, although most of the noise points in the initial mask have been removed, there is a residual at the boundary line, and if the target mask processed in step S40 is directly used for merging, the two parts of the boundary of the merged image will have gray lines with different degrees of depth, so in this embodiment, the following steps in step S104 include:
s50, performing boundary line correction processing on the target mask by utilizing dilate functions.
In this embodiment, dilate functions are functions in the opencv library, and the dilate functions can be used to slightly push the boundary line to the non-lost image portion, that is, the white area slightly expands, the black area slightly contracts, for example, after the graph of the white background and the black word is processed by using the dilate functions, the black word is thinned, so that the noise point of the boundary line of the present application is eliminated.
In one embodiment, the step S105 includes:
And S60, based on the recorded damage target area, updating the pixel value of each pixel point of the area corresponding to the damage target area in the coordination mask to be 0 by using a complexent function or bitwise _not function, and updating the pixel value of each pixel point of the rest area in the coordination mask to be 255.
In this embodiment, the complex function or bitwise _not function is a function in the opencv library, and the pixel value of each pixel point of the region corresponding to the damage target region in the cooperation mask can be updated to 0 through both functions, and the pixel value of each pixel point of the remaining region in the cooperation mask is updated to 255.
In one embodiment, the step S107 includes:
and S70, performing matrix addition on the updated superdivision graph and the original graph, and storing the superdivision graph and the original graph in a preset format by utilizing imwrite functions to obtain a target photo in a corresponding format.
It should be noted that imwrite functions are functions in opencv library, and the present application can save the target photo in various formats, such as jpg, jpeg, etc.
The embodiment of the invention also provides a device for repairing the JPEG photo, which is used for executing any embodiment of the method for repairing the JPEG photo. Specifically, referring to fig. 7, fig. 7 is a schematic block diagram of a repair device for a JPEG photograph according to an embodiment of the present invention.
As shown in fig. 7, a repair device 500 of a JPEG photograph includes:
the superdivision unit 501 extracts a thumbnail of the JPEG photo and performs superdivision processing on the thumbnail to obtain a superdivision diagram;
A filling unit 502, configured to read an original image of the JPEG photograph, fill lost pixels in the original image, and fill pixel values of each lost pixel point to 128;
A searching unit 503, configured to obtain an initial mask of the original image after filling, find and record a damage target area with the largest area in the initial mask, and set a pixel value of each pixel point in the initial mask to 0;
Updating unit 504, configured to fill the corresponding position of the initial mask after the position 0 is set based on the recorded damage target area, so that the pixel value of each pixel point of the damage target area is updated to 255, and a target mask is obtained;
A first conversion unit 505, configured to perform pixel value conversion on all pixels with pixel values of 0 and 255 in the target mask, convert the pixels with pixel values of 0 into pixels with pixel values of 255, and convert the pixels with pixel values of 255 into pixels with pixel values of 0, so as to obtain a matching mask;
A second converting unit 506, configured to update the pixel values of all the pixels in the region with the pixel value of 255 in the target mask corresponding to the original graph to be 0, and update the pixel values of all the pixels in the region with the pixel value of 255 in the matching mask corresponding to the super-resolution graph to be 0;
And an output unit 507 for matrix-adding the updated superdivision graph and the original graph, and outputting the target photo.
The target photo obtained by the device can be used for obtaining and displaying the effective information as comprehensively as possible by utilizing the reserved data to the greatest extent, and the photo detail is far better than the superresolution graph.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus and units described above may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again.
The repair device of a JPEG photograph as described above may be implemented in the form of a computer program which may be run on a computer device as shown in fig. 8.
Referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present invention. The computer device 1100 is a server, and the server may be a stand-alone server or a server cluster formed by a plurality of servers.
With reference to FIG. 8, the computer device 1100 includes a processor 1102, memory, and a network interface 1105 connected through a system bus 1101, wherein the memory may include a non-volatile storage medium 1103 and an internal memory 1104.
The non-volatile storage medium 1103 may store an operating system 11031 and computer programs 11032. The computer program 11032, when executed, causes the processor 1102 to perform a method for repairing a JPEG photograph.
The processor 1102 is operable to provide computing and control capabilities to support the operation of the overall computer device 1100.
The internal memory 1104 provides an environment for the execution of a computer program 11032 in the nonvolatile storage medium 1103, which computer program 11032, when executed by the processor 1102, causes the processor 1102 to execute a method for repairing a JPEG photograph.
The network interface 1105 is used for network communication such as providing transmission of data information, etc. It will be appreciated by those skilled in the art that the architecture shown in fig. 8 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting of the computer device 1100 to which the present inventive arrangements may be implemented, and that a particular computer device 1100 may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
Those skilled in the art will appreciate that the embodiment of the computer device shown in fig. 8 is not limiting of the specific construction of the computer device, and in other embodiments, the computer device may include more or less components than those shown, or certain components may be combined, or a different arrangement of components. For example, in some embodiments, the computer device may include only a memory and a processor, and in such embodiments, the structure and function of the memory and the processor are consistent with the embodiment shown in fig. 8, and will not be described again.
It should be appreciated that in an embodiment of the invention, the Processor 1102 may be a central processing unit (Central Processing Unit, CPU), the Processor 1102 may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL processors, DSPs), application SPECIFIC INTEGRATED Circuits (ASICs), off-the-shelf Programmable gate arrays (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In another embodiment of the invention, a computer-readable storage medium is provided. The computer readable storage medium may be a non-volatile computer readable storage medium. The computer readable storage medium stores a computer program, wherein the computer program when executed by a processor implements a method for repairing a JPEG photograph according to an embodiment of the present invention.
The storage medium is a physical, non-transitory storage medium, and may be, for example, a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (10)

1. A method for repairing a JPEG photograph, comprising:
Extracting a thumbnail of a JPEG photo, and performing superprocessing on the thumbnail to obtain a superresolution picture;
Reading an original image of the JPEG photo, and filling lost pixels in the original image to fill the pixel value of each lost pixel point to 128;
acquiring an initial mask of the filled original graph, searching and recording a damage target area with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to 0;
Filling the corresponding position of the initial mask after the initial mask is set to 0 based on the recorded damage target area, and updating the pixel value of each pixel point of the damage target area to 255 to obtain a target mask;
Performing pixel value conversion on all pixel points with the pixel value of 0 and the pixel value of 255 in the target mask, converting the pixel point with the pixel value of 0 into the pixel point with the pixel value of 255, and converting the pixel point with the pixel value of 255 into the pixel point with the pixel value of 0 to obtain a matching mask;
updating the pixel values of all the pixel points in the region with the pixel value of 255 in the target mask corresponding to the original image to be 0, and updating the pixel values of all the pixel points in the region with the pixel value of 255 in the matching mask corresponding to the super-resolution image to be 0;
And carrying out matrix addition on the updated superdivision graph and the original graph, and outputting a target photo.
2. The method for repairing a JPEG photograph according to claim 1, wherein said reading an original picture, filling the missing pixels in said original picture such that the pixel value of each missing pixel point is 128, comprises:
reading the original graph by utilizing imread functions;
and filling the lost pixels in the original graph by using imread functions.
3. The method for repairing a JPEG photograph according to claim 1, wherein said obtaining an initial mask of said original image after filling, searching and recording a damage target area with a largest area in said initial mask, and before setting a pixel value of each pixel point in said initial mask to 0, comprises:
downsampling the original image by using pyrDown functions to enable the size of the original image to reach a preset threshold;
The size of the original image after downsampling is adjusted, so that the size of the original image is the same as that of the superdivision image;
The original graph is converted to HSV color space using cvtColor functions.
4. A repair method of a JPEG photograph according to any of the claims 1 to 3, wherein said obtaining an initial mask of said original map after filling, searching and recording a damage target area with a largest area in said initial mask, comprises:
Acquiring an initial mask of the original graph by utilizing inRange functions;
searching all gray areas of the initial mask using findContours functions;
Calculating the area of each gray area by utilizing contourArea functions;
comparing and judging the area of each gray area, finding the gray area with the largest area, and taking the gray area as the damage target area.
5. The method according to claim 1, wherein the filling the initial mask corresponding position after the position of 0 to update the pixel value of each pixel point of the damage target area to 255, comprises:
Filling at the corresponding position of the initial mask by using drawContours functions, so that the pixel value of each pixel point of the damage target area is updated to 255.
6. The method for repairing a JPEG photograph according to claim 1, wherein said filling the corresponding position of said initial mask after the lapse of 0 based on said recorded damaged target area, to update the pixel value of each pixel of said damaged target area to 255, to obtain a target mask, comprises:
and carrying out boundary line correction processing on the target mask by utilizing dilate functions.
7. The method for repairing a JPEG photograph according to claim 1, wherein said performing pixel value conversion on all pixels with pixel values of 0 and 255 in said target mask, converting the pixels with pixel values of 0 into pixels with pixel values of 255, and converting the pixels with pixel values of 255 into pixels with pixel values of 0, obtaining a fitting mask, comprises:
And performing pixel value conversion on all the pixels with the pixel value of 0 and the pixel value of 255 in the target mask by using a complexent function or bitwise _not function, converting the pixel with the pixel value of 0 into the pixel with the pixel value of 255, and converting the pixel with the pixel value of 255 into the pixel with the pixel value of 0 to obtain the matched mask.
8. A repair device for a JPEG photograph, comprising:
The superdivision unit is used for extracting the thumbnail of the JPEG photo and performing superprocessing on the thumbnail to obtain a superdivision diagram;
The filling unit is used for reading an original image of the JPEG photo, filling lost pixels in the original image, and filling pixel values of lost pixels to 128;
The searching unit is used for acquiring an initial mask of the filled original image, searching and recording a damage target area with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to 0;
an updating unit, configured to fill the corresponding position of the initial mask after the position 0 is set based on the recorded damage target area, so that the pixel value of each pixel point of the damage target area is updated to 255, and a target mask is obtained;
a first conversion unit, configured to perform pixel value conversion on all pixels with pixel values of 0 and 255 in the target mask, so that the pixel with pixel value of 0 is converted into the pixel with pixel value of 255, and the pixel with pixel value of 255 is converted into the pixel with pixel value of 0, so as to obtain a matching mask;
A second conversion unit, configured to update the pixel values of all the pixel points in the area where the pixel value in the original image corresponds to 255 in the target mask to 0, and update the pixel values of all the pixel points in the area where the pixel value in the super-resolution image corresponds to 255 in the matching mask to 0;
And the output unit is used for carrying out matrix addition on the updated superdivision graph and the original graph and outputting a target photo.
9. Computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements a method of repairing a JPEG photograph according to any of the claims 1 to 7 when executing the computer program.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program which, when executed by a processor, causes the processor to perform a method of repairing a JPEG photograph according to any of the claims 1 to 7.
CN202111638119.8A 2021-12-29 2021-12-29 JPEG photo restoration method and device and related components Active CN114298937B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111638119.8A CN114298937B (en) 2021-12-29 2021-12-29 JPEG photo restoration method and device and related components

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111638119.8A CN114298937B (en) 2021-12-29 2021-12-29 JPEG photo restoration method and device and related components

Publications (2)

Publication Number Publication Date
CN114298937A CN114298937A (en) 2022-04-08
CN114298937B true CN114298937B (en) 2024-05-17

Family

ID=80971454

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111638119.8A Active CN114298937B (en) 2021-12-29 2021-12-29 JPEG photo restoration method and device and related components

Country Status (1)

Country Link
CN (1) CN114298937B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107464230A (en) * 2017-08-23 2017-12-12 京东方科技集团股份有限公司 Image processing method and device
WO2018036462A1 (en) * 2016-08-22 2018-03-01 腾讯科技(深圳)有限公司 Image segmentation method, computer apparatus, and computer storage medium
WO2020038207A1 (en) * 2018-08-21 2020-02-27 Huawei Technologies Co., Ltd. Binarization and normalization-based inpainting for removing text

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018036462A1 (en) * 2016-08-22 2018-03-01 腾讯科技(深圳)有限公司 Image segmentation method, computer apparatus, and computer storage medium
CN107464230A (en) * 2017-08-23 2017-12-12 京东方科技集团股份有限公司 Image processing method and device
WO2020038207A1 (en) * 2018-08-21 2020-02-27 Huawei Technologies Co., Ltd. Binarization and normalization-based inpainting for removing text

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种结合多种图像分割算法的实例分割方案;詹琦梁;陈胜勇;胡海根;李小薪;周乾伟;;小型微型计算机***;20200409(第04期);全文 *

Also Published As

Publication number Publication date
CN114298937A (en) 2022-04-08

Similar Documents

Publication Publication Date Title
CN107967669B (en) Picture processing method and device, computer equipment and storage medium
JP6763417B2 (en) Electronics
US8644605B2 (en) Mapping colors of an image
US9679366B2 (en) Guided color grading for extended dynamic range
US7978922B2 (en) Compressing images in documents
CN111563908B (en) Image processing method and related device
CN112602088B (en) Method, system and computer readable medium for improving quality of low light images
CN111192239B (en) Remote sensing image change area detection method and device, storage medium and electronic equipment
CN111145106B (en) Image enhancement method, device, medium and equipment
CN108805838B (en) Image processing method, mobile terminal and computer readable storage medium
KR20150031241A (en) A device and a method for color harmonization of an image
US20140185104A1 (en) Image processing device and computer-readable storage medium storing computer-readable instructions
CN111127342A (en) Image processing method and device, storage medium and terminal equipment
CN113744256A (en) Depth map hole filling method and device, server and readable storage medium
CN107220934B (en) Image reconstruction method and device
US20100040304A1 (en) Image quality improvement processing apparatus, image quality improvement processing method and computer-readable recording medium storing image quality improvement processing computer program
CN113592720B (en) Image scaling processing method, device, equipment and storage medium
CN110717962A (en) Dynamic photo generation method and device, photographing equipment and storage medium
CN111539975B (en) Method, device, equipment and storage medium for detecting moving object
CN112073718B (en) Television screen splash detection method and device, computer equipment and storage medium
CN114298937B (en) JPEG photo restoration method and device and related components
CN112218005A (en) Video editing method based on artificial intelligence
CN113012031A (en) Image processing method and image processing apparatus
US20200098090A1 (en) Image processing device, image processing system, image processing method, and program
Zheng et al. Joint residual pyramid for joint image super-resolution

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Country or region after: China

Address after: 1301-1310, building 2, jinlitong financial center building, 1100 Xingye Road, Haiwang community, Xin'an street, Bao'an District, Shenzhen, Guangdong 518000

Applicant after: Shenzhen Ruan Niu Technology Group Co.,Ltd.

Address before: 1301-1310, building 2, jinlitong financial center building, 1100 Xingye Road, Haiwang community, Xin'an street, Bao'an District, Shenzhen, Guangdong 518000

Applicant before: AFIRSTSOFT CO.,LTD.

Country or region before: China

GR01 Patent grant
GR01 Patent grant