CN114298937A - JPEG photo repairing method, device and related components - Google Patents

JPEG photo repairing method, device and related components Download PDF

Info

Publication number
CN114298937A
CN114298937A CN202111638119.8A CN202111638119A CN114298937A CN 114298937 A CN114298937 A CN 114298937A CN 202111638119 A CN202111638119 A CN 202111638119A CN 114298937 A CN114298937 A CN 114298937A
Authority
CN
China
Prior art keywords
pixel
mask
target
original image
pixel value
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.)
Granted
Application number
CN202111638119.8A
Other languages
Chinese (zh)
Other versions
CN114298937B (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.)
Afirstsoft Co Ltd
Original Assignee
Afirstsoft 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 Afirstsoft Co Ltd filed Critical Afirstsoft Co Ltd
Priority to CN202111638119.8A priority Critical patent/CN114298937B/en
Priority claimed from CN202111638119.8A external-priority 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

Images

Abstract

The invention discloses a method, a device and a related component for repairing a JPEG (joint photographic experts group) photo, wherein the method comprises the steps of extracting a thumbnail of the JPEG photo and obtaining a super-resolution image; 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 region with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to be 0; filling the corresponding position of the initial mask to obtain a target mask; performing pixel value conversion on the target mask to obtain a matching mask; updating all pixel points in the region of 255 pixel values in the target mask corresponding to the original image to be 0; updating all pixel points in the area of 255 pixel values in the corresponding matching mask of the hyper-map to be 0; performing matrix addition on the super-resolution image and the original image, and outputting a target photo; the target photo obtained by the method has better visual effect than the hyper-map, and more comprehensive effective information is obtained by utilizing the reserved data.

Description

