WO2020001222A1 - 图像处理方法、装置、计算机可读介质及电子设备 - Google Patents

图像处理方法、装置、计算机可读介质及电子设备 Download PDF

Info

Publication number
WO2020001222A1
WO2020001222A1 PCT/CN2019/088973 CN2019088973W WO2020001222A1 WO 2020001222 A1 WO2020001222 A1 WO 2020001222A1 CN 2019088973 W CN2019088973 W CN 2019088973W WO 2020001222 A1 WO2020001222 A1 WO 2020001222A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
gradient
target
processed
target image
Prior art date
Application number
PCT/CN2019/088973
Other languages
English (en)
French (fr)
Inventor
杨扬
马文晔
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Priority to EP19824450.1A priority Critical patent/EP3817361A4/en
Publication of WO2020001222A1 publication Critical patent/WO2020001222A1/zh
Priority to US16/921,813 priority patent/US11348207B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/73Deblurring; Sharpening
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/77Retouching; Inpainting; Scratch removal
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/10Image enhancement or restoration using non-spatial domain filtering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • H04N23/81Camera processing pipelines; Components thereof for suppressing or minimising disturbance in the image signal generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20048Transform domain processing
    • G06T2207/20052Discrete cosine transform [DCT]

Definitions

  • Embodiments of the present application relate to the field of computer technology, and in particular, to an image processing method, apparatus, computer-readable medium, and electronic device.
  • the purpose of the embodiments of the present application is to provide an image processing method, an apparatus, a computer-readable medium, and an electronic device, so as to at least to some extent overcome the problem that the reflection ghost in the image cannot be effectively removed.
  • an image processing method including: acquiring a to-be-processed image including a reflection ghost; calculating an image gradient of the to-be-processed image; and determining the to-be-processed according to the image gradient The gradient of the target image after the reflection ghost is removed from the image; and the target image is generated based on the gradient of the target image.
  • an image processing apparatus including: an obtaining unit for obtaining a to-be-processed image including a reflection ghost; a gradient calculation unit for calculating an image gradient of the to-be-processed image A first processing unit configured to determine a gradient of a target image after removing the reflection ghost from the image to be processed according to the image gradient; a second processing unit configured to generate the target image based on the gradient of the target image The target image.
  • a computer-readable medium on which a computer program is stored, and when the computer program is executed by a processor, the image processing method as described in the foregoing embodiment is implemented.
  • an electronic device including: one or more processors; a storage device for storing one or more programs, and when the one or more programs are replaced by the one or more programs, When executed by multiple processors, the one or more processors are caused to implement the image processing method as described in the foregoing embodiment.
  • the image gradient of the image to be processed is calculated, and the gradient of the target image after the reflection ghost is removed from the image to be processed is determined based on the image gradient of the image to be processed, based on the
  • the target image gradient is used to generate the target image, so that the reflection ghost portion in the to-be-processed image can be filtered by calculating the image gradient of the to-be-processed image, and then the target image is generated based on the gradient of the obtained target image, avoiding the need in related technologies.
  • FIG. 1 shows a schematic diagram of an exemplary system architecture to which an image processing method or an image processing apparatus of an embodiment of the present application can be applied;
  • FIG. 2 is a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application
  • FIG. 3 schematically illustrates a flowchart of an image processing method according to an embodiment of the present application
  • FIG. 4 schematically illustrates a flowchart of generating a target image based on a gradient of the target image according to an embodiment of the present application
  • FIG. 5 schematically illustrates a flowchart of constructing an optimization function according to an embodiment of the present application
  • FIG. 6 schematically illustrates a flowchart of solving an optimization model according to an embodiment of the present application
  • FIG. 7 schematically illustrates a flowchart of generating a target image based on an optimal solution corresponding to a target variable according to an embodiment of the present application
  • FIG. 8 is a schematic diagram of an imaging process when taking a picture according to an embodiment of the present application.
  • FIG. 9 is a schematic diagram showing a comparison effect before and after processing an image including reflection ghosts according to an embodiment of the present application.
  • FIG. 10 is a schematic diagram showing a comparison effect before and after processing an image including reflection ghosts according to an embodiment of the present application.
  • FIG. 11 is a schematic diagram showing a comparison effect before and after processing an image including reflection ghosts according to an embodiment of the present application.
  • FIG. 12 schematically illustrates a block diagram of an image processing apparatus according to an embodiment of the present application.
  • FIG. 13 schematically illustrates a block diagram of a first processing unit according to an embodiment of the present application
  • FIG. 14 schematically illustrates a block diagram of a second processing unit according to an embodiment of the present application.
  • FIG. 1 shows a schematic diagram of an exemplary system architecture 100 to which an image processing method or an image processing apparatus of an embodiment of the present application can be applied.
  • the system architecture 100 may include one or more of terminal devices 101, 102, and 103, a network 104, and a server 105.
  • the network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105.
  • the network 104 may include various connection types, such as a wired communication link, a wireless communication link, and the like.
  • the numbers of terminal devices, networks, and servers in FIG. 1 are merely exemplary. Depending on the implementation needs, there can be any number of terminal devices, networks, and servers.
  • the server 105 may be a server cluster composed of multiple servers.
  • the user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and the like.
  • the terminal devices 101, 102, 103 may be various electronic devices with a display screen, including but not limited to smart phones, tablet computers, portable computers, desktop computers, and so on.
  • the server 105 may be a server that provides various services.
  • the user uploads a to-be-processed image including reflection ghosts to the server 105 by using the terminal device 103 (may also be the terminal device 101 or 102).
  • the server 105 may calculate the image gradient of the to-be-processed image, and then determine the gradient of the target image after the reflection ghost is removed from the to-be-processed image based on the image gradient, and then generate based on the gradient of the target image.
  • the target image may be a server that provides various services. For example, the user uploads a to-be-processed image including reflection ghosts to the server 105 by using the terminal device 103 (may also be the terminal device 101 or 102).
  • the server 105 may calculate the image gradient of the to-be-processed image, and then determine the gradient of the target image after the reflection ghost is removed from the to-be-processed image based on the image gradient, and then generate based on the gradient of the target image.
  • the image processing method provided by the embodiment of the present application is generally executed by the server 105, and accordingly, the image processing apparatus is generally disposed in the server 105.
  • the terminal may also have similar functions with the server, so as to execute the image processing solution provided in the embodiment of the present application. For example, after the terminal captures an image including reflection ghosts, The image is directly processed to obtain a clear image after removing the reflection ghost.
  • FIG. 2 is a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
  • the computer system 200 includes a central processing unit (CPU) 201 that can be loaded into a random access memory (RAM) 203 according to a program stored in a read-only memory (ROM) 202 or a program loaded from a storage section 208 Instead, perform various appropriate actions and processes.
  • RAM 203 various programs and data required for system operation are also stored.
  • the CPU 201, the ROM 202, and the RAM 203 are connected to each other through a bus 204.
  • An input / output (I / O) interface 205 is also connected to the bus 204.
  • the following components are connected to the I / O interface 205: an input portion 206 including a keyboard, a mouse, and the like; an output portion 207 including a cathode ray tube (CRT), a liquid crystal display (LCD), and the speaker; a storage portion 208 including a hard disk and the like; a communication section 209 including a network interface card such as a LAN card, a modem, and the like.
  • the communication section 209 performs communication processing via a network such as the Internet.
  • the driver 210 is also connected to the I / O interface 205 as needed.
  • a removable medium 211 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 210 as needed, so that a computer program read therefrom is installed into the storage section 208 as needed.
  • a process described below with reference to a flowchart may be implemented as a computer software program.
  • embodiments of the present application include a computer program product including a computer program carried on a computer-readable medium, the computer program containing program code for performing the method shown in the flowchart.
  • the computer program may be downloaded and installed from a network through the communication section 209, and / or installed from a removable medium 211.
  • this computer program is executed by a central processing unit (CPU) 201, various functions defined in the system of the present application are executed.
  • CPU central processing unit
  • the computer-readable medium shown in the embodiments of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the foregoing.
  • the computer-readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programming read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • the computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • the computer-readable signal medium may include a data signal propagated in baseband or transmitted as a part of a carrier wave, which carries a computer-readable program code. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device .
  • Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline and the like, or any suitable combination of the foregoing.
  • each block in the flowchart or block diagram may represent a module, program segment, or part of code, which contains one or more of the logic functions used to implement the specified logic. Executable instructions.
  • the functions labeled in the blocks may also occur in a different order than those labeled in the drawings. For example, two blocks represented one after the other may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram or flowchart, and combinations of blocks in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with A combination of dedicated hardware and computer instructions.
  • the units described in the embodiments of the present application may be implemented by software or hardware.
  • the described units may also be provided in a processor.
  • the names of these units do not, in some cases, define the unit itself.
  • the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device in.
  • the computer-readable medium carries one or more programs, and when the one or more programs are executed by one of the electronic devices, the electronic device is caused to implement a method as described in the following embodiments.
  • the electronic device can implement the steps shown in FIG. 3 to FIG. 7.
  • FIG. 3 schematically illustrates a flowchart of an image processing method according to an embodiment of the present application, and the image processing method is applicable to the electronic device described in the foregoing embodiment.
  • the image processing method includes at least steps S310 to S340, which are described in detail as follows:
  • step S310 an image to be processed including a reflection ghost is acquired.
  • the to-be-processed image may be obtained by a user through a terminal (such as a smartphone, a camera, a video camera, etc.).
  • a terminal such as a smartphone, a camera, a video camera, etc.
  • the picture may be taken due to the reflection of the glass Emission ghosting exists in the image.
  • step S320 an image gradient of the image to be processed is calculated.
  • the image when calculating the image gradient of the image to be processed, the image can be regarded as a two-dimensional discrete function, and calculating the gradient of the image is actually deriving the two-dimensional discrete function.
  • step S330 the gradient of the target image after the reflection ghost is removed from the image to be processed is determined according to the image gradient.
  • step S330 specifically includes: calculating a gradient modulus length of each pixel point in the image to be processed according to the image gradient; and based on a gradient modulus length of each pixel point in the image to be processed To determine the gradient value of each pixel point in the target image; and determine the gradient of the target image according to the gradient value of each pixel point in the target image.
  • the reflection ghost is usually more blurred and the color changes are smoother, so the gradient value of the target image is 0 on most pixels, and a few non-zero parts
  • the gradient mode length is relatively large, but the mode length of all pixels in the reflection ghost portion is relatively small, so the gradient value of each pixel point in the target image can be determined according to the gradient mode length of each pixel point in the image to be processed. .
  • the gradient modulus length of each pixel point in the image to be processed it is determined that the first type of pixels in the image to be processed whose gradient modulus length is less than the threshold of the modulus length and the gradient modulus length is greater than Or a second type of pixel point equal to the modulus length threshold; then setting the gradient value of the first type of pixel point to 0 to obtain an updated gradient value of the first type of pixel point; further setting the first type of pixel point
  • the updated gradient value of the pixel-like point and the gradient value of the second-type pixel point are used as the gradient value of each pixel point in the target image.
  • the gradient of the target image determined in the embodiment of the present application is an approximate gradient of the target image.
  • the mode length threshold if the mode length threshold is set too small, reflection ghosting may not be removed completely; if the mode length threshold is set too large, some details in the image may be removed incorrectly.
  • the mode length threshold is selected, a more appropriate value needs to be selected according to the strength of the reflection ghost, that is, the magnitude of the mode length threshold is related to the strength of the reflection ghost.
  • a preset length calculation method may be used to determine a modulus length threshold according to a gradient modulus length of each pixel point in an image to be processed.
  • the threshold value of the modulus length may be determined according to the maximum value, the minimum value, the mean value, and the median of the gradient modulus length of each pixel in the image to be processed.
  • the specific algorithm can be set as needed, and it is not limited here.
  • the value of the modulus length threshold may be selected by a user.
  • An initial target image may be generated by using a preset initial value of the modulus length threshold, and the initial target image may be displayed in a user interface.
  • a threshold input interface is provided in the user interface, and an updated value of the modulus length threshold is determined according to a user's operation on the threshold input interface.
  • An update target image is generated by using the update value of the modulus length threshold, and the update target image is displayed in the user interface.
  • the threshold input interface may be a text input interface or a graphical selection control, such as a sliding selection control, a scrolling selection control, or the like.
  • a text input interface the input value range can be displayed on the user interface so that the user can input a value within the value range as required.
  • a graphical selection control a plurality of discrete values can be provided as options through the selection control, or a continuous range of selectable values can be provided for the user to select.
  • the above-mentioned process of determining the update value of the modulus length threshold value and generating the update target image may be repeatedly performed according to the operation of the user, so that the user can obtain the target image with the best effect by selecting the update value.
  • step S340 the target image is generated based on the gradient of the target image.
  • the technical solution of the embodiment shown in FIG. 3 enables calculation of the image gradient of the image to be processed to filter out reflection ghost portions in the image to be processed, and then generates a target image based on the gradient of the obtained target image.
  • the purpose of effectively removing the reflection ghost can also ensure that the processed image has a high quality.
  • a gradient matrix of the image to be processed is determined. Determine the first element corresponding to the reflection ghost in the image to be processed according to the value of each element in the gradient matrix, use the first element to perform preset processing on the gradient matrix, and use the processed gradient matrix as all Describe the gradient matrix of the target image.
  • the target image is restored using the gradient matrix of the target image and the image to be processed.
  • the image to be processed may be represented by a matrix I having a dimension of M ⁇ N, where M and N represent the number of pixels in each row and each column in the image to be processed.
  • M and N represent the number of pixels in each row and each column in the image to be processed.
  • the boundary of the photographed object is usually clear, that is, the color changes are steep, while the reflection ghost is blurred, and the color change is smooth. That is, the gradient of the photographed object is 0 on most pixels, and the mode length of a few non-zero parts is larger, and the image length of the image part including reflection ghost is smaller on all pixels. So you can Perform preset processing Make the gradient matrix obtained after processing approximate the gradient matrix of the target image. Represents a preset process that removes the effect of reflection ghosts from the gradient matrix of the image to be processed.
  • ⁇ h ( ⁇ ) may be any feasible processing method.
  • h represents the threshold value of the gradient modulus length.
  • the gradient of pixels whose gradient modulus length is greater than h will be replaced with 0, that is, the color change of the corresponding pixel relative to the surrounding pixels will be smoothed.
  • ⁇ h ( ⁇ ) may include a gradient matrix of I using a clustering algorithm. The values of each element in the cluster are clustered to obtain multiple clusters.
  • Gradient matrix The value of the element belonging to at least one of the plurality of clusters (for example, the mean or the value of the cluster center is non-zero, and the non-maximum value of at least one cluster) is set to zero.
  • ⁇ h ( ⁇ ) may be other processing methods.
  • a Laplace transform result of the divergence of the gradient matrix of the target image may be determined.
  • the target image is restored using the Laplace transform result and the image to be processed.
  • the image to be processed I and the target image T can be regarded as a matrix of M ⁇ N, and substituted into the following formula to solve:
  • a gradient matrix representing the image I to be processed Represents the preset processing to remove the effect of reflection ghosts from the gradient matrix of the image to be processed
  • div ( ⁇ ) represents the divergence operator
  • is a preset weight, greater than 0 and less than 1
  • M and N respectively represent the image to be processed The number of pixels in each row and column of the matrix, that is, the dimension of the matrix I.
  • a weighted sum of the Laplacian result and the image to be processed may be determined; and a discrete cosine transform result of the weighted sum may be determined; An inverse transform of the discrete cosine transform is performed on the quotient of the discrete cosine transform result and the position feature amount of each pixel, and the value of the inverse transform is used as the pixel value of each pixel point.
  • the pixels T m, n in the m-th row and n-th column in the target image T can be solved using the following formula:
  • F c ( ⁇ ) represents the discrete cosine transform
  • M and N represent the number of pixels in each row and each column in the image to be processed, that is, the dimensions of the matrix I.
  • each color channel of an image to be processed may be separately processed to obtain a monochrome target image of each color channel, and then combined to obtain a target image. That is, the image gradient corresponding to each color channel of the image to be processed may be calculated; the gradient corresponding to each color channel of the target image is determined according to the image gradient corresponding to each color channel; based on each color channel of the target image The corresponding gradient generates a monochrome image corresponding to each color channel; and uses the monochrome image corresponding to each color channel to synthesize the target image.
  • a process for generating a target image based on a gradient of a target image includes the following steps S410, S420, and S430.
  • step S410 an optimization function is constructed according to the gradient of the target image, the image to be processed and the target variable, and an optimization model is constructed based on the optimization function.
  • the optimization model indicates that the value of the optimization function reaches a minimum. When the value, the optimal solution corresponding to the target variable represents the target image.
  • the process of constructing an optimization function may include the following steps S510 and S520:
  • step S510 calculate the divergence of the gradient of the target image, construct a first calculation term according to the divergence of the gradient of the target image and the Laplace transform term of the target variable, and according to the to-be-processed The image and the target variable construct a second calculation term.
  • the difference between the Laplace transform term of the target variable and the divergence of the gradient of the target image can be calculated, and then the square of the second norm of the difference is squared as the first A calculation term.
  • the difference between the image to be processed and the target variable can also be calculated, and then the square of the second norm of the difference is used as the second calculation item.
  • the first calculation term includes both the first derivative and the second derivative, there will be an infinite number of solutions when the optimal operation is performed to determine the optimal solution. Therefore, the first embodiment Two calculation terms to ensure that the optimization function has only a unique solution.
  • step S520 the optimization function is generated according to the first calculation item and the second calculation item.
  • step S520 specifically includes: generating a weight of the first calculation item and a weight of the second calculation item, wherein the weight of the second calculation item is less than the first calculation item A weighted sum of the first calculation item and the second calculation item according to the weight of the first calculation item and the weight of the second calculation item to generate the optimization function.
  • the weight of the second calculation term can be set to a small value to avoid causing a large solution to the solution of the optimization function. influences.
  • the optimization function may be generated according to the following formula:
  • a Laplace transform term representing the target variable Represents the gradient of the target image; div ( ⁇ ) represents a divergence operator; T represents the target variable; I represents the image to be processed; k 1 represents the weight of the first calculation item; k 2 represents the The weight of the second calculated term.
  • k 1 may be k 2 can be ⁇ is a parameter.
  • step S420 the optimization model is solved to obtain an optimal solution corresponding to the target variable.
  • solving the optimization model may specifically include the following steps:
  • step S610 a derivative operation is performed on the target variable in the optimization function to obtain a derivative of the optimization function.
  • step S620 the value of the derivative is set to 0 to construct a target equation.
  • step S630 the objective equation is solved to obtain an optimal solution corresponding to the objective variable.
  • the solution process of the target equation may be a discrete cosine transform process on the target equation; and then based on the result of performing the discrete cosine transform process on the target equation, the most corresponding corresponding to the target variable is obtained. Excellent solution.
  • step S430 the target image is generated based on the optimal solution corresponding to the target variable.
  • the process of generating the target image based on the optimal solution corresponding to the target variable includes:
  • Step S710 Calculate the pixel value of each pixel in the target image based on the optimal solution corresponding to the target variable.
  • the color value of each color channel corresponding to each pixel in the target image may be calculated based on the optimal solution corresponding to the target variable, and according to each pixel in the target image Corresponding to the color value of each color channel, the pixel value of each pixel point in the target image is determined.
  • each pixel corresponds to three color channels of R, G, and B. After obtaining the color value of each color channel corresponding to each pixel point, the pixel value of each pixel point can be obtained.
  • Step S720 Generate the target image according to a pixel value of each pixel point in the target image.
  • the technical solution of the above embodiment of the present application enables a global optimal solution to be obtained by constructing a convex function (that is, the above-mentioned optimization function), and a solution of the optimization function can be quickly obtained, which improves the image processing efficiency.
  • the image to be processed is I
  • the reflection ghost portion is a reflection layer (R)
  • the portion not including the reflection ghost is a transmission layer (T).
  • the gradient of the image I to be processed is obtained as follows formula:
  • the lens of the camera focuses on the photographic object behind the glass, and the reflective object on the glass is not close to the lens because it is close to the lens, so the image on the negative is blurred.
  • the reflection layer R is more blurred and the color changes are more gentle. It is 0 in most pixels, and the modulus length of a few non-zero parts is relatively large, and The modulus length is small at all pixels. So you can use the interception function to The smaller part is removed, so that the gradient obtained after interception is similar to which is
  • the interception function is defined as:
  • h represents the threshold of the gradient modulus length.
  • the gradient of pixels with gradient modulus length greater than h will be replaced by 0, that is, the color change of the corresponding pixel relative to the surrounding pixels will be smoothed.
  • the transmission layer T can be obtained by inverse solution.
  • the process of resolving to obtain the transport layer T depends on the following optimization model:
  • the above optimization model represents the objective function
  • the value of T corresponding to the minimum value is the obtained transport layer T.
  • the Laplace transform representing the transmission layer T is used to extract the edges of objects in the photo (that is, the boundaries with obvious color changes), where the Laplacian transformation of the transmission layer T is equal to its second step, that is div ( ⁇ ) represents the divergence operator, which is the negative transpose of the gradient operator.
  • Objective function It is used to indicate that the edge of the object in the transmission layer T is as close as possible to the obvious edge of the object in the input image I.
  • the objective function Both the first and second derivatives are included, then there will be an infinite number of solutions when determining the optimal solution with the derivative operation, so the objective function is added To ensure that the objective function has only a unique solution. And in order to avoid adding It has a greater impact on the results, and can make the parameter ⁇ take a very small value to ensure that the processed image has a better quality.
  • variable T can be differentiated in the objective function, and the derivative is 0, and the following equation can be obtained:
  • Equation 1 The above equation is a Poisson-like equation, which can be solved using a standard discrete cosine transform (DCT for Discrete Cosine Transform) to obtain a closed-form solution as shown in Equation 1 below:
  • DCT discrete cosine transform
  • Equation 1 P represents F c ( ⁇ ) represents the discrete cosine transform, Represents the corresponding inverse transform, the subscript (m, n) represents the pixels in the m-th row and the n-th column, and K is defined by the following formula 2:
  • M and N represent that the pixel dimension of the image I to be processed is M * N.
  • T can be obtained according to the above formula 1, where a color image has three color channels of red, green, and blue. Each color channel is calculated according to the above formula 1 and then combined.
  • the values of the parameters ⁇ and h need to be specified.
  • the value of ⁇ can be [10 -7 , 10 -9 ], for example, 10 -7 , 10 -8, or 10 -9 in order to achieve better de-ghosting effect. If the value of h is too small, the ghosting of the reflection layer will not be removed completely; if the value of h is too large, the details of the transmission layer will be removed by mistake. Therefore, the value of h needs to be adjusted according to the strength of the glass reflection ghost in the input image in order to achieve the best effect.
  • the technical solution of the embodiment of the present application can effectively remove the reflection ghosts in the image.
  • FIG. 9 represents an image including reflection ghosts
  • FIG. 9 represents According to the image obtained after the technical solution of the embodiment of the application is processed, it can be seen that the technical solution based on the embodiment of the application effectively removes the reflection ghosts 901 and 902 in (a) in FIG. 9.
  • FIG. 10 (a) shows an image including reflection ghosts
  • FIG. 10 (b) shows an image obtained after processing according to the technical solution of the embodiment of the present application.
  • the technical solution of the example effectively removes the reflection ghost 1001 in FIG. 10 (a).
  • FIG. 11 (a) shows an image including a reflection ghost
  • FIG. 11 (b) shows an image obtained after processing according to the technical solution of the embodiment of the present application.
  • the technical solution of the example effectively removes the reflection ghost 1101 in (a) in FIG. 11 and greatly reduces the reflection ghost 1102 in (a) in FIG. 11.
  • the image processing algorithm in the embodiment of the present application can be implemented on MATLAB 2017a.
  • the computer is configured with an 8-core Intel 7-8550U 1.80 GHz CPU and 16 GB of memory
  • the processing time of the image using the technical solution of the embodiment of the present application does not exceed 1.5 seconds, which is better than the best current image processing algorithms (such as the algorithm of eliminating reflection ghosts by iterative methods) About 800 times faster. It can be seen that the technical solution of the embodiment of the present application not only effectively removes reflection ghosts in the image, but also can improve the processing rate of the image.
  • FIG. 12 schematically illustrates a block diagram of an image processing apparatus according to an embodiment of the present application.
  • an image processing apparatus 1200 includes: an obtaining unit 1201, a gradient calculation unit 1202, a first processing unit 1203, and a second processing unit 1204.
  • the obtaining unit 1201 is configured to obtain a to-be-processed image including reflection ghosts; the gradient calculation unit 1202 is used to calculate an image gradient of the to-be-processed image; and the first processing unit 1203 is configured to determine the to-be-processed according to the image gradient. Processing the gradient of the target image after removing the reflection ghost; the second processing unit 1204 is configured to generate the target image based on the gradient of the target image.
  • the first processing unit 1203 includes a module length calculation unit 1301, a first determination unit 1302, and a second determination unit 1303.
  • the module length calculation unit 1301 is configured to calculate a gradient module length of each pixel in the image to be processed according to the image gradient; and the first determination unit 1302 is configured to be based on a gradient of each pixel in the image to be processed The module length determines a gradient value of each pixel point in the target image; a second determination unit 1303 is configured to determine a gradient of the target image according to the gradient value of each pixel point in the target image.
  • the first determining unit 1302 is configured to determine a first type of pixel point in the image to be processed whose gradient modulus length is smaller than a modulus length threshold and the gradient modulus length is greater than or equal to the modulus length Threshold second pixel type; set the gradient value of the first type pixel point to 0 to obtain the updated gradient value of the first type pixel point; update the gradient value of the first type pixel point And the gradient value of the second type of pixel points is used as the gradient value of each pixel point in the target image.
  • the magnitude of the modulus length threshold is related to the strength of the reflection ghost.
  • a preset length calculation method may be used to determine the modulus length threshold according to the gradient modulus length of each pixel in the image to be processed, or the value of the modulus length threshold may be selected by the user. For details, refer to the foregoing, and details are not described herein again. .
  • the second processing unit 1204 may determine a gradient matrix of the image to be processed. Determine the first element corresponding to the reflection ghost in the image to be processed according to the value of each element in the gradient matrix, use the first element to perform preset processing on the gradient matrix, and use the processed gradient matrix as all Describe the gradient matrix of the target image. The target image is restored using the gradient matrix of the target image and the image to be processed.
  • the second processing unit 1204 may represent the image to be processed with a matrix I having a dimension of M ⁇ N, and M and N represent the number of pixels in each row and each column in the image to be processed, respectively.
  • the boundary of the photographed object is usually clear, that is, the color changes are steep, while the reflection ghost is blurred, and the color change is smooth. That is, the gradient of the photographed object is 0 on most pixels, and the mode length of a few non-zero parts is larger, and the image length of the image part including reflection ghost is smaller on all pixels. So you can Perform preset processing Make the gradient matrix obtained after processing approximate the gradient matrix of the target image. Represents a preset process that removes the effect of reflection ghosts from the gradient matrix of the image to be processed.
  • ⁇ h ( ⁇ ) may be any feasible processing method.
  • h represents the threshold value of the gradient modulus length.
  • the gradient of pixels whose gradient modulus length is greater than h will be replaced with 0, that is, the color change of the corresponding pixel relative to the surrounding pixels will be smoothed.
  • ⁇ h ( ⁇ ) may include a gradient matrix of I using a clustering algorithm. The values of each element in the cluster are clustered to obtain multiple clusters.
  • Gradient matrix The value of the element belonging to at least one of the plurality of clusters (for example, the mean or the value of the cluster center is non-zero, and the non-maximum value of at least one cluster) is set to zero.
  • ⁇ h ( ⁇ ) may be other processing methods.
  • the second processing unit 1204 may determine a Laplace transform result of the divergence of the gradient matrix of the target image. .
  • the target image is restored using the Laplace transform result and the image to be processed.
  • the image to be processed I and the target image T can be regarded as a matrix of M ⁇ N, and substituted into the following formula to solve:
  • a gradient matrix representing the image I to be processed Represents a preset process that removes the effect of reflection ghosts from the gradient matrix of the image to be processed
  • div ( ⁇ ) represents a divergence operator
  • is a preset weight, greater than 0 and less than 1
  • M and N respectively represent the image to be processed
  • the number of pixels in each row and column of the matrix that is, the dimension of the matrix I.
  • the second processing unit 1204 may determine a weighted sum of the Laplace transform result and the image to be processed; A discrete cosine transform result; performing an inverse transform of the discrete cosine transform on the quotient of the discrete cosine transform result and the position feature amount of each pixel, and using the value of the inverse transform as the pixel value of each pixel point.
  • the pixels T m, n in the m-th row and n-th column in the target image T can be solved using the following formula:
  • F c ( ⁇ ) represents the discrete cosine transform
  • M and N represent the number of pixels in each row and each column in the image to be processed, that is, the dimensions of the matrix I.
  • the second processing unit 1204 may perform the foregoing processing on each color channel of the image to be processed to obtain a monochrome target image of each color channel, and then combine to obtain a target image. That is, the image gradient corresponding to each color channel of the image to be processed may be calculated; the gradient corresponding to each color channel of the target image is determined according to the image gradient corresponding to each color channel; based on each color channel of the target image The corresponding gradient generates a monochrome image corresponding to each color channel; and uses the monochrome image corresponding to each color channel to synthesize the target image.
  • the second processing unit 1204 includes: a constructing unit 1401, a solving unit 1402, and a generating unit 1403.
  • the constructing unit 1401 is configured to construct an optimization function according to the gradient of the target image, the image to be processed and the target variable, and construct an optimization model based on the optimization function, where the optimization model represents a value in the optimization function.
  • the optimal solution corresponding to the target variable represents the target image
  • a solving unit 1402 is configured to solve the optimization model to obtain an optimal solution corresponding to the target variable
  • a generating unit 1403 is configured to Based on the optimal solution corresponding to the target variable, the target image is generated.
  • the constructing unit 1401 is configured to calculate a divergence of a gradient of the target image, according to a divergence of the gradient of the target image and a Laplace transform term of the target variable A first calculation term is constructed, and a second calculation term is constructed according to the image to be processed and the target variable; and the optimization function is generated according to the first calculation term and the second calculation term.
  • the constructing unit 1401 is configured to generate a weight of the first calculation item and a weight of the second calculation item, wherein the weight of the second calculation item is less than the weight of the first calculation item A weight of a calculation item; weighting and summing the first calculation item and the second calculation item according to the weight of the first calculation item and the weight of the second calculation item to generate the optimization function .
  • the constructing unit 1401 is configured to generate the optimization function according to the following formula:
  • a Laplace transform term representing the target variable Represents the gradient of the target image; div ( ⁇ ) represents a divergence operator; T represents the target variable; I represents the image to be processed; k 1 represents the weight of the first calculation item; k 2 represents the The weight of the second calculated term.
  • the solving unit 1402 is configured to: perform a derivative operation on the target variable in the optimization function to obtain a derivative of the optimization function; and set the value of the derivative to 0 To construct an objective equation; solve the objective equation to obtain an optimal solution corresponding to the objective variable.
  • the solving unit 1402 is configured to: perform a discrete cosine transform process on the target equation; and obtain a result corresponding to the target variable based on a result of performing a discrete cosine transform process on the target equation. Optimal solution.
  • the generating unit 1403 is configured to: calculate a pixel value of each pixel in the target image based on an optimal solution corresponding to the target variable; and according to each of the target images The pixel value of a pixel point generates the target image.
  • the generating unit 1403 is configured to calculate the color values of each color channel corresponding to each pixel in the target image based on the optimal solution corresponding to the target variable; The color value of each color channel corresponding to each pixel point in the target image is used to determine the pixel value of each pixel point in the target image.
  • modules or units of the device for action execution are mentioned in the detailed description above, this division is not mandatory.
  • the features and functions of two or more modules or units described above may be embodied in one module or unit.
  • the features and functions of a module or unit described above can be further divided into multiple modules or units to be embodied.
  • the technical solution according to the embodiment of the present application may be embodied in the form of a software product, and the software product may be stored in a non-volatile storage medium (can be a CD-ROM, a U disk, a mobile hard disk, etc.) or on a network , Including several instructions to enable a computing device (which may be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiment of the present application.
  • a computing device which may be a personal computer, a server, a touch terminal, or a network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Image Processing (AREA)

Abstract

本申请实施例提供了一种图像处理方法、装置、计算机可读介质及电子设备。该图像处理方法包括:获取包含有反射重影的待处理图像;计算所述待处理图像的图像梯度;根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度;基于所述目标图像的梯度,生成所述目标图像。本申请实施例的技术方案能够有效去除图像中的反射重影,保证了处理后的图像具有较高的质量。

Description

图像处理方法、装置、计算机可读介质及电子设备
本申请要求于2018年06月29日提交中国专利局、申请号为201810693249.3、申请实施例名称为“图像处理方法、装置、计算机可读介质及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及计算机技术领域,具体而言,涉及一种图像处理方法、装置、计算机可读介质及电子设备。
背景
现实生活中的许多照片是隔着玻璃(例如窗户、橱窗等)拍摄的,这样拍摄得到的照片中会带有玻璃表面的反射重影,对实际拍摄的目标物体造成干扰。
针对上述问题,相关技术中提出了基于多张相似的图像(例如略微变换拍摄角度、使用偏光器、开启/关闭闪光灯等方法拍摄到的多张图像)来将反射重影部分分离出来并去除。但是,这种方案需要拍摄多张相似的图像,还需运用特殊装置或满足特定条件,因而难以适用于实际生活情形。可见,目前并没有有效的去除反射重影的技术方案。
需要说明的是,在上述背景技术部分公开的信息仅用于加强对本申请实施例的背景的理解,因此可以包括不构成对本领域普通技术人员已知的现有技术的信息。
技术内容
本申请实施例的目的在于提供一种图像处理方法、装置、计算机可 读介质及电子设备,进而至少在一定程度上克服无法有效去除图像中的反射重影的问题。
本申请实施例的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本申请实施例的实践而习得。
根据本申请实施例的一个方面,提供了一种图像处理方法,包括:获取包含有反射重影的待处理图像;计算所述待处理图像的图像梯度;根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度;基于所述目标图像的梯度,生成所述目标图像。
根据本申请实施例的一个方面,提供了一种图像处理装置,包括:获取单元,用于获取包含有反射重影的待处理图像;梯度计算单元,用于计算所述待处理图像的图像梯度;第一处理单元,用于根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度;第二处理单元,用于基于所述目标图像的梯度,生成所述目标图像。
根据本申请实施例的一个方面,提供了一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述实施例中所述的图像处理方法。
根据本申请实施例的一个方面,提供了一种电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现如上述实施例中所述的图像处理方法。
在本申请的一些实施例所提供的技术方案中,通过计算待处理图像的图像梯度,并根据该待处理图像的图像梯度确定待处理图像去除反射重影之后的目标图像的梯度,以基于该目标图像的梯度生成目标图像,使得能够通过计算待处理图像的图像梯度来过滤掉待处理图像中的反射重影部分,进而基于得到的目标图像的梯度来生成目标图像,避免了 相关技术中需要采用多张相似的图像来消除反射重影而带来的实用性较低的问题,实现了在一张图像的基础上有效去除反射重影的目的,同时能够保证处理后的图像具有较高的质量。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。
附图简要说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。在附图中:
图1示出了可以应用本申请实施例的图像处理方法或图像处理装置的示例性系统架构的示意图;
图2示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图;
图3示意性示出了根据本申请的一个实施例的图像处理方法的流程图;
图4示意性示出了根据本申请的一个实施例的基于目标图像的梯度生成目标图像的流程图;
图5示意性示出了根据本申请的一个实施例的构建优化函数的流程图;
图6示意性示出了根据本申请的一个实施例的对优化模型进行求解的流程图;
图7示意性示出了根据本申请的一个实施例的基于目标变量对应的 最优解生成目标图像的流程图;
图8示出了根据本申请的一个实施例的拍照时的成像过程示意图;
图9示出了根据本申请的一个实施例的对包含有反射重影的图像进行处理前后的对比效果示意图;
图10示出了根据本申请的一个实施例的对包含有反射重影的图像进行处理前后的对比效果示意图;
图11示出了根据本申请的一个实施例的对包含有反射重影的图像进行处理前后的对比效果示意图;
图12示意性示出了根据本申请的一个实施例的图像处理装置的框图;
图13示意性示出了根据本申请的一个实施例的第一处理单元的框图;
图14示意性示出了根据本申请的一个实施例的第二处理单元的框图。
实施方式
现在将参考附图更全面地描述示例实施方式。然而,示例实施方式能够以多种形式实施,且不应被理解为限于在此阐述的范例;相反,提供这些实施方式使得本申请将更加全面和完整,并将示例实施方式的构思全面地传达给本领域的技术人员。
此外,所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施例中。在下面的描述中,提供许多具体细节从而给出对本申请的实施例的充分理解。然而,本领域技术人员将意识到,可以实践本申请实施例的技术方案而没有特定细节中的一个或更多,或者可以采用其它的方法、组元、装置、步骤等。在其它情况下,不详细示出或描 述公知方法、装置、实现或者操作以避免模糊本申请实施例的各方面。
附图中所示的方框图仅仅是功能实体,不一定必须与物理上独立的实体相对应。即,可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。
附图中所示的流程图仅是示例性说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解,而有的操作/步骤可以合并或部分合并,因此实际执行的顺序有可能根据实际情况改变。
图1示出了可以应用本申请实施例的图像处理方法或图像处理装置的示例性系统架构100的示意图。
如图1所示,系统架构100可以包括终端设备101、102、103中的一种或多种,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线通信链路、无线通信链路等等。
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。比如服务器105可以是多个服务器组成的服务器集群等。
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103可以是具有显示屏的各种电子设备,包括但不限于智能手机、平板电脑、便携式计算机和台式计算机等等。
服务器105可以是提供各种服务的服务器。例如用户利用终端设备103(也可以是终端设备101或102)向服务器105上传了包含有反射重影的待处理图像。服务器105在接收到该待处理图像之后,可以计算该 待处理图像的图像梯度,然后根据该图像梯度确定待处理图像去除反射重影之后的目标图像的梯度,进而基于该目标图像的梯度,生成目标图像。
需要说明的是,本申请实施例所提供的图像处理方法一般由服务器105执行,相应地,图像处理装置一般设置于服务器105中。但是,在本申请的其它实施例中,终端也可以与服务器具有相似的功能,从而执行本申请实施例所提供的图像处理方案,比如终端在拍摄到一张包含有反射重影的图像之后,直接对该图像进行处理,进而得到去除反射重影之后的清晰图像。
图2示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。
需要说明的是,图2示出的电子设备的计算机系统200仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。
如图2所示,计算机系统200包括中央处理单元(CPU)201,其可以根据存储在只读存储器(ROM)202中的程序或者从存储部分208加载到随机访问存储器(RAM)203中的程序而执行各种适当的动作和处理。在RAM 203中,还存储有系统操作所需的各种程序和数据。CPU 201、ROM 202以及RAM 203通过总线204彼此相连。输入/输出(I/O)接口205也连接至总线204。
以下部件连接至I/O接口205:包括键盘、鼠标等的输入部分206;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分207;包括硬盘等的存储部分208;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分209。通信部分209经由诸如因特网的网络执行通信处理。驱动器210也根据需要连接至I/O接口205。可拆卸介质211,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需 要安装在驱动器210上,以便于从其上读出的计算机程序根据需要被安装入存储部分208。
特别地,根据本申请的实施例,下文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分209从网络上被下载和安装,和/或从可拆卸介质211被安装。在该计算机程序被中央处理单元(CPU)201执行时,执行本申请的系统中限定的各种功能。
需要说明的是,本申请实施例所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请实施例中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请实施例中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、 装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、有线等等,或者上述的任意合适的组合。
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现,所描述的单元也可以设置在处理器中。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定。
作为另一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该电子设备执行时,使得该电子设备实现如下述实施例中所述的方法。例如,所述的电子设备可以实现如图3至图7所示的各个步骤。
以下对本申请实施例的技术方案的实现细节进行详细阐述:
图3示意性示出了根据本申请的一个实施例的图像处理方法的流程 图,该图像处理方法适用于前述实施例中所述的电子设备。参照图3所示,该图像处理方法至少包括步骤S310至步骤S340,详细介绍如下:
在步骤S310中,获取包含有反射重影的待处理图像。
在本申请的一个实施例中,待处理图像可以是用户通过终端(如智能手机、照相机、摄像机等)拍摄得到的,比如用户隔着玻璃、橱窗等进行拍摄时可能由于玻璃的反射作用导致拍摄的图像中存在发射重影。
在步骤S320中,计算所述待处理图像的图像梯度。
在本申请的一个实施例中,在计算待处理图像的图像梯度时,可以将图像看成二维离散函数,计算图像的梯度其实就是对这个二维离散函数进行求导。
在步骤S330中,根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度。
在本申请的一个实施例中,步骤S330具体包括:根据所述图像梯度计算所述待处理图像中的各个像素点的梯度模长;基于所述待处理图像中的各个像素点的梯度模长,确定所述目标图像中的各个像素点的梯度值;根据所述目标图像中的各个像素点的梯度值,确定所述目标图像的梯度。
在该实施例中,相对于物体边界清晰的目标图像而言,反射重影通常较为模糊,颜色变化较为平缓,那么目标图像的梯度值在大部分像素上都是0,而少数非0部分的梯度模长都比较大,但是反射重影部分在所有像素上的模长都比较小,因此可以根据待处理图像中的各个像素点的梯度模长来确定目标图像中的各个像素点的梯度值。
具体地,在本申请的一个实施例中,可以根据待处理图像中的各个像素点的梯度模长,确定待处理图像中梯度模长小于模长阈值的第一类像素点和梯度模长大于或等于所述模长阈值的第二类像素点;然后将所 述第一类像素点的梯度值设为0,得到所述第一类像素点更新后的梯度值;进而将所述第一类像素点更新后的梯度值和所述第二类像素点的梯度值作为所述目标图像中的各个像素点的梯度值。需要说明的是,本申请实施例中确定的目标图像的梯度是目标图像的近似梯度。
在本申请的一个实施例中,模长阈值如果设置过小,则会导致反射重影去除不彻底;模长阈值如果设置过大,则会导致图像中的一些细节去错误去除,因此在选择模长阈值时,需要根据反射重影的强弱程度选择较为合适的值,即模长阈值的大小与反射重影的强弱程度相关联。
一些实施例中,可以根据待处理图像中各个像素点的梯度模长利用预设的计算方法确定模长阈值。例如,可以根据待处理图像中各像素点的梯度模长的最大值、最小值、均值、中位数等,确定模长阈值。具体的算法可以根据需要进行设置,这里不进行限定。
另一些实施例中,可以由用户选择模长阈值的取值。可以先利用模长阈值的预设的初始值生成初始目标图像,并将所述初始目标图像展示在用户界面中。在用户界面中提供一个阈值输入接口,根据用户对所述阈值输入接口的操作确定模长阈值的更新值。利用模长阈值的更新值生成更新目标图像,将更新目标图像展示在所述用户界面中。
其中,阈值输入接口可以是文本输入接口,也可以是图形化的选择控件,例如滑动选择控件、滚动式选择控件,等。当阈值输入接口用文本输入接口实现时,可以在用户界面上展示输入的值范围,以便用户根据需要输入该值范围内的数值。当阈值输入接口用图形化的选择控件实现时,可以通过选择控件提供复数个离散的值作为选项,也可以提供一个连续的可选值的范围供用户选择。
上述确定模长阈值的更新值、生成更新目标图像的过程可以根据用户的操作重复执行多次,使得用户可以通过选择更新值,得到效果最佳 的目标图像。
继续参照图3所示,在步骤S340中,基于所述目标图像的梯度,生成所述目标图像。
图3所示实施例的技术方案使得能够通过计算待处理图像的图像梯度来过滤掉待处理图像中的反射重影部分,进而基于得到的目标图像的梯度来生成目标图像,实现了在一张图像的基础上有效去除反射重影的目的,同时能够保证处理后的图像具有较高的质量。
各实施例中,生成目标图像时,确定所述待处理图像的梯度矩阵。根据所述梯度矩阵中各元素的值确定所述待处理图像中反射重影对应的第一元素,利用所述第一元素对所述梯度矩阵进行预设处理,将处理后的梯度矩阵作为所述目标图像的梯度矩阵。利用所述目标图像的梯度矩阵和所述待处理图像还原所述目标图像。
例如,可以将待处理图像用维度为M×N的矩阵I表示,M和N分别表示待处理图像中每行和每列中像素的数目。可以对待处理图像I求梯度,例如,可以求相邻像素的值之差,得到I的梯度矩阵
Figure PCTCN2019088973-appb-000001
由于待处理图像中,被拍摄物体的边界通常比较清晰,也即颜色变化较为陡峭,而反射重影则较为模糊,颜色变化较为平缓。也即,被拍摄物体的梯度在大部分像素上都是0,而少数非0部分的模长都比较大,而包括反射重影的图像部分在所有像素上的模长都比较小。因此可以对
Figure PCTCN2019088973-appb-000002
进行预设的处理
Figure PCTCN2019088973-appb-000003
使得处理之后所得的梯度矩阵近似于目标图像的梯度矩阵。
Figure PCTCN2019088973-appb-000004
表示从待处理图像的梯度矩阵中去除反射重影的影响的预设处理。
各实施例中,δ h(·)可以为任意可行的处理方法。例如,
Figure PCTCN2019088973-appb-000005
Figure PCTCN2019088973-appb-000006
其中,h表示梯度模长的阈值。根据该例的处理方法,梯度模长大于h的像素点的梯度将被替换为0,即对应像素相对于周边像素的颜色变化将被抹平。又例如,δ h(·)可以包括,利用聚类算法对I的梯度矩阵
Figure PCTCN2019088973-appb-000007
中各元素的值进行聚类,得到多个聚类。将梯度矩阵
Figure PCTCN2019088973-appb-000008
中属于上述多个聚类中至少一个聚类(例如均值或聚类中心的值非0,且非最大的至少一个聚类)的元素的值设置为0。以上仅为举例。其它实施例中,δ h(·)还可以是其它处理方法。
一些实施例中,利用所述目标图像的梯度矩阵和所述待处理图像还原所述目标图像时,可以确定所述目标图像的梯度矩阵的散度的拉普拉斯变换结果。利用所述拉普拉斯变换结果和所述待处理图像还原所述目标图像。
例如,可以将待处理图像I和目标图像T看做M×N的矩阵,并代入下面的公式求解:
Figure PCTCN2019088973-appb-000009
其中,
Figure PCTCN2019088973-appb-000010
表示拉普拉斯变换;
Figure PCTCN2019088973-appb-000011
表示待处理图像I的梯度矩阵;
Figure PCTCN2019088973-appb-000012
表示从待处理图像的梯度矩阵中去除反射重影的影响的预设处理;div(·)表示散度算子;ε为预设的权重,大于0小于1;M和N分别表示待处理图像中每行和每列中像素的数目,也即矩阵I的维度。
一些实施例中,利用拉普拉斯变换值和待处理图像得到所述目标图像时,可以确定拉普拉斯变换结果和待处理图像的加权和;确定所述加权和的离散余弦变换结果;对所述离散余弦变换结果与各像素的位置特征量的商进行离散余弦变换的逆变换,将所述逆变换的值作为各像素点的像素值。
例如,目标图像T中的第m行、第n列的像素T m,n可以利用下面的 公式求解:
Figure PCTCN2019088973-appb-000013
其中,F c(·)表示离散余弦变换,
Figure PCTCN2019088973-appb-000014
表示离散余弦变换的逆变换,
Figure PCTCN2019088973-appb-000015
Figure PCTCN2019088973-appb-000016
M和N分别表示待处理图像中每行和每列中像素的数目,也即矩阵I的维度。
一些实施例中,可以对待处理图像的各颜色通道分别进行上述处理,得到各颜色通道的单色目标图像,再合并得到目标图像。也即,可以计算所述待处理图像的各颜色通道对应的图像梯度;根据各颜色通道对应的图像梯度,确定所述目标图像的各颜色通道对应的梯度;基于所述目标图像的各颜色通道对应的梯度,生成各颜色通道对应的单色图像;利用所述各颜色通道对应的单色图像合成所述目标图像。
参照图4所示,根据本申请一个实施例的基于目标图像的梯度生成目标图像的流程,包括如下步骤S410、步骤S420和步骤S430。
在步骤S410中,根据所述目标图像的梯度,以及所述待处理图像和目标变量构建优化函数,并基于所述优化函数构建优化模型,所述优化模型表示在所述优化函数的值达到最小值时,所述目标变量对应的最优解表示所述目标图像。
在本申请的一个实施例中,如图5所示,构建优化函数的过程可以包括如下步骤S510和步骤S520:
在步骤S510中,计算所述目标图像的梯度的散度,根据所述目标图像的梯度的散度和所述目标变量的拉普拉斯变换项构建第一计算项,并 根据所述待处理图像和所述目标变量构建第二计算项。
在本申请的一个实施例中,可以计算目标变量的拉普拉斯变换项和目标图像的梯度的散度之间的差值,然后求该差值的二范数的平方,以此作为第一计算项。同时也可以计算待处理图像与目标变量之间的差值,然后将该差值的二范数的平方作为第二计算项。
需要说明的是,由于第一计算项中包含的均为一阶导数和二阶导数,那么在进行求导运算确定最优解时会存在无限多个解,因此在上述实施例中添加了第二计算项来保证优化函数在求解时仅有唯一解。
在步骤S520中,根据所述第一计算项和所述第二计算项,生成所述优化函数。
在本申请的一个实施例中,步骤S520具体包括:生成所述第一计算项的权重和所述第二计算项的权重,其中,所述第二计算项的权重小于所述第一计算项的权重;根据所述第一计算项的权重和所述第二计算项的权重,对所述第一计算项和所述第二计算项进行加权求和,以生成所述优化函数。
在该实施例中,由于第二计算项是为了保证优化函数在求解时仅有唯一解,因此可以将第二计算项的权重设置为较小值,以避免对优化函数的解造成较大的影响。
在本申请的一个实施例中,可以根据以下公式生成所述优化函数:
Figure PCTCN2019088973-appb-000017
其中,
Figure PCTCN2019088973-appb-000018
表示所述目标变量的拉普拉斯变换项;
Figure PCTCN2019088973-appb-000019
表示所述目标图像的梯度;div(·)表示散度算子;T表示所述目标变量;I表示所述待处理图像;k 1表示所述第一计算项的权重;k 2表示所述第二计算项的权重。
在本申请的一个实施例中,k 1可以为
Figure PCTCN2019088973-appb-000020
k 2可以为
Figure PCTCN2019088973-appb-000021
ε为参数。
继续参照图4所示,在步骤S420中,对所述优化模型进行求解,以得到所述目标变量对应的最优解。
在本申请的一个实施例中,如图6所示,对所述优化模型进行求解,具体可以包括如下步骤:
步骤S610,在所述优化函数中对所述目标变量进行求导运算,得到所述优化函数的导数。
步骤S620,将所述导数的值置为0,以构建目标方程。
步骤S630,对所述目标方程进行求解,以得到所述目标变量对应的最优解。
在本申请的一个实施例中,对目标方程的求解过程可以是对目标方程进行离散余弦变换处理;然后基于对所述目标方程进行离散余弦变换处理后的结果,得到所述目标变量对应的最优解。
继续参照图4所示,在步骤S430中,基于所述目标变量对应的最优解,生成所述目标图像。
在本申请的一个实施例中,如图7所示,基于目标变量对应的最优解,生成所述目标图像的过程,包括:
步骤S710,基于所述目标变量对应的最优解,计算所述目标图像中的各个像素点的像素值。
在本申请的一个实施例中,可以基于目标变量对应的最优解,分别计算所述目标图像中的各个像素点对应的各个颜色通道的颜色值,并根据所述目标图像中的各个像素点对应的各个颜色通道的颜色值,确定所述目标图像中的各个像素点的像素值。
在本申请的一个实施例中,对于RGB图像而言,每个像素点对应了R、G、B三个颜色通道。在获得每个像素点对应的各个颜色通道的颜色值之后,可以得到各个像素点的像素值。
步骤S720,根据所述目标图像中的各个像素点的像素值,生成所述目标图像。
本申请上述实施例的技术方案使得能够通过构建凸函数(即上述的优化函数)来保证得到全局最优解,并且能够快速求出优化函数的解,提高了图像的处理效率。
以下结合图8至图11,以待处理图像为I,反射重影部分为反射层(Reflection Layer)R,不包含反射重影的部分为传输层(Transmission Layer)T为例,对本申请实施例的技术方案的实现细节进行详细阐述:
在本申请的一个实施例中,待处理图像I可以分解为传输层T和反射层R,即I=T+R,假设反射层R是缓和平滑的,对待处理图像I求梯度,得到如下等式:
Figure PCTCN2019088973-appb-000022
如图8所示,由于在实际拍照的过程中,照相机的镜头对焦于玻璃后面的被拍摄物体,玻璃上的反射物体由于距离镜头较近,无法完全聚焦,因而在底片上成像较为模糊。
基于上述分析可知,相对于物体边界清晰的传输层T,反射层R较为模糊,颜色变化较为平缓,用数学语言来描述,即
Figure PCTCN2019088973-appb-000023
在大部分像素上都是0,而少数非0部分的模长都比较大,而
Figure PCTCN2019088973-appb-000024
在所有像素上的模长都比较小。因此可以用截取函数将
Figure PCTCN2019088973-appb-000025
较小的部分去掉,从而使得截取之后所得的梯度就近似于
Figure PCTCN2019088973-appb-000026
Figure PCTCN2019088973-appb-000027
其中,截取函数定义为:
Figure PCTCN2019088973-appb-000028
在截取函数的定义中,h表示梯度模长的阈值,梯度模长大于h的像素点的梯度将被替换为0,即对应像素相对于周边像素的颜色变化将 被抹平。
通过以上原理,当给定一个图像I之后,可以通过反解得到传输层T。在本申请的一个实施例中,反解得到传输层T的过程依赖于如下优化模型:
Figure PCTCN2019088973-appb-000029
上述优化模型表示目标函数
Figure PCTCN2019088973-appb-000030
的值在最小时对应的T值即为得到的传输层T。
在上述优化模型中,
Figure PCTCN2019088973-appb-000031
表示传输层T的拉普拉斯变换,用于提取照片中物体的边缘(即颜色变化明显的边界),其中传输层T的拉普拉斯变换等于其二阶梯度,即
Figure PCTCN2019088973-appb-000032
div(·)表示散度算子,为梯度算子的负转置。目标函数中
Figure PCTCN2019088973-appb-000033
用于表示传输层T中的物体边缘与输入图像I中物体的明显边缘尽量接近。
由于目标函数中的
Figure PCTCN2019088973-appb-000034
包含的均为一阶导数和二阶导数,那么在进行求导运算确定最优解时会存在无限多个解,因此在目标函数中添加了
Figure PCTCN2019088973-appb-000035
来保证目标函数在求解时仅有唯一解。而为了避免在目标函数中添加的
Figure PCTCN2019088973-appb-000036
对结果造成较大的影响,可以使参数ε取一个极小的值,以便保证处理得到的图像具有较优的质量。
为了求解上述的优化模型,可以在在目标函数中对变量T求导,令导数为0,可得到下面的方程:
Figure PCTCN2019088973-appb-000037
上述方程是一个类泊松方程,可以使用标准的离散余弦变换(DCT for Discrete Cosine Transform)求解,得到如下述公式1所示的闭式解:
Figure PCTCN2019088973-appb-000038
在公式1中,P表示
Figure PCTCN2019088973-appb-000039
F c(·)表示离散余弦变换,
Figure PCTCN2019088973-appb-000040
表示对应的逆变换,脚标(m,n)表示第m行第n列的像素,K由下式公式2定义:
Figure PCTCN2019088973-appb-000041
在上述公式2中,M和N代表待处理的图像I的像素维度是M*N。
基于上述的理论基础,当给定一张带有玻璃反射重影的输入图像I时,可以按照上述公式1求得T即可,其中彩色图像具有红、绿、蓝三个颜色通道,因此对于每个颜色通道都按照上述公式1进行计算,然后再进行合并即可。在求解过程中需要指定参数ε和h的值,在本申请的一个实施例中,ε的取值可以取[10 -7,10 -9],比如可以取10 -7、10 -8或10 -9,以便达到较好的去重影效果。而若h取值过小,会导致反射层重影去除不彻底;若h取值过大,会导致传输层的细节被错误去除。因此,h的取值需要根据输入图像中玻璃反射重影的强弱程度进行调整,以便达到最佳的效果。
本申请实施例的技术方案可以有效去除图像中的反射重影,具体如图9所示,图9中(a)图表示包含有反射重影的图像,图9中(b)图表示根据本申请实施例的技术方案处理后得到的图像,可见基于本申请实施例的技术方案有效去除了图9中(a)图中的反射重影901和902。
再如图10所示,图10中(a)图表示包含有反射重影的图像,图10中(b)图表示根据本申请实施例的技术方案处理后得到的图像,可见基于本申请实施例的技术方案有效去除了图10中(a)图中的反射重 影1001。
又如图11所示,图11中(a)图表示包含有反射重影的图像,图11中(b)图表示根据本申请实施例的技术方案处理后得到的图像,可见基于本申请实施例的技术方案有效去除了图11中(a)图中的反射重影1101,并极大减弱了图11中(a)图中的反射重影1102。
在本申请的一个实施例中,可以在MATLAB 2017a上实现本申请实施例中的图像处理算法,当计算机配置为8核Intel i7-8550U 1.80GHz CPU和16GB内存时,对于一张用手机拍摄的1440*1080像素的照片,采用本申请实施例的技术方案对图像进行处理的时间不超过1.5秒,比现行的最好的图像处理算法(如通过迭代的方式来消除反射重影的算法那)快大约800倍。可见,本申请实施例的技术方案不仅有效去除了图像中的反射重影,而且能够提高图像的处理速率。
以下介绍本申请实施例的装置实施例,可以用于执行本申请实施例上述实施例中的图像处理方法。对于本申请实施例装置实施例中未披露的细节,请参照本申请实施例上述的图像处理方法的实施例。
图12示意性示出了根据本申请的一个实施例的图像处理装置的框图。
参照图12所示,根据本申请的一个实施例的图像处理装置1200,包括:获取单元1201、梯度计算单元1202、第一处理单元1203和第二处理单元1204。
其中,获取单元1201用于获取包含有反射重影的待处理图像;梯度计算单元1202用于计算所述待处理图像的图像梯度;第一处理单元1203用于根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度;第二处理单元1204用于基于所述目标图像的梯度,生成所述目标图像。
在本申请的一个实施例中,如图13所示,第一处理单元1203包括:模长计算单元1301、第一确定单元1302和第二确定单元1303。
其中,模长计算单元1301用于根据所述图像梯度计算所述待处理图像中的各个像素点的梯度模长;第一确定单元1302用于基于所述待处理图像中的各个像素点的梯度模长,确定所述目标图像中的各个像素点的梯度值;第二确定单元1303用于根据所述目标图像中的各个像素点的梯度值,确定所述目标图像的梯度。
在本发明的一个实施例中,所述第一确定单元1302用于:确定所述待处理图像中梯度模长小于模长阈值的第一类像素点和梯度模长大于或等于所述模长阈值的第二类像素点;将所述第一类像素点的梯度值设为0,得到所述第一类像素点更新后的梯度值;将所述第一类像素点更新后的梯度值和所述第二类像素点的梯度值作为所述目标图像中的各个像素点的梯度值。
在本发明的一个实施例中,所述模长阈值的大小与所述反射重影的强弱程度相关联。各实施例中,可以根据待处理图像中各个像素点的梯度模长利用预设的计算方法确定模长阈值,也可以由用户选择模长阈值的取值,具体参见上文,这里不再赘述。
一些实施例中,第二处理单元1204可以确定所述待处理图像的梯度矩阵。根据所述梯度矩阵中各元素的值确定所述待处理图像中反射重影对应的第一元素,利用所述第一元素对所述梯度矩阵进行预设处理,将处理后的梯度矩阵作为所述目标图像的梯度矩阵。利用所述目标图像的梯度矩阵和所述待处理图像还原所述目标图像。
例如,第二处理单元1204可以将待处理图像用维度为M×N的矩阵I表示,M和N分别表示待处理图像中每行和每列中像素的数目。可以对待处理图像I求梯度,例如,可以求相邻像素的值之差,得到I的 梯度矩阵
Figure PCTCN2019088973-appb-000042
由于待处理图像中,被拍摄物体的边界通常比较清晰,也即颜色变化较为陡峭,而反射重影则较为模糊,颜色变化较为平缓。也即,被拍摄物体的梯度在大部分像素上都是0,而少数非0部分的模长都比较大,而包括反射重影的图像部分在所有像素上的模长都比较小。因此可以对
Figure PCTCN2019088973-appb-000043
进行预设的处理
Figure PCTCN2019088973-appb-000044
使得处理之后所得的梯度矩阵近似于目标图像的梯度矩阵。
Figure PCTCN2019088973-appb-000045
表示从待处理图像的梯度矩阵中去除反射重影的影响的预设处理。
各实施例中,δ h(·)可以为任意可行的处理方法。例如,
Figure PCTCN2019088973-appb-000046
Figure PCTCN2019088973-appb-000047
其中,h表示梯度模长的阈值。根据该例的处理方法,梯度模长大于h的像素点的梯度将被替换为0,即对应像素相对于周边像素的颜色变化将被抹平。又例如,δ h(·)可以包括,利用聚类算法对I的梯度矩阵
Figure PCTCN2019088973-appb-000048
中各元素的值进行聚类,得到多个聚类。将梯度矩阵
Figure PCTCN2019088973-appb-000049
中属于上述多个聚类中至少一个聚类(例如均值或聚类中心的值非0,且非最大的至少一个聚类)的元素的值设置为0。以上仅为举例。其它实施例中,δ h(·)还可以是其它处理方法。
一些实施例中,利用所述目标图像的梯度矩阵和所述待处理图像还原所述目标图像时,第二处理单元1204可以确定所述目标图像的梯度矩阵的散度的拉普拉斯变换结果。利用所述拉普拉斯变换结果和所述待处理图像还原所述目标图像。
例如,可以将待处理图像I和目标图像T看做M×N的矩阵,并代入下面的公式求解:
Figure PCTCN2019088973-appb-000050
其中,
Figure PCTCN2019088973-appb-000051
表示拉普拉斯变换;
Figure PCTCN2019088973-appb-000052
表示待处理图像I的梯度矩阵;
Figure PCTCN2019088973-appb-000053
表示从待处理图像的梯度矩阵中去除反射重影的影响的预设处理;div(·)表示散度算子;ε为预设的权重,大于0小于1;M和N分别表示待处理图像中每行和每列中像素的数目,也即矩阵I的维度。
一些实施例中,利用拉普拉斯变换值和待处理图像得到所述目标图像时,第二处理单元1204可以确定拉普拉斯变换结果和待处理图像的加权和;确定所述加权和的离散余弦变换结果;对所述离散余弦变换结果与各像素的位置特征量的商进行离散余弦变换的逆变换,将所述逆变换的值作为各像素点的像素值。
例如,目标图像T中的第m行、第n列的像素T m,n可以利用下面的公式求解:
Figure PCTCN2019088973-appb-000054
其中,F c(·)表示离散余弦变换,
Figure PCTCN2019088973-appb-000055
表示离散余弦变换的逆变换,
Figure PCTCN2019088973-appb-000056
Figure PCTCN2019088973-appb-000057
M和N分别表示待处理图像中每行和每列中像素的数目,也即矩阵I的维度。
一些实施例中,第二处理单元1204可以对待处理图像的各颜色通道分别进行上述处理,得到各颜色通道的单色目标图像,再合并得到目标图像。也即,可以计算所述待处理图像的各颜色通道对应的图像梯度;根据各颜色通道对应的图像梯度,确定所述目标图像的各颜色通道对应的梯度;基于所述目标图像的各颜色通道对应的梯度,生成各颜色通道对应的单色图像;利用所述各颜色通道对应的单色图像合成所述目标图像。
在本申请的一个实施例中,如图14所示,第二处理单元1204包括: 构建单元1401、求解单元1402和生成单元1403。
其中,构建单元1401用于根据所述目标图像的梯度,以及所述待处理图像和目标变量构建优化函数,并基于所述优化函数构建优化模型,所述优化模型表示在所述优化函数的值达到最小值时,所述目标变量对应的最优解表示所述目标图像;求解单元1402用于对所述优化模型进行求解,以得到所述目标变量对应的最优解;生成单元1403用于基于所述目标变量对应的最优解,生成所述目标图像。
在本申请的一个实施例中,所述构建单元1401用于:计算所述目标图像的梯度的散度,根据所述目标图像的梯度的散度和所述目标变量的拉普拉斯变换项构建第一计算项,并根据所述待处理图像和所述目标变量构建第二计算项;根据所述第一计算项和所述第二计算项,生成所述优化函数。
在本申请的一个实施例中,所述构建单元1401用于:生成所述第一计算项的权重和所述第二计算项的权重,其中,所述第二计算项的权重小于所述第一计算项的权重;根据所述第一计算项的权重和所述第二计算项的权重,对所述第一计算项和所述第二计算项进行加权求和,以生成所述优化函数。
在本申请的一个实施例中,所述构建单元1401用于根据以下公式生成所述优化函数:
Figure PCTCN2019088973-appb-000058
其中,
Figure PCTCN2019088973-appb-000059
表示所述目标变量的拉普拉斯变换项;
Figure PCTCN2019088973-appb-000060
表示所述目标图像的梯度;div(·)表示散度算子;T表示所述目标变量;I表示所述待处理图像;k 1表示所述第一计算项的权重;k 2表示所述第二计算项的权重。
在本申请的一个实施例中,所述求解单元1402用于:在所述优化函 数中对所述目标变量进行求导运算,得到所述优化函数的导数;将所述导数的值置为0,以构建目标方程;对所述目标方程进行求解,以得到所述目标变量对应的最优解。
在本申请的一个实施例中,所述求解单元1402用于:对所述目标方程进行离散余弦变换处理;基于对所述目标方程进行离散余弦变换处理后的结果,得到所述目标变量对应的最优解。
在本申请的一个实施例中,所述生成单元1403用于:基于所述目标变量对应的最优解,计算所述目标图像中的各个像素点的像素值;根据所述目标图像中的各个像素点的像素值,生成所述目标图像。
在本申请的一个实施例中,所述生成单元1403用于:基于所述目标变量对应的最优解,分别计算所述目标图像中的各个像素点对应的各个颜色通道的颜色值;根据所述目标图像中的各个像素点对应的各个颜色通道的颜色值,确定所述目标图像中的各个像素点的像素值。
应当注意,尽管在上文详细描述中提及了用于动作执行的设备的若干模块或者单元,但是这种划分并非强制性的。实际上,根据本申请的实施方式,上文描述的两个或更多模块或者单元的特征和功能可以在一个模块或者单元中具体化。反之,上文描述的一个模块或者单元的特征和功能可以进一步划分为由多个模块或者单元来具体化。
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本申请实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、触控终端、或者网络设备等)执行根据本申请实施方式的方法。
本领域技术人员在考虑说明书及实践这里公开的申请后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本申请的真正范围和精神由下面的权利要求指出。
应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求来限制。
综上所述,权利要求的范围不应局限于以上描述的例子中的实施方式,而应当将说明书作为一个整体并给予最宽泛的解释。

