CN109886886B - Image restoration method and device - Google Patents

Image restoration method and device Download PDF

Info

Publication number
CN109886886B
CN109886886B CN201910065220.5A CN201910065220A CN109886886B CN 109886886 B CN109886886 B CN 109886886B CN 201910065220 A CN201910065220 A CN 201910065220A CN 109886886 B CN109886886 B CN 109886886B
Authority
CN
China
Prior art keywords
pixel
image
restored
target
coordinates
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
CN201910065220.5A
Other languages
Chinese (zh)
Other versions
CN109886886A (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 Dapu Microelectronics Co Ltd
Original Assignee
Shenzhen Dapu Microelectronics 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 Dapu Microelectronics Co Ltd filed Critical Shenzhen Dapu Microelectronics Co Ltd
Priority to CN201910065220.5A priority Critical patent/CN109886886B/en
Publication of CN109886886A publication Critical patent/CN109886886A/en
Application granted granted Critical
Publication of CN109886886B publication Critical patent/CN109886886B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Processing (AREA)
  • Editing Of Facsimile Originals (AREA)

Abstract

The invention provides an image restoration method, which comprises the following steps: acquiring coordinates and pixel values of each pixel point in an image to be restored; determining the amplification ratio of the image to be restored by calculating by utilizing the coordinates and the pixel values of each pixel point, and searching all target pixel points inserted according to the amplification ratio; and deleting all target pixel points in the image to be restored. The invention also provides an image restoration device. The invention determines the amplification proportion of the image by searching the pixel points inserted through the amplification treatment and deletes the pixel points inserted through the amplification treatment, thereby restoring the image amplified by adopting the bilinear interpolation method, avoiding color distortion and reducing the occupied space of the image.

Description

Image restoration method and device
[ field of technology ]
The invention belongs to the technical field of image processing, and particularly relates to an image restoration method and device.
[ background Art ]
At present, a bilinear interpolation method is generally adopted to amplify an image, and the method comprises the following two steps: the image is subjected to space coordinate transformation and gray level interpolation. The space occupied by the amplified image is often several times that of the original image, the memory device is required to occupy a larger capacity, and the image is usually required to be restored so as to be convenient for a user to store the original image. In view of the foregoing, it is desirable to provide an image restoration method and apparatus for overcoming the above-mentioned drawbacks.
[ invention ]
The invention provides an image restoration method and device, which restore an image amplified by adopting a bilinear interpolation method, avoid color distortion and reduce the occupied space of the image.
In order to achieve the above object, the present invention provides an image restoration method, comprising the steps of:
acquiring coordinates and pixel values of each pixel point in an image to be restored;
determining the amplification ratio of the image to be restored by calculating by utilizing the coordinates and the pixel values of each pixel point, and searching all target pixel points inserted according to the amplification ratio;
and deleting all target pixel points in the image to be restored.
In a preferred embodiment, the step of determining the magnification ratio of the image to be restored by calculation using the coordinates and the pixel values of each pixel point and searching for all target pixel points inserted according to the magnification ratio includes:
searching target coordinates of pixel points inserted according to a preset amplification ratio in the X direction and the Y direction of the image to be restored respectively, and calculating pixel calculated values corresponding to the target coordinates;
judging whether the pixel values of the target pixel points corresponding to all the target coordinates in the image to be restored are consistent with the pixel calculated values;
and when the pixel values of all the target pixel points are consistent with the pixel calculated values, determining that the image to be restored is amplified by the preset amplification proportion.
In a preferred embodiment, when it is determined that the pixel value of any target pixel point is inconsistent with the pixel calculated value, the preset magnification ratio is changed, and the steps of searching for the target coordinates of the pixel point inserted according to the preset magnification ratio in the X direction and the Y direction of the image to be restored, and calculating the pixel calculated value corresponding to the target coordinates are re-performed.
In a preferred embodiment, the pixel values and pixel calculation values are each composed of components of R, G, and B channels; the step of obtaining the coordinates and the pixel values of each pixel point in the image to be restored comprises the following steps: and acquiring the coordinates of each pixel point in the image to be restored and the components of pixel values in an R channel, a G channel and a B channel.
In a preferred embodiment, the step of determining whether the pixel values of the pixel points corresponding to all the target coordinates in the image to be restored are consistent with the calculated pixel values specifically includes: and sequentially judging whether the components of the pixel values of the target pixel points corresponding to all the target coordinates in the R channel, the G channel and the B channel are consistent with the components of the pixel calculated values in the R channel, the G channel and the B channel.
In a preferred embodiment, the preset magnification ratio is n times of the original image magnified according to a bilinear interpolation algorithm, wherein n is a positive integer and n is equal to or greater than 2.
In a preferred embodiment, the step of searching for the target coordinates of the pixel points inserted according to the preset magnification ratio in the X direction and the Y direction of the image to be restored, and calculating the pixel calculation value corresponding to the target coordinates includes:
respectively starting from a first pixel point in the X direction and the Y direction of the image to be restored, traversing and searching coordinates of the pixel points from the original image at each interval of n-1 pixel points to obtain target coordinates which are inserted into the pixel points according to a preset amplification ratio;
and calculating a pixel calculation value corresponding to the target coordinate by utilizing a bilinear interpolation algorithm according to the coordinate and the pixel value of the pixel point from the original image and the target coordinate of the pixel point inserted according to the preset amplification ratio.
In a preferred embodiment, before the step of searching the target coordinates of the pixel points inserted according to the preset magnification ratio in the X direction and the Y direction of the image to be restored, and calculating the pixel calculation value corresponding to the target coordinates, the method further includes: setting a preset magnification ratio, and sequentially executing the method according to the magnification ratio which is 2 times to n times of the original image.
In order to achieve the above object, the present invention further provides an image restoration device, including a processor, a memory, and an image restoration program stored in the memory and executable on the processor; the processor implements the image restoration method described above when executing the image restoration program.
Compared with the prior art, the invention has the beneficial effects that: the amplification proportion of the image is determined by searching the pixel points inserted through amplification processing, and the pixel points inserted through amplification processing are deleted, so that the image amplified by adopting the bilinear interpolation method is restored, color distortion is avoided, the utilization rate of the amplified image is improved, and the occupied space of the image is reduced.
[ description of the drawings ]
FIG. 1 is a flowchart of an image restoration method according to a preferred embodiment of the present invention;
FIG. 2 is a schematic flow chart of step S102 in the image restoration method shown in FIG. 1;
FIG. 3 is a schematic flow chart of step S201 in the image restoration method shown in FIG. 2;
FIG. 4 is a schematic diagram of an area in an image to be restored, at an enlarged scale of 2 times the original image;
fig. 5 is a schematic diagram of an area in an image to be restored, which is enlarged 3 times as large as an original image.
[ detailed description ] of the invention
In order to make the objects, technical solutions and advantageous technical effects of the present invention more apparent, the present invention will be further described in detail with reference to the accompanying drawings and detailed description. It should be understood that the detailed description is intended to illustrate the invention, and not to limit the invention.
Referring to fig. 1, the present invention provides an image restoration method for restoring an image amplified by a bilinear interpolation method, which specifically includes the following steps:
step S101, coordinates and pixel values of all pixel points in the image to be restored are obtained.
In step S101, an image coordinate system is established, generally, the upper left corner pixel point of the image to be restored is taken as the origin of coordinates, the right corner pixel point is taken as the positive direction of the X axis, the downward corner pixel point is taken as the positive direction of the Y axis, the unit is a pixel, and the coordinates of each pixel point in the image to be restored, namely, the numerical values in the X axis and the Y axis, respectively represent the column number and the row number of the pixel point in the image to be restored, so as to facilitate storage. The pixel value of the pixel point is composed of components of an R channel, a G channel, and a B channel, and step S101 specifically includes: and acquiring the coordinates of each pixel point in the image to be restored and the components of pixel values in an R channel, a G channel and a B channel.
Step S102, the coordinate and the pixel value of each pixel point are utilized to determine the amplification ratio of the image to be restored through calculation, and all target pixel points inserted according to the amplification ratio are searched.
Referring to fig. 2, step S102 further includes the following sub-steps:
in step S201, target coordinates of the pixel points inserted according to the preset magnification ratio are searched in the X direction and the Y direction of the image to be restored, and a pixel calculation value corresponding to the target coordinates is calculated.
In step S201, the preset amplification ratio is n times of the original image amplified according to the bilinear interpolation algorithm, where n is a positive integer and n is greater than or equal to 2, and the preset amplification ratio may be set according to specific needs of the user, for example, the user only needs to restore the image to be restored amplified by 2 times, n may be set to 2, and when the user is uncertain, n may be set to a maximum value. In this embodiment, before step S201, the method further includes: setting a preset magnification ratio, and sequentially executing the method according to the magnification ratio which is 2 times to n times of the original image.
Referring to fig. 3, step S201 specifically includes:
in step S301, coordinates of pixel points from the original image are searched by traversing every n-1 pixel points from the first pixel point in the X direction and the Y direction of the image to be restored, so as to obtain target coordinates of the pixel points inserted according to a preset amplification ratio.
In step S301, according to the bilinear interpolation algorithm principle, the pixel value of the pixel point inserted through the amplification processing is calculated by weighted average from the values of 4 adjacent pixels in the 2X 2 area in the original image, when the pixel point is amplified to n times of the original image, the coordinate positions of the pixel point in the original image are transformed into the coordinate positions where n-1 pixel points are located at intervals from the first pixel point in the X direction and the Y direction of the image to be restored, and the rest pixel points in the image to be restored are the pixel points inserted according to the preset amplification ratio.
Referring to fig. 4, taking the case of amplifying to 2 times of the original image according to the bilinear interpolation algorithm as an example of the preset amplification ratio, 1 pixel point at each interval is traversed and searched for the coordinates of the pixels from the original image from the first pixel point in the X direction and the Y direction of the image to be restored, namely, the pixels Q13, Q33, Q11 and Q31 are the pixels from the original image, and the pixels Q23, Q12, Q22, Q32 and Q21 are the pixels inserted by amplifying to 2 times of the original image according to the bilinear interpolation algorithm; that is, the target coordinates into which the pixel points are inserted at a preset magnification ratio can be obtained by looking up the coordinates of the pixel points from the original image.
Step S302, calculating a pixel calculation value corresponding to the target coordinate by utilizing a bilinear interpolation algorithm according to the coordinate and the pixel value of the pixel point from the original image and the target coordinate of the pixel point inserted according to the preset amplification ratio.
In step S302, the pixel calculation value corresponding to the target coordinate is calculated by using the bilinear interpolation algorithm, and the pixel value of the pixel point inserted in the X direction is calculated first, and then the pixel value of the pixel point inserted in the Y direction is calculated. As shown in fig. 4, if the pixel values (exemplified by the R channel components) of the pixel points Q11, Q31, Q13, Q33 are R11, R31, R13, R33, respectively, the pixel calculation value of the pixel point Q23 is (r13+r33)/2, the pixel calculation value of the pixel point Q12 is (r13+r11)/2, the pixel calculation value of the pixel point Q22 is (r23+r21)/2, the pixel calculation value of the pixel point Q32 is (r33+r31)/2, and the pixel calculation value of the pixel point Q21 is (r11+r31)/2.
Referring further to fig. 5, taking the case of enlarging the original image by 3 times according to the bilinear interpolation algorithm as an example of the preset enlargement ratio, the coordinates of the pixels from the original image are searched for every 2 pixels from the first pixel in the X direction and the Y direction of the image to be restored, i.e. the pixels Q14, Q44, Q11, Q41 are the pixels from the original image, and the pixels Q24, Q34, Q13, Q23, Q33, Q43, Q12, Q22, Q32, Q42, Q21, Q31 are the pixels inserted by enlarging the original image by 3 times according to the bilinear interpolation algorithm. If the pixel values (taking the R channel component as an example) of the pixel points Q14, Q44, Q11 and Q41 are R14, R44, R11 and R41 respectively, the pixel calculated value of the pixel point Q24 is R14 x 2/3+r44x1/3, the pixel calculated value of the pixel point Q34 is R14 x 1/3+r44x2/3, the pixel calculated value of the pixel point Q13 is R14 x 2/3+r1x1/3, and the pixel calculated values corresponding to all the target coordinates can be obtained according to the bilinear interpolation algorithm principle by analogy.
Step S202, judging whether the pixel values of the target pixel points corresponding to all the target coordinates in the image to be restored are consistent with the pixel calculated values.
In step S202, if the target pixel corresponding to the target coordinate is a pixel inserted according to the preset magnification ratio, the pixel value obtained from the image to be restored should be consistent with the pixel calculated value. In one embodiment, the step S202 specifically includes: and sequentially judging whether the components of the pixel values of the target pixel points corresponding to all the target coordinates in the R channel, the G channel and the B channel are consistent with the components of the pixel calculated values in the R channel, the G channel and the B channel. As shown in fig. 4, if the image to be restored is enlarged to 2 times of the original image according to the bilinear interpolation algorithm, the pixel points Q23, Q12, Q22, Q32, Q21 are target pixel points, and the pixel values thereof should be consistent with the pixel calculation values. For example, in this embodiment, the components of the R channel, the G channel, and the B channel are all represented by 8 bits, that is, the value range is 0-255, the known pixel points Q11, Q31, Q13, Q33 are 20, 45, 100, and 40, the pixel calculated values of the available pixel points Q23, Q12, Q22, Q32, and Q21 are 70, 60, 51, 42, and 32 calculated in step S302, and the pixel values of the target pixel points corresponding to all the target coordinates are compared, and if they are consistent, it can be determined that the target pixel point is the pixel point inserted by 2 times the original image according to the magnification ratio; if the target pixel points are inconsistent, the target pixel points are not the pixel points which are inserted according to the magnification ratio which is 2 times of the original image.
In step S203, when it is determined that the pixel values of all the target pixel points are consistent with the pixel calculation values, it is determined that the image to be restored is amplified by the preset amplification ratio.
In step S203, when it is determined that the pixel values of all the target pixel points are equal to the pixel calculated values, it may be determined that the target pixel points are the pixel points inserted according to the preset magnification ratio, that is, it is determined that the image to be restored is magnified by the preset magnification ratio.
Further, step S102 further includes: in step S204, when it is determined that the pixel value of any target pixel point is inconsistent with the pixel calculated value, the preset amplification ratio is changed, and step S201 is re-executed.
In step S204, when it is determined that the pixel value of any target pixel point is inconsistent with the pixel calculated value, it may be determined that the target pixel point is not inserted according to the preset magnification ratio, that is, it is determined that the image to be restored is not magnified by the preset magnification ratio, and the judgment is performed by recalculating the preset magnification ratio.
In this embodiment, before step S201, the method further includes: setting a preset magnification ratio, and sequentially executing the method according to the preset magnification ratio which is 2 times to n times of the original image. The method of the embodiment of the invention sequentially determines the amplification ratio from 2 times to n times of the original image until the amplification ratio is maximum.
And step S103, deleting all target pixel points in the image to be restored.
In step S103, the target pixel is the pixel inserted through the amplifying process, and the original image is obtained after deleting. For example, when the resolution of the image to be restored is 720x480, determining that the image to be restored is an image which is amplified twice as much as the original image, deleting all target pixel points to obtain the original image with the resolution of 360x 240; when the resolution of the image to be restored is 1080x720 and the image to be restored is determined to be an image which is three times amplified as the original image, deleting all target pixel points to obtain the original image with the resolution of 360x 240.
According to the image restoration method provided by the embodiment of the invention, the amplification proportion of the image is determined by searching the pixel points inserted through the amplification treatment, and the pixel points inserted through the amplification treatment are deleted, so that the image amplified by the bilinear interpolation method is restored, the color distortion is avoided, the utilization rate of the amplified image is improved, and the occupied space of the image is reduced.
Based on the above method embodiment, the present invention further provides an image restoration device, which includes a processor, a memory, and an image restoration program stored in the memory and executable on the processor. The image restoration method of the embodiment of the invention is realized when the processor executes the image restoration program.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be implemented by a program to instruct related hardware, the program may be stored in a computer readable storage medium, and the storage medium may include: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
The foregoing is merely a preferred embodiment of the invention, which has been described in further detail in connection with specific preferred embodiments thereof, and it is not intended that the invention be limited to these embodiments. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (7)

1. An image restoration method, characterized by comprising the steps of:
acquiring coordinates and pixel values of each pixel point in an image to be restored;
determining the amplification ratio of the image to be restored by calculating by utilizing the coordinates and the pixel values of each pixel point, and searching all target pixel points inserted according to the amplification ratio;
deleting all target pixel points in the image to be restored;
the step of determining the amplification ratio of the image to be restored by calculating by using the coordinates and the pixel values of each pixel point and searching all target pixel points inserted according to the amplification ratio comprises the following steps:
searching target coordinates of pixel points inserted according to a preset amplification ratio in the X direction and the Y direction of the image to be restored respectively, and calculating pixel calculated values corresponding to the target coordinates;
judging whether the pixel values of the target pixel points corresponding to all the target coordinates in the image to be restored are consistent with the pixel calculated values;
when the pixel values of all the target pixel points are consistent with the pixel calculated values, determining that the image to be restored is amplified by the preset amplification proportion; and when judging that the pixel value of any target pixel point is inconsistent with the pixel calculated value, changing the preset amplification ratio, and re-executing the steps of searching the target coordinates of the pixel point inserted according to the preset amplification ratio in the X direction and the Y direction of the image to be restored respectively, and calculating the pixel calculated value corresponding to the target coordinates.
2. The image restoration method according to claim 1, wherein the pixel value and the pixel calculation value are each composed of components of an R channel, a G channel, and a B channel; the step of obtaining the coordinates and the pixel values of each pixel point in the image to be restored comprises the following steps: and acquiring the coordinates of each pixel point in the image to be restored and the components of pixel values in an R channel, a G channel and a B channel.
3. The image restoration method as set forth in claim 2, wherein the step of determining whether the pixel values of the pixel points corresponding to all the target coordinates in the image to be restored are consistent with the pixel calculation values specifically includes: and sequentially judging whether the components of the pixel values of the target pixel points corresponding to all the target coordinates in the R channel, the G channel and the B channel are consistent with the components of the pixel calculated values in the R channel, the G channel and the B channel.
4. The image restoration method according to claim 1, wherein the preset magnification ratio is n times as large as the original image according to a bilinear interpolation algorithm, where n is a positive integer and n is not less than 2.
5. The image restoration method as set forth in claim 4, wherein the steps of searching for target coordinates of the pixel points inserted according to a preset magnification ratio in the X-direction and the Y-direction of the image to be restored, respectively, and calculating pixel calculation values corresponding to the target coordinates, include:
respectively starting from a first pixel point in the X direction and the Y direction of the image to be restored, traversing and searching coordinates of the pixel points from the original image at each interval of n-1 pixel points to obtain target coordinates which are inserted into the pixel points according to a preset amplification ratio;
and calculating a pixel calculation value corresponding to the target coordinate by utilizing a bilinear interpolation algorithm according to the coordinate and the pixel value of the pixel point from the original image and the target coordinate of the pixel point inserted according to the preset amplification ratio.
6. The image restoration method according to claim 5, wherein before the step of searching for target coordinates of the pixel points inserted according to a preset magnification ratio in the X-direction and the Y-direction of the image to be restored, and calculating a pixel calculation value corresponding to the target coordinates, respectively, further comprising: setting a preset magnification ratio, and sequentially executing the method according to the magnification ratio which is 2 times to n times of the original image.
7. An image restoration device is characterized by comprising a processor, a memory and an image restoration program which is stored in the memory and can run on the processor; the processor, when executing the image restoration program, implements the image restoration method as defined in any one of claims 1 to 6.
CN201910065220.5A 2019-01-23 2019-01-23 Image restoration method and device Active CN109886886B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910065220.5A CN109886886B (en) 2019-01-23 2019-01-23 Image restoration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910065220.5A CN109886886B (en) 2019-01-23 2019-01-23 Image restoration method and device

Publications (2)

Publication Number Publication Date
CN109886886A CN109886886A (en) 2019-06-14
CN109886886B true CN109886886B (en) 2023-05-23

Family

ID=66926662

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910065220.5A Active CN109886886B (en) 2019-01-23 2019-01-23 Image restoration method and device

Country Status (1)

Country Link
CN (1) CN109886886B (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2371459B (en) * 2001-01-19 2005-05-04 Pixelfusion Ltd Image scaling
US20070058179A1 (en) * 2005-09-15 2007-03-15 Fujitsu Limited Image processing apparatus and method for image resizing matching data supply speed
JP2009278655A (en) * 2009-08-19 2009-11-26 Fujifilm Corp Image processing apparatus, image processing method, and digital camera
JP5633616B2 (en) * 2013-09-13 2014-12-03 株式会社リコー Image forming apparatus and image forming method
CN108986033A (en) * 2018-07-26 2018-12-11 西安电子科技大学 Image-scaling method based on bilinear interpolation algorithm processing

Also Published As

Publication number Publication date
CN109886886A (en) 2019-06-14

Similar Documents

Publication Publication Date Title
US8265422B1 (en) Method and apparatus for removing general lens distortion from images
CN106204441B (en) Image local amplification method and device
CN102289786B (en) Edge anti-aliasing method and device for image scaling
Woods et al. Boundary value problem in image restoration
CN110866862B (en) Data processing method and device based on buffer, storage medium and electronic equipment
CN111223061A (en) Image correction method, correction device, terminal device and readable storage medium
US10395337B2 (en) Image processing apparatus, image processing method, and storage medium
CN109886886B (en) Image restoration method and device
JP2010212782A (en) Image sharpening device and image sharpening method
CN111429458A (en) Image restoration method and device and electronic equipment
CN110738615B (en) Fisheye image correction method, device, system and storage medium
CN111105356B (en) Image processing method, device and computer readable storage medium
CN117710235B (en) Image target enhancement method, device, computer equipment and storage medium
WO2020258287A1 (en) Image correction method, image correction apparatus, and electronic device
CN109698977B (en) Video image restoration method and device
JP6116271B2 (en) Feature amount calculation apparatus, method, and program
CN110956589A (en) Image blurring processing method, device, equipment and storage medium
CN117011146B (en) Image scaling method and device, electronic equipment and storage medium
JP2001166754A (en) Display system
JP4194889B2 (en) Image processing device
CN104978712A (en) Image processing method and device
CN116527908B (en) Motion field estimation method, motion field estimation device, computer device and storage medium
CN117437126B (en) Image conversion method, computer device, and computer-readable storage medium
CN111858824B (en) Terrain data fusion method, device, computer equipment and storage medium
CN111626935B (en) Pixel map scaling method, game content generation method and 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
GR01 Patent grant
GR01 Patent grant