JPEG photo repairing method, device and related components
Technical Field
The invention relates to the field of image processing, in particular to a JPEG picture restoration method, a JPEG picture restoration device and related components.
Background
At present, photos shot by an Android or iphone mobile phone are in a jpeg format, and thumbnails are basically available in the photos; when a network transmission terminal or a local disk loses part of data, an original photo is damaged, and a thumbnail is extracted instead of the original photo, which needs to be described.
Therefore, the super-resolution technology is often used to process the thumbnail to obtain a super-resolution image with significantly improved effect, but the obtained super-resolution image still has a significant gap with the original image, and the retained data cannot be utilized to the maximum extent to obtain the most comprehensive effective information.
Disclosure of Invention
The invention aims to provide a JPEG photo repairing method, a JPEG photo repairing device and related components, and aims to solve the problem that the existing hyper-resolution image cannot utilize reserved data to the maximum extent to obtain effective information which is as comprehensive as possible.
In order to solve the technical problems, the invention aims to realize the following technical scheme: provided is a JPEG photo repairing method, which comprises the following steps:
extracting thumbnails of JPEG pictures, and carrying out super-resolution processing on the thumbnails to obtain super-resolution pictures;
reading an original image of the JPEG photo, and filling lost pixels in the original image to enable the pixel value filling of each lost pixel point to be 128;
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 be 0;
filling corresponding positions of the initial mask after 0 is arranged on the basis of 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 pixel values of 0 and 255 in the target mask to convert the pixel points with the pixel values of 0 into the pixel points with the pixel values of 255, and converting the pixel points with the pixel values of 255 into the pixel points with the pixel values of 0 to obtain a matching mask;
updating the pixel values of all pixel points in the region of the original graph corresponding to the pixel value of 255 in the target mask to be 0, and updating the pixel values of all pixel points in the region of the hyper-map corresponding to the pixel value of 255 in the matching mask to be 0;
and performing matrix addition on the updated super-resolution image and the original image, and outputting a target photo.
Another object of the present invention is to provide a JPEG still image restoration apparatus, including:
the super-dividing unit is used for extracting thumbnails of JPEG pictures and carrying out super-dividing processing on the thumbnails to obtain super-divided pictures;
the filling unit is used for reading the original image of the JPEG photo and filling lost pixels in the original image to enable the pixel value of each lost pixel point to be 128;
the searching unit is used for acquiring the filled initial mask of the 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 be 0;
the updating unit is used for filling corresponding positions of the initial mask after 0 is arranged on the basis of the recorded damage target area, so that the pixel value of each pixel point of the damage target area is updated to be 255, and a target mask is obtained;
a first conversion unit, configured to obtain a matching mask of the super-resolution map, update a pixel value of each pixel point of an area corresponding to the damage target area in the matching mask to 0 based on the recorded damage target area, and update a pixel value of each pixel point of a remaining area in the matching mask to 255;
a second conversion unit, configured to update pixel values of all pixel points in a region, where the pixel value in the target mask is 255, of the original graph to 0, and update pixel values of all pixel points in a region, where the pixel value in the matching mask is 255, of the hyper-resolution graph to 0;
and the output unit is used for performing matrix addition on the updated super-resolution image and the original image and outputting the 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 on the memory and executable on the processor, where the processor implements the method for repairing a JPEG photo 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, and the computer program, when executed by a processor, causes the processor to execute the method for repairing a JPEG photo according to the first aspect.
The embodiment of the invention discloses a method, a device and related components for repairing a JPEG (joint photographic experts group) photo, wherein the method comprises the following steps: extracting thumbnails of JPEG pictures, and carrying out super-resolution processing on the thumbnails to obtain super-resolution pictures; reading an original image of the JPEG photo, and filling lost pixels in the original image to enable the pixel value filling of each lost pixel point to be 128; 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 be 0; filling corresponding positions of the initial mask after 0 is arranged on the basis of 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 pixel values of 0 and 255 in the target mask to convert the pixel points with the pixel values of 0 into the pixel points with the pixel values of 255, and converting the pixel points with the pixel values of 255 into the pixel points with the pixel values of 0 to obtain a matching mask; updating the pixel values of all pixel points in the region of the original graph corresponding to the pixel value of 255 in the target mask to be 0, and updating the pixel values of all pixel points in the region of the hyper-map corresponding to the pixel value of 255 in the matching mask to be 0; performing matrix addition on the updated super-resolution image and the original image, and outputting a target photo; the method reserves the non-damaged area in the original image, selects the damaged area in the original image from the hyper-map, and combines the two areas, thereby obtaining better visual effect than the hyper-map and obtaining and displaying effective information as comprehensive as possible by utilizing the reserved data to the maximum extent.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a JPEG photograph restoration method according to an embodiment of the present invention;
FIG. 2 is a display diagram of a thumbnail provided by an embodiment of the present invention;
FIG. 3 is a display diagram of an original diagram provided by an embodiment of the present invention;
FIG. 4 is a display diagram of a super-resolution chart provided by an embodiment of the present invention;
FIG. 5 is a display diagram of a target mask provided by an embodiment of the present invention;
FIG. 6 is a diagram showing a target photo according to an embodiment of the present invention;
FIG. 7 is a schematic block diagram of a JPEG photo restoration apparatus provided by an embodiment of the present invention;
FIG. 8 is a schematic block diagram of a computer device provided by an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It will be understood that the terms "comprises" and/or "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 the specification of the present invention 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 this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
Referring to fig. 1, fig. 1 is a schematic flow chart illustrating a JPEG photo restoration method according to an embodiment of the present invention;
as shown in fig. 1, the method includes steps S101 to S107.
S101, extracting thumbnails of JPEG pictures, and carrying out super-division processing on the thumbnails to obtain super-division pictures;
s102, reading an original image of the JPEG photo, and filling lost pixels in the original image to enable the pixel value filling of each lost pixel point to be 128;
s103, acquiring the filled initial mask of the original image, searching and recording a damage target region with the largest area in the initial mask, and setting the pixel value of each pixel point in the initial mask to be 0;
s104, based on the recorded damage target area, filling corresponding positions of the initial mask after being aligned to 0, and updating the pixel value of each pixel point of the damage target area to 255 to obtain a target mask;
s105, performing pixel value conversion on all pixel points with pixel values of 0 and 255 in the target mask to convert the pixel points with the pixel values of 0 into the pixel points with the pixel values of 255, and converting the pixel points with the pixel values of 255 into the pixel points with the pixel values of 0 to obtain a matching mask;
s106, updating the pixel values of all pixel points in the area, corresponding to the pixel value of 255, in the target mask to 0, of the original graph, and updating the pixel values of all pixel points in the area, corresponding to the pixel value of 255, in the matching mask to 0, of the hyper-map;
107. and performing matrix addition on the updated super-resolution image and the original image, and outputting a target photo.
In the prior art, only the thumbnails of the JPEG photos are subjected to super-resolution processing, and the corresponding super-resolution images are output, because the detail loss in the thumbnails is serious, even if the super-resolution images with good visual effects are obtained after the thumbnails are processed by the super-resolution technology, the output requirements of the images cannot be met, so that in order to obtain effective information which is displayed as comprehensively as possible by using the retained data to the maximum extent, according to the application, the SOI (FFD8) and the EOI (FFD9) are searched for by using identifiers of JPEG standards, thumbnails corresponding to the JPEG photos (as shown in fig. 2) are obtained, then the super-resolution technology is used for performing super-resolution processing on the obtained thumbnails to obtain the corresponding super-resolution images (as shown in fig. 4), and it needs to be noted that the super-resolution technology in the application is a class of depth learning algorithms such as realsr.
Reading an original image (as 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 a local damage, that is, the original image has an area with a part of lost pixels, and in an opencv library, the original image is also a data type of a matrix Mat, and has various attributes such as size and element type; the present application fills the area of the missing pixels with a gray RGB (128, 128, 128), where the boundary between the area of the missing pixels and the area of the non-missing pixels is different, but is also gray, and the value of the gray is floating within a small range.
In order to initially divide a gray area, namely a damaged area, the method first obtains an initial mask of the original image after filling, and because the initial mask has more or less noise points in the corresponding undamaged area, each gray area needs to be found in the initial mask, and based on the condition that the probability of a large pure gray area appearing in an actual picture is very low, the gray area with the largest area is taken as a damaged target area to exclude the gray area of the original image and circle out a damaged part; and simultaneously recording the damaged target area, setting the pixel value of each pixel point in the initial mask to be 0, wherein the whole initial mask is black, updating the pixel value of each pixel point in the damaged target area of the initial mask from 0 to 255 based on the previously recorded damaged target area, wherein the damaged target area of the initial mask is white to obtain a target mask, namely, the target mask is changed into a black-white image.
Then, pixel value conversion is carried out on all pixel points with the pixel values of 0 and 255 in the target mask, so that the pixel points with the pixel values of 0 are converted into the pixel points with the pixel values of 255, the pixel points with the pixel values of 255 are converted into the pixel points with the pixel values of 0, and a matching mask is obtained; and then updating the pixel values of all pixel points in the region of the original image corresponding to the pixel value of 255 in the target mask to 0, updating the pixel values of all pixel points in the region of the hyper-map corresponding to the pixel value of 255 in the matching mask to 0, namely, setting the region of the hyper-map corresponding to the damaged target region to 0, selecting the region of the original image with the pixel value of 255 of each pixel point in the target mask, and finally adding the processed original image and the hyper-map together, wherein the region of 0 in the original image and the hyper-map are just not overlapped, namely the region of 0 in the original image does not change the value of the region corresponding to the hyper-map, and the region of 0 in the hyper-map does not change the value of the region corresponding to the original image.
The target photo (shown in fig. 6) obtained by the JPEG photo restoration method can acquire and display effective information as comprehensive as possible by utilizing the reserved data to the maximum extent, and the details of the photo are far better than those of a hyper-map.
In one embodiment, the step S102 includes the following steps:
s10, reading the original graph by using an imread function;
s11, filling the lost pixels in the original graph by using an imread function.
It should be noted that the imread function in this embodiment is a function in the opencv library, and is used to read data in a picture file, and the gray value of actual data loss may be filled in with the imread function.
In an embodiment, before the step S103, the method includes the following steps:
s20, downsampling the original graph by using a pyrDOWN function to enable the size of the original graph to reach a preset threshold value;
s21, adjusting the size of the original graph after down sampling to make the size of the original graph and the size of the super graph the same;
s22, converting the original graph into an HSV color space by using a cvtColor function.
It should be noted that, pyrDOWN is a downsampling operation, resize is a resizing operation, since the aspect ratio of the thumbnail (and the corresponding hyper-map are the same) is not necessarily the same as that of the original image, and if direct resize merging is performed, there may be a phenomenon that the boundary is not correct, the present application first downsamples the original image through a pyrDOWN function, makes the size of the original image approach the size of the hyper-map, or makes one time or an integral multiple of the original image larger than the hyper-map, but generally makes the multiple not exceed 4, and then resize the downsampled original image to the target size, that is, the size of the hyper-map, so as to avoid the problem of boundary mismatch when merging occurs.
In step S22, cvcvcvtcolor is a color space conversion function in Opencv, and can implement conversion from RGB colors to color spaces such as HSV and HSI, and can also be converted into grayscale images, where the parameter used in this application is BRG2HSV, and it should be noted that HSV color spaces are color regions that are easy to rapidly segment, and RGB spaces are difficult to segment different color regions.
In one embodiment, the step S103 includes the following steps:
s30, acquiring an initial mask of the original image by using an inRange function;
s31, searching all gray areas of the initial mask by using a findContours function;
s32, calculating the area of each gray area by using a contourArea function;
and 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" may implement a binarization function, and set pixel values within two threshold values to white (255) and pixel values not within a threshold interval to black (0), thereby preliminarily dividing a gray region.
It should be noted that findcontours and contourArea are both functions in the opencv library, the former finds the outline of a region that may exist in a picture, and the latter calculates the area of each region, and accordingly finds the largest, and also the actual data loss part. Considering that in an actual photograph, a region where a large block of pure gray appears is likely to be small, a gray region having the largest area is taken as a damage target region.
In one embodiment, the step S104 includes:
and S40, filling the corresponding position of the initial mask by using a drawContours function, and updating the pixel value of each pixel point of the damage target area to 255.
In this embodiment, the drawContours function is a function in the opencv library, and the noise point in the initial mask may be removed by filling the drawContours function in the corresponding position of the initial mask, so as to obtain the target mask.
With reference to fig. 5, although most of the noise points in the initial mask are removed, there will be residual at the boundary line, and if the target mask processed in step S40 is directly used for merging, there will be gray lines with different shades at the boundary between two parts of the merged image, so in this embodiment, the step S104 includes:
and S50, performing boundary line correction processing on the target mask by using a dilate function.
In this embodiment, the dilate function is a function in the opencv library, and the boundary line can be pushed to the non-lost image part slightly by using the dilate function, that is, the white area is slightly expanded, and the black area is slightly contracted, for example, after the graph of the white-background black word is processed by using the dilate function, the black word is slightly thinned, so as to eliminate the noise point of the boundary line in the present application.
In one embodiment, the step S105 includes:
and S60, updating the pixel value of each pixel point of the region corresponding to the damage target region in the matching mask to 0 by using a complete function or a bitwise _ not function based on the recorded damage target region, and updating the pixel value of each pixel point of the remaining region in the matching mask to 255.
In this embodiment, the complete function or the bitwise _ not function are both functions in the opencv library, and the pixel values of the pixels in the region corresponding to the damage target region in the matching mask can be updated to 0 through both the functions, and the pixel values of the pixels in the remaining region in the matching mask can be updated to 255.
In one embodiment, the step S107 includes:
and S70, performing matrix addition on the updated supergraph and the original graph, and storing the supergraph and the original graph into a preset format by using an imwrite function to obtain a target photo in a corresponding format.
It should be noted that the imwrite function is a function in the opencv library, and the application can store the target photo in various formats such as jpg, Jpeg, and the like.
The embodiment of the invention also provides a device for repairing the JPEG photo, which is used for executing any embodiment of the repairing method of the JPEG photo. Specifically, referring to fig. 7, fig. 7 is a schematic block diagram of a JPEG photo restoration apparatus according to an embodiment of the present invention.
As shown in fig. 7, the JPEG photograph restoration apparatus 500 includes:
a super-segmentation unit 501, configured to extract thumbnails of JPEG photos, and perform super-segmentation processing on the thumbnails to obtain super-segmentation maps;
a filling unit 502, configured to read an original image of the JPEG photo, fill missing pixels in the original image, and make the pixel value of each missing pixel point be 128;
a searching unit 503, configured to obtain an initial mask of the filled original image, find and record a damage target region with a largest area in the initial mask, and set a pixel value of each pixel in the initial mask to 0;
an updating unit 504, configured to fill, based on the recorded damage target region, a corresponding position of the initial mask after being set to 0, so that a pixel value of each pixel point of the damage target region is updated to 255, and a target mask is obtained;
a first conversion unit 505, configured to perform pixel value conversion on all pixel points with a pixel value of 0 and a 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, so as to obtain a matching mask;
a second converting unit 506, configured to update pixel values of all pixel points in a region, where the pixel value in the target mask is 255, of the original graph to 0, and update pixel values of all pixel points in a region, where the pixel value in the matching mask is 255, of the hyper-resolution graph to 0;
and an output unit 507, configured to perform matrix addition on the updated hyper-map and the original map, and output a target photo.
The target photo obtained by the device can acquire and display effective information as comprehensive as possible by utilizing the reserved data to the maximum extent, and the details of the photo are far superior to those of a super-resolution map.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The JPEG photo restoration apparatus described above may be implemented in the form of a computer program that can 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 an independent server or a server cluster including a plurality of servers.
Referring to fig. 8, the computer device 1100 includes a processor 1102, memory and network interface 1105 connected by a system bus 1101, where the memory may include non-volatile storage media 1103 and 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, may cause the processor 1102 to perform a method of repairing JPEG photos.
The processor 1102 is configured to provide computing and control capabilities that support the operation of the overall computing device 1100.
The internal memory 1104 provides an environment for running the computer program 11032 in the nonvolatile storage medium 1103, and when the computer program 11032 is executed by the processor 1102, the processor 1102 may be caused to execute a JPEG photograph restoration method.
The network interface 1105 is used for network communications, such as to provide for the transmission of data information. Those skilled in the art will appreciate that the configuration shown in fig. 8 is a block diagram of only a portion of the configuration associated with aspects of the present invention and is not intended to limit the computing device 1100 to which aspects of the present invention may be applied, and that a particular computing device 1100 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
Those skilled in the art will appreciate that the embodiment of a computer device illustrated in fig. 8 does not constitute a limitation on the specific construction of the computer device, and that in other embodiments a computer device may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. For example, in some embodiments, the computer device may only include a memory and a processor, and in such embodiments, the structures and functions of the memory and the processor are consistent with those of the embodiment shown in fig. 8, and are not described herein again.
It should be appreciated that in embodiments of the present invention, the Processor 1102 may be a Central Processing Unit (CPU), and the Processor 1102 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. Wherein a 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 photo according to an embodiment of the present invention.
The storage medium is an entity and non-transitory storage medium, and may be various entity storage media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, devices and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A JPEG photo restoration method is characterized by comprising the following steps:
extracting thumbnails of JPEG pictures, and carrying out super-resolution processing on the thumbnails to obtain super-resolution pictures;
reading an original image of the JPEG photo, and filling lost pixels in the original image to enable the pixel value filling of each lost pixel point to be 128;
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 be 0;
filling corresponding positions of the initial mask after 0 is arranged on the basis of 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 pixel values of 0 and 255 in the target mask to convert the pixel points with the pixel values of 0 into the pixel points with the pixel values of 255, and converting the pixel points with the pixel values of 255 into the pixel points with the pixel values of 0 to obtain a matching mask;
updating the pixel values of all pixel points in the region of the original graph corresponding to the pixel value of 255 in the target mask to be 0, and updating the pixel values of all pixel points in the region of the hyper-map corresponding to the pixel value of 255 in the matching mask to be 0;
and performing matrix addition on the updated super-resolution image and the original image, and outputting a target photo.
2. The method for repairing a JPEG photo in accordance with claim 1, wherein the reading of the original image, and the filling of the missing pixels in the original image, so that the pixel value of each missing pixel is 128, comprises:
reading an original graph by utilizing an imread function;
filling missing pixels in the original graph with an imread function.
3. The method for repairing a JPEG photo according to claim 1, wherein the step of obtaining the filled initial mask of the original image, searching and recording the damage target region with the largest area in the initial mask, and before setting the pixel value of each pixel point in the initial mask to 0, includes:
utilizing a pyrDOWN function to carry out downsampling on the original graph, so that the size of the original graph reaches a preset threshold value;
resizing the downsampled original graph to make the original graph and the super graph have the same size;
the original map is converted to HSV color space using the cvtColor function.
4. The method for repairing a JPEG photo according to any one of claims 1 to 3, wherein the step of obtaining the filled initial mask of the original image, and searching and recording a damage target area with a largest area in the initial mask comprises:
acquiring an initial mask of the original image by using an inRange function;
searching all gray regions of the initial mask by using a findContours function;
calculating the area of each gray area by using a contourArea function;
and comparing and judging the area of each gray area, finding out the gray area with the largest area, and taking the gray area as a damage target area.
5. The method for repairing a JPEG photo in accordance with claim 1, wherein the filling of the corresponding position of the initial mask after 0 is performed to update the pixel value of each pixel point of the damage target region to 255 includes:
and filling the corresponding position of the initial mask by using a drawContours function, and updating the pixel value of each pixel point of the damage target area to be 255.
6. The method for restoring a JPEG still according to claim 1, wherein the step of filling the corresponding position of the initial mask after the setting of 0 based on the recorded damage target region to update the pixel value of each pixel point of the damage target region to 255, and after obtaining the target mask, comprises:
and performing boundary line correction processing on the target mask by using a dilate function.
7. The method for repairing a JPEG photo in accordance with claim 1, wherein the pixel value conversion is performed on all the pixel points with pixel values of 0 and 255 in the target mask, so as to convert the pixel point with pixel value of 0 into the pixel point with pixel value of 255, and convert the pixel point with pixel value of 255 into the pixel point with pixel value of 0, so as to obtain the matching mask, comprising:
and performing pixel value conversion on all pixel points with pixel values of 0 and 255 in the target mask by using a complementary function or a bitwise _ not function, so that the pixel points with the pixel values of 0 are converted into the pixel points with the pixel values of 255, and the pixel points with the pixel values of 255 are converted into the pixel points with the pixel values of 0 to obtain a matching mask.
8. A JPEG photograph restoration apparatus, comprising:
the super-dividing unit is used for extracting thumbnails of JPEG pictures and carrying out super-dividing processing on the thumbnails to obtain super-divided pictures;
the filling unit is used for reading the original image of the JPEG photo and filling lost pixels in the original image to enable the pixel value of each lost pixel point to be 128;
the searching unit is used for acquiring the filled initial mask of the 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 be 0;
the updating unit is used for filling corresponding positions of the initial mask after 0 is arranged on the basis of the recorded damage target area, so that the pixel value of each pixel point of the damage target area is updated to be 255, and a target mask is obtained;
the first conversion unit is used for performing pixel value conversion on all pixel points with pixel values of 0 and 255 in the target mask to convert the pixel points with the pixel values of 0 into the pixel points with the pixel values of 255, and convert the pixel points with the pixel values of 255 into the pixel points with the pixel values of 0 to obtain a matching mask;
a second conversion unit, configured to update pixel values of all pixel points in a region, where the pixel value in the target mask is 255, of the original graph to 0, and update pixel values of all pixel points in a region, where the pixel value in the matching mask is 255, of the hyper-resolution graph to 0;
and the output unit is used for performing matrix addition on the updated super-resolution image and the original image and outputting the target photo.
9. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of repairing a JPEG photograph in accordance with any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that a computer program is stored which, when executed by a processor, causes the processor to execute the method of repairing a JPEG photograph as claimed in any one of claims 1 to 7.
CN202111638119.8A 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 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 JPEG photo restoration method and device and related components

Publications (2)

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

Family

ID=

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
詹琦梁;陈胜勇;胡海根;李小薪;周乾伟;: "一种结合多种图像分割算法的实例分割方案", 小型微型计算机系统, no. 04, 9 April 2020 (2020-04-09) *

Similar Documents

Publication Publication Date Title
CN107967669B (en) Picture processing method and device, computer equipment and storage medium
US10410397B2 (en) Picture presentation method and apparatus
EP2209090B1 (en) Image restoring apparatus and method thereof
CN110728722B (en) Image color migration method and device, computer equipment and storage medium
CN112602088B (en) Method, system and computer readable medium for improving quality of low light images
CN111275034B (en) Method, device, equipment and storage medium for extracting text region from image
US9300840B2 (en) Image processing device and computer-readable storage medium storing computer-readable instructions
CN109389659B (en) Rendering method and device of mathematical formula in PPT, storage medium and terminal equipment
KR20140128226A (en) Image processing apparatus, image processing method, image processing control porgram and recording medium
CN112073718B (en) Television screen splash detection method and device, computer equipment and storage medium
US10123052B2 (en) Elimination of artifacts from lossy encoding of digital images by color channel expansion
US10963988B2 (en) Image processing device, image processing system, image processing method, and program
CN113012031A (en) Image processing method and image processing apparatus
CN114298937B (en) JPEG photo restoration method and device and related components
CN114298937A (en) JPEG photo repairing method, device and related components
CN116485944A (en) Image processing method and device, computer readable storage medium and electronic equipment
WO2022247702A1 (en) Image processing method and apparatus, electronic device, and storage medium
Zheng et al. Joint residual pyramid for joint image super-resolution
CN112487943B (en) Key frame de-duplication method and device and electronic equipment
WO2021164329A1 (en) Image processing method and apparatus, and communication device and readable storage medium
CN113793264A (en) Archive image processing method and system based on convolution model and electronic equipment
CN113724269A (en) Example segmentation method, training method of example segmentation network and related equipment
US8254711B2 (en) System and method for processing digital noise in a digital image
CN111161174A (en) Blood vessel model establishing method and device, computer equipment and storage medium
CN113658084B (en) Image processing method, image processing apparatus, storage medium, and electronic device

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