Claims (21)

  1. 一种图像处理方法,包括:
    获取包含有反射重影的待处理图像;
    计算所述待处理图像的图像梯度;
    根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度;
    基于所述目标图像的梯度,生成所述目标图像。
  2. 根据权利要求1所述的图像处理方法,其中,根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度,包括:
    根据所述图像梯度计算所述待处理图像中的各个像素点的梯度模长;
    基于所述待处理图像中的各个像素点的梯度模长,确定所述目标图像中的各个像素点的梯度值;
    根据所述目标图像中的各个像素点的梯度值,确定所述目标图像的梯度。
  3. 根据权利要求2所述的图像处理方法,其中,基于所述待处理图像中的各个像素点的梯度模长,确定所述目标图像中的各个像素点的梯度值,包括:
    确定所述待处理图像中梯度模长小于模长阈值的第一类像素点和梯度模长大于或等于所述模长阈值的第二类像素点;
    将所述第一类像素点的梯度值设为0,得到所述第一类像素点更新后的梯度值;
    将所述第一类像素点更新后的梯度值和所述第二类像素点的梯度值作为所述目标图像中的各个像素点的梯度值。
  4. 根据权利要求3所述的图像处理方法,进一步包括:
    根据所述待处理图像中各个像素点的梯度模长利用预设的计算方法确定所述模长阈值。
  5. 根据权利要求3所述的图像处理方法,进一步包括:
    利用所述模长阈值的预设初始值生成初始目标图像,将所述初始目标图像展示在用户界面中;
    在所述用户界面中提供阈值输入接口,根据用户对所述阈值输入接口的操作确定所述模长阈值的更新值;
    利用所述模长阈值的更新值生成更新目标图像,将所述更新目标图像展示在所述用户界面中。
  6. 根据权利要求1所述的图像处理方法,其中,基于所述目标图像的梯度,生成所述目标图像,包括:
    确定所述待处理图像的梯度矩阵;
    根据所述梯度矩阵中各元素的值确定所述待处理图像中反射重影对应的第一元素,利用所述第一元素对所述梯度矩阵进行预设处理,将处理后的梯度矩阵作为所述目标图像的梯度矩阵;
    利用所述目标图像的梯度矩阵和所述待处理图像还原所述目标图像。
  7. 根据权利要求6所述的图像处理方法,其中,利用所述目标图像的梯度矩阵和所述待处理图像还原所述目标图像包括:
    确定所述目标图像的梯度矩阵的散度的拉普拉斯变换结果;
    利用所述拉普拉斯变换结果和所述待处理图像还原所述目标图像。
  8. 根据权利要求7所述的图像处理方法,其中,利用所述拉普拉斯变换结果和所述待处理图像还原所述目标图像包括:
    确定所述拉普拉斯变换值和所述待处理图像的加权和;
    确定所述加权和的离散余弦变换结果;
    对所述离散余弦变换结果与各像素的位置特征量的商进行离散余弦 变换的逆变换,将所述逆变换的值作为各像素点的像素值。
  9. 根据权利要求1所述的图像处理方法,其中,计算所述待处理图像的图像梯度、根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度、基于所述目标图像的梯度,生成所述目标图像包括:
    计算所述待处理图像的各颜色通道对应的图像梯度;
    根据各颜色通道对应的图像梯度,确定所述目标图像的各颜色通道对应的梯度;
    基于所述目标图像的各颜色通道对应的梯度,生成各颜色通道对应的单色图像;
    利用所述各颜色通道对应的单色图像合成所述目标图像。
  10. 根据权利要求1所述的图像处理方法,其特征在于,基于所述目标图像的梯度,生成所述目标图像,包括:
    根据所述目标图像的梯度,以及所述待处理图像和目标变量构建优化函数,并基于所述优化函数构建优化模型,所述优化模型表示在所述优化函数的值达到最小值时,所述目标变量对应的最优解表示所述目标图像;
    对所述优化模型进行求解,以得到所述目标变量对应的最优解;
    基于所述目标变量对应的最优解,生成所述目标图像。
  11. 根据权利要求10所述的图像处理方法,其特征在于,根据所述目标图像的梯度,以及所述待处理图像和目标变量构建优化函数,包括:
    计算所述目标图像的梯度的散度,根据所述目标图像的梯度的散度和所述目标变量的拉普拉斯变换项构建第一计算项,并根据所述待处理图像和所述目标变量构建第二计算项;
    根据所述第一计算项和所述第二计算项,生成所述优化函数。
  12. 根据权利要求11所述的图像处理方法,其特征在于,根据所述第一计算项和所述第二计算项,生成所述优化函数,包括:
    生成所述第一计算项的权重和所述第二计算项的权重,其中,所述第二计算项的权重小于所述第一计算项的权重;
    根据所述第一计算项的权重和所述第二计算项的权重,对所述第一计算项和所述第二计算项进行加权求和,以生成所述优化函数。
  13. 根据权利要求12所述的图像处理方法,其特征在于,根据以下公式生成所述优化函数:
    Figure PCTCN2019088973-appb-100001
    其中,L(T)表示所述目标变量的拉普拉斯变换项;
    Figure PCTCN2019088973-appb-100002
    表示所述目标图像的梯度;div(·)表示散度算子;T表示所述目标变量;I表示所述待处理图像;k_1表示所述第一计算项的权重;k_2表示所述第二计算项的权重。
  14. 根据权利要求10至13中任一项所述的图像处理方法,其特征在于,对所述优化模型进行求解,包括:
    在所述优化函数中对所述目标变量进行求导运算,得到所述优化函数的导数;
    将所述导数的值置为0,以构建目标方程;
    对所述目标方程进行求解,以得到所述目标变量对应的最优解。
  15. 根据权利要求14所述的图像处理方法,其特征在于,对所述目标方程进行求解,包括:
    对所述目标方程进行离散余弦变换处理;
    基于对所述目标方程进行离散余弦变换处理后的结果,得到所述目标变量对应的最优解。
  16. 根据权利要求10所述的图像处理方法,其特征在于,基于所述 目标变量对应的最优解,生成所述目标图像,包括:
    基于所述目标变量对应的最优解,计算所述目标图像中的各个像素点的像素值;
    根据所述目标图像中的各个像素点的像素值,生成所述目标图像。
  17. 根据权利要求16所述的图像处理方法,其特征在于,基于所述目标变量对应的最优解,计算所述目标图像中的各个像素点的像素值,包括:
    基于所述目标变量对应的最优解,分别计算所述目标图像中的各个像素点对应的各个颜色通道的颜色值;
    根据所述目标图像中的各个像素点对应的各个颜色通道的颜色值,确定所述目标图像中的各个像素点的像素值。
  18. 一种图像处理装置,其特征在于,包括:
    获取单元,用于获取包含有反射重影的待处理图像;
    梯度计算单元,用于计算所述待处理图像的图像梯度;
    第一处理单元,用于根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度;
    第二处理单元,用于基于所述目标图像的梯度,生成所述目标图像。
  19. 一种计算机可读介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至17中任一项所述的图像处理方法。
  20. 一种电子设备,其特征在于,包括:
    一个或多个处理器;
    存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现如权利要求1至17中任一项所述的图像处理方法。
  21. 一种图像处理方法,应用于电子设备,包括:
    获取包含有反射重影的待处理图像;
    计算所述待处理图像的图像梯度;
    根据所述图像梯度确定所述待处理图像去除所述反射重影之后的目标图像的梯度;
    基于所述目标图像的梯度,生成所述目标图像。
