[go: up one dir, main page]

CN110097520B - Image processing method and device - Google Patents

Image processing method and device Download PDF

Info

Publication number
CN110097520B
CN110097520B CN201910375766.0A CN201910375766A CN110097520B CN 110097520 B CN110097520 B CN 110097520B CN 201910375766 A CN201910375766 A CN 201910375766A CN 110097520 B CN110097520 B CN 110097520B
Authority
CN
China
Prior art keywords
image
value
processed
determining
channel value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910375766.0A
Other languages
Chinese (zh)
Other versions
CN110097520A (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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910375766.0A priority Critical patent/CN110097520B/en
Publication of CN110097520A publication Critical patent/CN110097520A/en
Application granted granted Critical
Publication of CN110097520B publication Critical patent/CN110097520B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image

Landscapes

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

Abstract

The embodiment of the disclosure discloses an image processing method and device. One embodiment of the method comprises: determining a dark channel value and a bright channel value of the image to be processed based on color values of pixels of the image to be processed, wherein the bright channel value and the dark channel value are used for indicating the brightness of the image to be processed; determining an offset for adjusting the color value of the image to be processed based on the determined bright channel value and the dark channel value; and adjusting the pixel value of the image to be processed based on the determined offset to obtain a processed image, wherein the embodiment can adjust the color of the image to be processed, or perform defogging processing and shading processing on the image with fog or the image with heavy shadow in the shot image, thereby improving the image imaging quality.

Description

Image processing method and device
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to an image processing method and device.
Background
With the development of electronic technology, image processing technology has been widely used. Users prefer to perform image processing using various image processing-class applications installed in terminals. For example, the user may beautify the shot picture, remove noise in the image, etc.; the brightness degree of the shot picture can be adjusted; it is also possible to remove unnecessary scenes (e.g., people around the subject) in the taken picture, and the like.
In the related image processing technology, when an image is too bright or too dark, it is generally necessary to perform overall adjustment on the gray-scale value of the image to reduce the brightness or darkness of the image.
Disclosure of Invention
The embodiment of the disclosure provides an image processing method and device.
In a first aspect, an embodiment of the present disclosure provides an image processing method, including: determining a dark channel value and a bright channel value of the image to be processed based on color values of pixels of the image to be processed, wherein the bright channel value and the dark channel value are used for indicating the brightness of the image to be processed; determining an offset for adjusting the color value of the image to be processed based on the determined bright channel value and the dark channel value; and adjusting the pixel value of the image to be processed based on the determined offset to obtain a processed image.
In some embodiments, determining dark channel values for the image to be processed comprises: dividing an image to be processed into a preset number of blocks, wherein each block in the preset number of blocks comprises a preset number of pixels; determining the minimum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined minimum color values in each block, and determining the obtained summation result as the dark channel value of the image to be processed.
In some embodiments, determining a bright channel value for the image to be processed comprises: determining the maximum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined maximum color values in each block, and determining the obtained summation result as the bright channel value of the image to be processed.
In some embodiments, determining an offset required to process the image to be processed based on the determined bright channel values and dark channel values comprises: determining the ratio of the bright channel value to the dark channel value; and determining the offset based on the ratio, the preset ratio of the bright channel to the dark channel and the dark channel value.
In some embodiments, each of the predetermined number of blocks includes one pixel.
In some embodiments, the predetermined ratio of the bright channel to the dark channel is determined based on a ratio of a bright channel value and a dark channel value of the historical sample images in the historical sample image set.
In a second aspect, an embodiment of the present disclosure provides an image processing apparatus, including: a first determination unit configured to determine a dark channel value and a bright channel value of an image to be processed based on color values of pixels of the image to be processed, wherein the bright channel value and the dark channel value are used for indicating the brightness of the image to be processed; a second determination unit configured to determine an offset amount for performing color value adjustment on the image to be processed based on the determined bright channel value and dark channel value; and the image processing unit is configured to adjust the pixel value of the image to be processed based on the determined offset, so as to obtain a processed image.
In some embodiments, the first determination unit is further configured to: dividing an image to be processed into a preset number of blocks, wherein each block in the preset number of blocks comprises a preset number of pixels; determining the minimum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined minimum color values in each block, and determining the obtained summation result as the dark channel value of the image to be processed.
In some embodiments, the first determination unit is further configured to: determining the maximum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined maximum color values in each block, and determining the obtained summation result as the bright channel value of the image to be processed.
In some embodiments, the second determination unit is further configured to: determining the ratio of the bright channel value to the dark channel value; and determining the offset based on the ratio, the preset ratio of the bright channel to the dark channel and the dark channel value.
In some embodiments, each of the predetermined number of blocks includes one pixel.
In some embodiments, the predetermined ratio of the bright channel to the dark channel is determined based on a ratio of a bright channel value and a dark channel value of the historical sample images in the historical sample image set.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; storage means for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any implementation of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, which computer program, when executed by a processor, implements the method as described in any of the implementations of the first aspect.
According to the image processing method and device provided by the embodiment of the disclosure, the offset of processing the image to be processed is determined by determining the dark channel value and the bright channel value of the image to be processed, and finally the pixel value of the image to be processed is adjusted according to the determined offset to obtain the processed image, so that the color of the image to be processed can be adjusted, or the defogging processing and the shadow removing processing are performed on the image with fog or the image with heavy shadow in the shot image, and the image imaging quality is improved.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of an image processing method according to the present disclosure;
FIG. 3 is a flow diagram of one embodiment of an alternative implementation of an image processing method according to the present disclosure;
4 a-4 b are schematic diagrams of an application scenario of an image processing method according to an embodiment of the present disclosure;
FIG. 5 is a schematic block diagram of one embodiment of an image processing apparatus according to the present disclosure;
FIG. 6 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 shows an exemplary architecture 100 to which embodiments of the image processing method or image processing apparatus of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The terminal apparatuses 101, 102, 103 may have installed thereon a photographing apparatus such as a camera, and may also have installed thereon a user such as a photographing-type application. Thus, the user can perform image capturing or the like through the terminal apparatuses 101, 102, 103. Various client applications may also be installed on the terminal devices 101, 102, 103. For example, a web browser application, a video application, a content sharing application, a social application, and the like, so that the user can also obtain an image through the application. The terminals 101, 102, 103 are also installed with applications such as image processing. Thus, the user can process images acquired by the photographing-type application or images acquired by other applications. The terminal devices 101, 102, 103 may interact with the server 105 via the network 104 to receive or send messages or the like.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices that can receive user operations, including but not limited to smart phones, tablet computers, e-book readers, laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a background server supporting client applications installed on the terminal devices 101, 102, 103. The terminal apparatuses 101, 102, 103 may transmit the acquired image to the server 105 to cause the server 105 to process the image, and return the processed image to the terminal apparatuses 101, 102, 103. Or a server that supports each processing function of the image processing class application installed in the terminal apparatuses 101, 102, 103.
The server 105 may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be noted that the image processing method provided by the embodiment of the present disclosure may be executed by the terminal devices 101, 102, and 103, or may be executed by the server 105. When the memory occupied by the image is too large, the image can be processed by using a server; this may be performed by the terminal devices 101, 102, 103 when the capability of the image processor of the terminal device to process the image is sufficient. Accordingly, the image processing apparatus is provided in the terminal devices 101, 102, 103 or in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of an image processing method according to the present disclosure is shown. The image processing method comprises the following steps:
step 201, determining dark channel values and bright channel values of the image to be processed based on color values of pixels of the image to be processed.
In this embodiment, an execution subject of the image processing method (for example, the terminal apparatus 101, 102, 103 or the server 105 shown in fig. 1) may first determine color values of pixels of the image to be processed after acquiring the image to be processed. The color of the image consists of three color channels, namely a R (Red) channel, a G (Green) channel and a B (Blue) channel, and the variation range of each color channel is (0-255). The color value of each pixel consists of a red color value, a green color value, and a blue color value. The RGB color values are all one value from 0-255.
Here, the dark channel is a concept defined based on an image defogging algorithm proposed by the hodcamen bosch. Specifically, the dark channel value is the minimum value of the light intensity in a certain area of the image. I.e. the smallest of the RGB values of all pixels in the area. The bright channel value is the maximum value of the light intensity in a certain area. I.e. the largest of the RGB values of all pixels in the area. That is, the two channel value, the dark channel value, is used to indicate the brightness of the image.
In some optional implementations of this embodiment, determining the dark channel value of the image to be processed includes: dividing an image to be processed into a preset number of blocks; determining the minimum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined minimum color values in each block, and determining the obtained summation result as the dark channel value of the image to be processed.
Specifically, the predetermined number of blocks may be specified manually. The number is determined according to the size of the image. When the image is too large, the number of blocks can be increased, and when the image is smaller, the number of blocks can be reduced, and the setting is carried out according to the requirements of application scenes. Here, each tile includes a plurality of pixels. The number of pixels it comprises is determined according to the size of the block. Then, for each of the predetermined number of blocks, the execution body may determine a minimum color value among RGB of pixels included in the block. As an example, when a certain block of an image includes 1000 pixels, the RGB values of one pixel are 10, 100, and 100, respectively. The RGB values of the remaining pixels are all greater than 10. Thus, the smallest color value in the tile can be determined to be 10. Then, the execution body may sum the determined minimum color values in each tile, and the sum result is used as a dark channel value of the image to be processed. For example, when the image to be processed is composed of 5 blocks, the minimum color values in the 5 blocks are 10, 20, and 30, respectively. The dark channel value of the image to be processed is 50.
In some optional implementations of this embodiment, determining a bright channel value of the image to be processed includes: determining the maximum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined maximum color values in each block, and determining the obtained summation result as the bright channel value of the image to be processed.
Specifically, for each of the predetermined number of blocks, the execution body may determine a maximum color value among RGB of pixels included in the block. As an example, when a certain block of an image includes 1000 pixels, the RGB values of one pixel are 10, 100, and 200, respectively. The RGB values of the remaining pixels are all less than 200. Thus, the maximum color value in the tile may be determined to be 200. Then, the execution body may sum up the determined color values of the maximum in each tile, and the sum result is used as a bright channel value of the image to be processed. For example, when the image to be processed is composed of 5 blocks, the maximum color values in the 5 blocks are 220, 200, 180, 70, and 100, respectively. The bright channel value of the image to be processed is 770.
It should be noted here that the shape of each block may be rectangular, circular, or the like. In order to facilitate the segmentation of the image, the shape of the block is usually set to be square. That is, the number of pixels corresponding to each side length in each block is the same.
And step 202, determining the offset for adjusting the color value of the image to be processed based on the determined bright channel value and dark channel value.
In this embodiment, the execution body described above may determine the ratio of the bright channel value and the dark channel value based on the determined bright channel value and dark channel value. Then, the above-described offset amount is determined based on the ratio. Generally, the larger the ratio is, the larger the difference between the brightness and the darkness in the image is, that is, the image brightness is too high, and the brightness can be appropriately reduced, so that the image can be shifted to the direction of reducing the brightness. Here, the execution subject may present a plurality of shifted images for selection by a user. Then, the color value shift result corresponding to the image selected by the user relative to the image to be processed is used as the shift amount.
In some optional implementations of this embodiment, the determining, based on the determined bright channel value and the dark channel value, an offset for processing the image to be processed includes: determining the ratio of the bright channel value to the dark channel value; and determining the offset based on the ratio of the bright channel value to the dark channel value, the preset ratio of the bright channel to the dark channel and the dark channel value.
Specifically, the execution body may be preset with a standard value of a ratio of the bright channel to the dark channel. Then, the ratio of the determined bright channel value and dark channel value may be compared with the above standard value, thereby determining the offset amount for performing color value adjustment on the image to be processed. Here, the difference between the ratio of the bright channel value and the dark channel value and the standard value may be determined. This difference is multiplied by the dark channel value described above. And then, subtracting one from the standard value and multiplying the standard value by the number of the divided blocks to obtain a second value. Finally, the quotient of the difference and the second value is determined as the offset.
In some optional implementations of the embodiment, the ratio of the preset bright channel to the dark channel is determined based on a ratio of a bright channel value and a dark channel value of the historical sample image in the historical sample image set.
Specifically, the executing subject may take multiple sample images for different light and weather based on the same scene. The plurality of sample images may be captured for strong light, weak light, fog, rain, clear sky, etc., for example, and are not limited herein. Then, the executing body may determine the bright channel value, the dark channel value, and the ratio between the bright channel value and the dark channel value of each image, for each sample image, using the determination method of the bright channel value and the dark channel value as described above. That is, each sample image corresponds to a ratio between a bright channel value and a dark channel value. Therefore, after the execution main body acquires the image to be processed, the ratio between the bright channel value and the dark channel value corresponding to the image with the effect required to be presented can be selected. For example, when an image shot by strong light needs to be presented, a ratio between a bright channel value and a dark channel value corresponding to the strong light sample image in the history sample image may be selected as a ratio between a preset bright channel value and a preset dark channel value.
The ratio of the preset bright channel to the preset dark channel is determined by the method, and the image to be processed can be processed to obtain different presentation effects of the image. When the image needs to be separated from the foreground and the background, the ratio between the bright channel value and the dark channel value corresponding to the historical image with high foreground-background contrast can be directly selected, so that the image is easier to process. Meanwhile, the preset ratio can be directly obtained from the historical sample image set to obtain the image effect required to be presented, so that the image processing speed can be improved.
It is to be noted here that when determining the ratio between the bright channel value and the dark channel value, in order to prevent the case where the dark channel value is 0, a smoothing constant larger than 0 may be added to the dark channel value at the time of calculation.
It should be noted that, for convenience of processing, the color values of each channel of the pixel are usually normalized, i.e. normalized to 0-1 from 0-255, so as to increase the processing speed.
And step 203, adjusting the pixel value of the image to be processed based on the determined offset to obtain a processed image.
In this embodiment, the execution body may add the obtained offset amounts to the respective pixel values after the offset amount obtained in step 202. That is, the offset is directly added to the color value of each pixel in the image to be processed. Here, when the offset amount needs to be subtracted from each color value, when a certain channel is a negative number after subtracting the offset amount, the color value of the channel is set to 0 at this time. When the color value of a certain channel exceeds 255 after adding the offset, the color value of the channel is set to be 255.
According to the image processing method provided by the embodiment of the disclosure, the offset of processing the image to be processed is determined by determining the dark channel value and the bright channel value of the image to be processed, and finally the pixel value of the image to be processed is adjusted through the determined offset to obtain the processed image, so that the color of the image to be processed can be adjusted, or the defogging processing and the shadow removing processing are performed on the image with fog or the image with heavy shadow in the shot image, and the image imaging quality is improved.
With further reference to fig. 3, a flow 300 of an embodiment of an alternative implementation of the present disclosure is shown. In the embodiment shown in fig. 3, each of the predetermined number of blocks in step 202 includes a pixel. The optional implementation manner specifically includes:
step 301, determining the minimum color value in the three primary color values of each pixel in the image to be processed.
Specifically, the image to be processed is composed of a plurality of pixels. Each pixel includes three primary color values. Thus, the color value with the smallest tristimulus color value in each pixel can be determined.
Step 302, summing the minimum color values in the determined pixels, and determining the obtained summation result as the dark channel value of the image to be processed.
Step 303, determining the maximum color value in the three primary color values of each pixel in the image to be processed.
And step 304, summing the determined maximum color values in each pixel, and determining the obtained summation result as the bright channel value of the image to be processed.
Step 305 determines the ratio of the bright channel value to the dark channel value.
Step 306, determining the offset based on the ratio of the bright channel value to the dark channel value, the preset ratio of the bright channel to the dark channel, and the dark channel value.
Specifically, the offset m can be determined by the following formula:
Figure BDA0002051601890000091
wherein R is the ratio of the bright channel value and the dark channel value based on the image to be processed; r is the ratio of the preset bright channel value to the preset dark channel value; sigma IdarkFor the dark channel value, D is the total number of pixels of the image to be processed.
The specific processing of the ratio of the preset bright channel value to the preset dark channel value and the beneficial effects thereof can refer to the related description in step 202, and are not described herein again.
And 307, adjusting the pixel value of the image to be processed based on the determined offset to obtain a processed image.
In this embodiment, the execution entity may add the obtained offset amount to each pixel value after the offset amount obtained in step 306. That is, the offset is directly added to the color value of each pixel in the image to be processed. Here, when the offset amount needs to be subtracted from each color value, when a certain channel is a negative number after subtracting the offset amount, the color value of the channel is set to 0 at this time. When the color value of a certain channel exceeds 255 after adding the offset, the color value of the channel is set to be 255.
As can be seen from fig. 3, unlike the embodiment shown in fig. 2, the present embodiment does not divide the image to be processed into blocks, and directly processes the pixels to obtain the bright channel value and the dark channel value. Thus, the determined offset amount can be more accurate for images with fewer pixels, and the processing effect can be improved.
With further reference to fig. 4 a-4 b, an application scenario diagram of the image processing method of the present disclosure is shown. Fig. 4a is an image to be processed. Wherein the number of pixels included in the image to be processed is 600 × 400. As shown in fig. 4a, the image of the scene is low in overall brightness, i.e. the color is gray. After acquiring fig. 4a, the execution subject may process the image of fig. 4a by using the method for determining the offset in formula (1), so as to obtain a processed image. Fig. 4b shows the processed image. Comparing fig. 4a with fig. 4b, it can be seen that the overall brightness of the scene represented by fig. 4b is greater than the brightness of the scene represented by fig. 4 a.
With further reference to fig. 5, as an implementation of the method shown in the above figures, the present disclosure provides an embodiment of an image processing apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 5, the present embodiment provides an image processing apparatus 500 including a first determination unit 501, a second determination unit 502, and an image processing unit 503. The first determining unit 501 is configured to determine a dark channel value and a bright channel value of the image to be processed based on color values of pixels of the image to be processed, where the bright channel value and the dark channel value are used for indicating the brightness of the image to be processed; a second determination unit 502 configured to determine an offset amount to process the image to be processed based on the determined bright channel value and dark channel value; an image processing unit 503 configured to adjust pixel values of the image to be processed based on the determined offset amount, resulting in a processed image.
In the present embodiment, in the image processing apparatus 500: the specific processing of the first determining unit 501, the second determining unit 502 and the image processing unit 503 and the technical effects thereof can refer to the related descriptions of step 201, step 202 and step 203 in the corresponding embodiment of fig. 2, which are not repeated herein.
In some optional implementations of this embodiment, the first determining unit 501 is further configured to: dividing an image to be processed into a preset number of blocks, wherein each block in the preset number of blocks comprises a preset number of pixels; determining the minimum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined minimum color values in each block, and determining the obtained summation result as the dark channel value of the image to be processed.
In some optional implementations of this embodiment, the first determining unit 501 is further configured to: determining the maximum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks; and summing the determined maximum color values in each block, and determining the obtained summation result as the bright channel value of the image to be processed.
In some optional implementations of the present embodiment, the second determining unit 502 is further configured to: determining the ratio of the bright channel value to the dark channel value; and determining the offset based on the ratio, the preset ratio of the bright channel to the dark channel and the dark channel value.
In some optional implementations of the present embodiment, each of the predetermined number of blocks includes one pixel.
In some optional implementations of the embodiment, the preset ratio of the bright channel to the dark channel is determined based on a ratio of a bright channel value and a dark channel value of the historical sample image in the historical sample image set.
The image processing device provided by the embodiment of the disclosure determines the offset of processing the image to be processed by determining the dark channel value and the bright channel value of the image to be processed, and finally adjusts the pixel value of the image to be processed by the determined offset to obtain the processed image, so that the color of the image to be processed can be adjusted, or defogging and shadow removing processing can be performed on the image with fog or the image with heavy shadow in the shot image, thereby improving the image imaging quality.
Referring now to FIG. 6, a schematic diagram of an electronic device (e.g., the server of FIG. 1) 600 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the use range of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 6 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A 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 of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport 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: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be included in the terminal device; or may exist separately without being assembled into the terminal device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: determining a dark channel value and a bright channel value of the image to be processed based on color values of pixels of the image to be processed, wherein the bright channel value and the dark channel value are used for indicating the brightness of the image to be processed; determining an offset for adjusting the color value of the image to be processed based on the determined bright channel value and the dark channel value; and adjusting the pixel value of the image to be processed based on the determined offset to obtain a processed image.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a processor including a first determining unit, a second determining unit, and an image processing unit. Here, the names of the cells do not constitute a limitation of the cell itself in some cases, and for example, the first determination unit may also be described as "a cell that determines a dark channel value and a light channel value of an image to be processed based on color values of pixels of the image to be processed".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (12)

1. An image processing method comprising:
determining a dark channel value and a bright channel value of an image to be processed based on color values of pixels of the image to be processed, wherein the bright channel value and the dark channel value are used for indicating the brightness of the image to be processed;
determining an offset for adjusting the color value of the image to be processed based on the determined bright channel value and the dark channel value;
adjusting the pixel value of the image to be processed based on the determined offset to obtain a processed image;
wherein, the determining the offset of the color value adjustment of the image to be processed based on the determined bright channel value and the dark channel value comprises:
determining a ratio of the bright channel value to the dark channel value;
determining the offset based on the ratio, a preset ratio of a bright channel to a dark channel and the dark channel value;
wherein the determining the offset based on the ratio, a preset ratio of a bright channel to a dark channel, and the dark channel value comprises:
determining a difference between the ratio and the ratio of the preset bright channel to the dark channel; multiplying the difference by the dark channel value; subtracting one from the ratio of the preset bright channel to the preset dark channel, and then multiplying the subtracted value by the number of blocks divided by the image to be processed or the total number of pixels of the image to be processed to obtain a second value; determining a quotient of a result of multiplying the difference by the dark channel value and the second value as the offset.
2. The method of claim 1, wherein determining dark channel values for the image to be processed comprises:
dividing the image to be processed into a preset number of blocks, wherein each block in the preset number of blocks comprises a preset number of pixels;
determining the minimum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks;
and summing the minimum color values in the determined blocks, and determining the obtained summation result as the dark channel value of the image to be processed.
3. The method of claim 2, wherein determining a bright channel value for the image to be processed comprises:
determining the maximum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks;
and summing the determined maximum color values in each block, and determining the obtained summation result as the bright channel value of the image to be processed.
4. The method of claim 2, wherein each of the predetermined number of blocks comprises one pixel.
5. The method of claim 1, wherein the predetermined ratio of bright to dark channels is determined based on a ratio of bright to dark channel values of historical sample images in the set of historical sample images.
6. An image processing apparatus comprising:
a first determination unit configured to determine a dark channel value and a bright channel value of an image to be processed based on color values of pixels of the image to be processed, wherein the bright channel value and the dark channel value are used for indicating the brightness of the image to be processed;
a second determination unit configured to determine an offset amount for performing color value adjustment on the image to be processed based on the determined bright channel value and dark channel value;
an image processing unit configured to adjust pixel values of an image to be processed based on the determined offset, resulting in a processed image;
wherein the second determination unit is further configured to:
determining a ratio of the bright channel value to the dark channel value;
determining the offset based on the ratio, a preset ratio of a bright channel to a dark channel and the dark channel value;
the second determination unit is further configured to:
determining a difference between the ratio and the ratio of the preset bright channel to the dark channel; multiplying the difference by the dark channel value; subtracting one from the ratio of the preset bright channel to the preset dark channel, and then multiplying the subtracted value by the number of blocks divided by the image to be processed or the total number of pixels of the image to be processed to obtain a second value; determining a quotient of a result of multiplying the difference by the dark channel value and the second value as the offset.
7. The apparatus of claim 6, wherein the first determining unit is further configured to:
dividing the image to be processed into a preset number of blocks, wherein each block in the preset number of blocks comprises a preset number of pixels;
determining the minimum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks;
and summing the minimum color values in the determined blocks, and determining the obtained summation result as the dark channel value of the image to be processed.
8. The apparatus of claim 7, wherein the first determining unit is further configured to:
determining the maximum color value in the ternary color values of the pixels included in the block for the blocks in the preset number of blocks;
and summing the determined maximum color values in each block, and determining the obtained summation result as the bright channel value of the image to be processed.
9. The apparatus of claim 7, wherein each of the preset number of blocks comprises one pixel.
10. The apparatus of claim 6, wherein the predetermined ratio of bright to dark channels is determined based on a ratio of bright to dark channel values of historical sample images in the set of historical sample images.
11. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
12. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201910375766.0A 2019-05-07 2019-05-07 Image processing method and device Active CN110097520B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910375766.0A CN110097520B (en) 2019-05-07 2019-05-07 Image processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910375766.0A CN110097520B (en) 2019-05-07 2019-05-07 Image processing method and device

Publications (2)

Publication Number Publication Date
CN110097520A CN110097520A (en) 2019-08-06
CN110097520B true CN110097520B (en) 2021-09-14

Family

ID=67447139

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910375766.0A Active CN110097520B (en) 2019-05-07 2019-05-07 Image processing method and device

Country Status (1)

Country Link
CN (1) CN110097520B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110473282B (en) * 2019-08-22 2021-04-20 腾讯科技(深圳)有限公司 Dyeing processing method and device for object model, computer equipment and storage medium
CN111064963A (en) * 2019-11-11 2020-04-24 北京迈格威科技有限公司 Image data decoding method, device, computer equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103020920B (en) * 2013-01-10 2015-03-25 厦门大学 Method for enhancing low-illumination images
CN103077504B (en) * 2013-01-10 2015-08-05 厦门大学 A kind of image defogging method capable based on self-adaptation illumination calculation
CN107527325B (en) * 2017-08-15 2020-12-18 沈阳海润机器人有限公司 Monocular underwater vision enhancement method based on dark channel priority

Also Published As

Publication number Publication date
CN110097520A (en) 2019-08-06

Similar Documents

Publication Publication Date Title
CN110378846B (en) Method, device, medium and electronic equipment for processing image buffing
CN111260601B (en) Image fusion method and device, readable medium and electronic equipment
CN113962859B (en) Panorama generation method, device, equipment and medium
CN111080595A (en) Image processing method, image processing device, electronic equipment and computer readable medium
CN110211030B (en) Image generation method and device
CN113473035A (en) Ambient brightness determination method and device and electronic equipment
CN111385484B (en) Information processing method and device
CN109102484B (en) Method and apparatus for processing image
CN111757100B (en) Method and device for determining camera motion variation, electronic equipment and medium
CN110097520B (en) Image processing method and device
CN110719407A (en) Picture beautifying method, device, equipment and storage medium
CN111738950B (en) Image processing method and device
CN112465940B (en) Image rendering method and device, electronic equipment and storage medium
CN111369472B (en) Image defogging method and device, electronic equipment and medium
CN110636331B (en) Method and apparatus for processing video
CN112312200A (en) Video cover generation method and device and electronic equipment
CN112241941B (en) Method, apparatus, device and computer readable medium for acquiring image
CN113256785B (en) Image processing method, apparatus, device and medium
CN110399802A (en) Handle method, apparatus, medium and the electronic equipment of the brightness of face-image eyes
CN110555799A (en) Method and apparatus for processing video
CN112804469B (en) Video call processing method, device, equipment and storage medium
CN114049275A (en) Image processing method and device, electronic equipment and storage medium
CN111756954B (en) Image processing method, image processing device, electronic equipment and computer readable medium
CN112804457B (en) Photographing parameter determination method and device and electronic equipment
US20240095882A1 (en) Image processing method and apparatus, electronic device and medium

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