PCT/CN2019/088973 2018-06-29 2019-05-29 图像处理方法、装置、计算机可读介质及电子设备 WO2020001222A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP19824450.1A EP3817361A4 (en) 2018-06-29 2019-05-29 IMAGE PROCESSING METHOD, COMPUTER READABLE MEDIUM, AND ELECTRONIC DEVICE
US16/921,813 US11348207B2 (en) 2018-06-29 2020-07-06 Image processing method and apparatus, computer-readable medium, and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810693249.3A CN110166684B (zh) 2018-06-29 2018-06-29 图像处理方法、装置、计算机可读介质及电子设备
CN201810693249.3 2018-06-29

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/921,813 Continuation US11348207B2 (en) 2018-06-29 2020-07-06 Image processing method and apparatus, computer-readable medium, and electronic device

Publications (1)

Publication Number Publication Date
WO2020001222A1 true WO2020001222A1 (zh) 2020-01-02

Family

ID=67645043

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/088973 WO2020001222A1 (zh) 2018-06-29 2019-05-29 图像处理方法、装置、计算机可读介质及电子设备

Country Status (4)

Country Link
US (1) US11348207B2 (zh)
EP (1) EP3817361A4 (zh)
CN (1) CN110166684B (zh)
WO (1) WO2020001222A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111292268A (zh) * 2020-02-07 2020-06-16 北京字节跳动网络技术有限公司 图像处理方法、装置、电子设备及计算机可读存储介质
CN113395436A (zh) * 2020-03-12 2021-09-14 杭州海康威视数字技术股份有限公司 图像处理方法、图像处理装置及图像处理系统

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110738677A (zh) * 2019-09-20 2020-01-31 清华大学 相机全清晰成像方法、装置与电子设备
CN113379610B (zh) * 2020-03-10 2024-03-15 Tcl科技集团股份有限公司 图像处理模型的训练方法、图像处理方法、介质及终端
CN111782219B (zh) * 2020-07-16 2024-03-22 矩阵元技术(深圳)有限公司 基于TensorFlow的自定义类型实现方法和装置
CN114037643A (zh) * 2021-11-12 2022-02-11 成都微光集电科技有限公司 图像处理方法、装置、介质和设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103247036A (zh) * 2012-02-10 2013-08-14 株式会社理光 多曝光图像融合方法和装置
CN105959543A (zh) * 2016-05-19 2016-09-21 努比亚技术有限公司 一种去除反光的拍摄装置和方法
CN106650794A (zh) * 2016-11-24 2017-05-10 北京理工大学 一种受物体表面高光反射影响的图像高光消除方法及系统
CN106683052A (zh) * 2015-11-06 2017-05-17 奥多比公司 使用视觉伪影抑制对照片和视频去雾
CN107610059A (zh) * 2017-08-28 2018-01-19 维沃移动通信有限公司 一种图像处理方法及移动终端
WO2018092540A1 (ja) * 2016-11-15 2018-05-24 ソニー株式会社 画像処理装置、および画像処理方法、並びにプログラム

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7616826B2 (en) * 2006-07-28 2009-11-10 Massachusetts Institute Of Technology Removing camera shake from a single photograph using statistics of a natural image
EP2384492A4 (en) * 2009-01-22 2012-08-08 Hewlett Packard Development Co ESTIMATING THE FLOU TYPE DEGRADATION OF AN IMAGE USING SPECULAR OVERFLOWS
JP2011029710A (ja) * 2009-07-21 2011-02-10 Nikon Corp 画像処理装置、画像処理プログラムおよび撮像装置
KR101699919B1 (ko) * 2011-07-28 2017-01-26 삼성전자주식회사 다중 노출 퓨전 기반에서 고스트 흐림을 제거한 hdr 영상 생성 장치 및 방법
US8705881B2 (en) * 2011-09-02 2014-04-22 Adobe Systems Incorporated Motion deblurring for text images
US8687913B2 (en) * 2012-07-17 2014-04-01 Adobe Systems Incorporated Methods and apparatus for image deblurring and sharpening using local patch self-similarity
US10063829B2 (en) * 2014-04-18 2018-08-28 Canon Kabushiki Kaisha Image processing method, image processing apparatus, image pickup apparatus, and non-transitory computer-readable storage medium
JP2017010092A (ja) * 2015-06-17 2017-01-12 キヤノン株式会社 画像処理装置、撮像装置、画像処理方法、画像処理プログラム、および、記憶媒体
JP2017157043A (ja) * 2016-03-02 2017-09-07 キヤノン株式会社 画像処理装置、撮像装置、及び、画像処理方法
CN105976332B (zh) * 2016-05-03 2019-03-01 北京大学深圳研究生院 基于图像中亮条纹信息的图像去模糊方法
KR102614906B1 (ko) * 2016-12-05 2023-12-18 삼성전자주식회사 영상 처리 방법 및 장치
CN106651798B (zh) * 2016-12-16 2020-04-28 四川长虹电器股份有限公司 一种有效的图像镜面反射移除方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103247036A (zh) * 2012-02-10 2013-08-14 株式会社理光 多曝光图像融合方法和装置
CN106683052A (zh) * 2015-11-06 2017-05-17 奥多比公司 使用视觉伪影抑制对照片和视频去雾
CN105959543A (zh) * 2016-05-19 2016-09-21 努比亚技术有限公司 一种去除反光的拍摄装置和方法
WO2018092540A1 (ja) * 2016-11-15 2018-05-24 ソニー株式会社 画像処理装置、および画像処理方法、並びにプログラム
CN106650794A (zh) * 2016-11-24 2017-05-10 北京理工大学 一种受物体表面高光反射影响的图像高光消除方法及系统
CN107610059A (zh) * 2017-08-28 2018-01-19 维沃移动通信有限公司 一种图像处理方法及移动终端

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LI, YU: "Exploiting Reflection Change for Automatic Reflection Removal", 2013 IEEE INTERNATIONAL CONFERENCE ON COMPUTER VISION, 31 December 2013 (2013-12-31), XP032572828 *
See also references of EP3817361A4

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111292268A (zh) * 2020-02-07 2020-06-16 北京字节跳动网络技术有限公司 图像处理方法、装置、电子设备及计算机可读存储介质
CN111292268B (zh) * 2020-02-07 2023-07-25 抖音视界有限公司 图像处理方法、装置、电子设备及计算机可读存储介质
CN113395436A (zh) * 2020-03-12 2021-09-14 杭州海康威视数字技术股份有限公司 图像处理方法、图像处理装置及图像处理系统

Also Published As

Publication number Publication date
CN110166684B (zh) 2021-09-17
EP3817361A1 (en) 2021-05-05
US11348207B2 (en) 2022-05-31
CN110166684A (zh) 2019-08-23
EP3817361A4 (en) 2021-08-25
US20200334794A1 (en) 2020-10-22

Similar Documents

Publication Publication Date Title
WO2020001222A1 (zh) 图像处理方法、装置、计算机可读介质及电子设备
WO2020156009A1 (zh) 视频修复方法及装置、电子设备和存储介质
US9697587B2 (en) Adaptive path smoothing for video stabilization
TWI777112B (zh) 圖像處理方法、電子設備和儲存介質
US20220222776A1 (en) Multi-Stage Multi-Reference Bootstrapping for Video Super-Resolution
TWI706379B (zh) 圖像處理方法及裝置、電子設備和儲存介質
US20210004962A1 (en) Generating effects on images using disparity guided salient object detection
US20150131898A1 (en) Blind image deblurring with cascade architecture
WO2016074620A1 (en) Parallax tolerant video stitching with spatial-temporal localized warping and seam finding
US10586308B2 (en) Digital media environment for removal of obstructions in a digital image scene
US9123138B2 (en) Adaptive patch-based image upscaling
US20140307950A1 (en) Image deblurring
EP3779891A1 (en) Method and device for training neural network model, and method and device for generating time-lapse photography video
US20170278219A1 (en) Adaptive path smoothing for video stabilization
CN109767401B (zh) 画面优化方法、装置、终端及对应的存储介质
CN110852334B (zh) 用于自适应像素滤波的系统和方法
US9984440B2 (en) Iterative patch-based image upscaling
US8995784B2 (en) Structure descriptors for image processing
US11107191B2 (en) Apparatus and method for detail enhancement in super-resolution imaging using mobile electronic device
WO2021109867A1 (zh) 图像处理方法及装置、计算机可读介质和电子设备
US9525818B2 (en) Automatic tuning of images based on metadata
CN113810755B (zh) 全景视频预览的方法、装置、电子设备及存储介质
WO2022095878A1 (zh) 拍摄方法、装置、电子设备及可读存储介质
CN115170383A (zh) 一种图像虚化方法、装置、存储介质及终端设备
US11893704B2 (en) Image processing method and device therefor

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19824450

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2019824450

Country of ref document: EP