Image processing method and device, storage medium and computer program product
By adjusting and correcting the initial image acquired by the image acquisition device and re-rendering the image, the problem of large amount of calculation and difficult parameter selection of Retinex technology is solved, and image quality is improved and real-time processing is achieved.
Patent Information
- Application Number
- CN202411513476.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-03
AI Technical Summary
The existing Retinex technology has a large amount of calculation in image processing and a long processing time, making it difficult to meet real-time requirements. Inappropriate parameter selection may lead to image distortion and loss of details, and cannot effectively improve image quality.
By acquiring the initial image captured by the image acquisition device, adjust the brightness based on the grayscale value of the pixel point, convert it to the HSV format, and correct it, and finally re-render the image to improve the saturation, chromaticity and brightness of the image and reduce the image. Image data processing volume to avoid color space switching.
It significantly improves the overall quality of the image, improves the saturation, chromaticity and brightness of the image, meets the real-time requirements, and solves the problem of poor image quality in image processing.
Smart Images

Figure CN119255120A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to an image processing method and device, a storage medium, and a computer program product. Background Art
[0002] At present, cameras are increasingly used in monitoring systems, smart phones, autonomous driving and other fields, and different fields have different requirements for the image quality of camera-captured images. In practical applications, cameras are often affected by various factors when capturing images, which not only affects the image quality of the captured images, but also affects the subsequent image processing and analysis. For example, in low-light environments, images will become dim, blurred, and details will be lost; under complex lighting conditions, images may have problems such as shadows, highlights, and insufficient contrast.
[0003] In order to solve the above problems, relevant technicians proposed the Retinex technology, whose basic idea is to first perform Gaussian filtering on the image to obtain the illumination component; then divide the original image by the illumination component to obtain the reflection component; finally, enhance the reflection component, such as histogram equalization, contrast stretching, etc., to obtain the enhanced image. However, although the Retinex technology has certain advantages in image enhancement, there are still some problems in practical applications. For example, the Retinex technology requires multiple filtering and calculations on the image, which has a large amount of calculation and a long processing time, making it difficult to meet the real-time requirements; in addition, the parameter selection of the Retinex technology has a great influence on the enhancement effect. If the parameters are not selected properly, it may cause image distortion, loss of details and other problems.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide an image processing method and device, a storage medium, and a computer program product to at least solve the technical problem that the related image processing technology directly adjusts the RGB color value of each pixel in the image, resulting in poor quality of the processed image.
[0006] According to one aspect of an embodiment of the present application, an image processing method is provided, including: obtaining an initial image of a target area captured by an image acquisition device, wherein the initial image includes a plurality of pixels and the grayscale value of each pixel is a grayscale value; adjusting the brightness of the initial image based on the grayscale values of each pixel in the initial image, and determining a first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in an HSV format; correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in an RGB format; and re-rendering the initial image based on the target color values of the plurality of pixels to obtain a rendered target image.
[0007] Optionally, the brightness of the initial image is adjusted based on the grayscale value of each pixel in the initial image, and the first color value of each pixel in the initial image after the brightness adjustment is determined, including: dividing the initial image into multiple sub-images; for each sub-image, adjusting the brightness of the sub-image according to the grayscale value of each pixel in the sub-image, and determining the second color value of each pixel in the sub-image after the brightness adjustment, wherein the second color value is in RGB format; and determining the first color value of each pixel in the sub-image after the brightness adjustment based on the second color value of each pixel in the sub-image after the brightness adjustment.
[0008] Optionally, the brightness of the initial image is adjusted based on the grayscale value of each pixel in the initial image, and the first color value of each pixel in the initial image after the brightness adjustment is determined, including: dividing the initial image into multiple sub-images; for each sub-image, adjusting the brightness of the sub-image according to the grayscale value of each pixel in the sub-image, and determining the second color value of each pixel in the sub-image after the brightness adjustment, wherein the second color value is in RGB format; and determining the first color value of each pixel in the sub-image after the brightness adjustment based on the second color value of each pixel in the sub-image after the brightness adjustment.
[0009] Optionally, the brightness of the sub-image is adjusted according to the grayscale value of each pixel in the sub-image, and the second color value of each pixel in the sub-image after the brightness adjustment is determined, including: determining the brightness adjustment coefficient of the sub-image to be adjusted based on the average grayscale value of the sub-image; for each pixel in the sub-image to be adjusted, using the brightness adjustment coefficient to adjust the grayscale value of the pixel, and determining the second color value of the pixel after the brightness adjustment, wherein the second color value is in RGB format.
[0010] Optionally, determining the first color value of each pixel in the sub-image after brightness adjustment based on the second color value of each pixel in the sub-image after brightness adjustment includes: determining that each color component in the second color value of each pixel in the sub-image is normalized; for each pixel in the sub-image, determining a first mapping relationship between the normalized second color value and the HSV format color value based on a size relationship between each color component in the second color value after normalization; and determining, based on the first mapping relationship, that the HSV format color value corresponding to the normalized second color value is the first color value.
[0011] Optionally, the first color value of each pixel in the initial image is corrected to obtain the target color value of each pixel, including: for each pixel in the initial image, the first color value of the pixel is corrected to obtain a corrected first color value, wherein the first color value includes: a chroma component, a saturation component, and a brightness component; based on the size relationship among the chroma component, the saturation component, and the brightness component in the adjusted first color value, a second mapping relationship between the corrected first color value and the RGB format color value is determined; based on the second mapping relationship, the RGB format color value corresponding to the corrected first color value is determined as the target color value of the pixel.
[0012] Optionally, correcting the first color value of the pixel to obtain a corrected first color value includes: using a Retinex algorithm to correct the chromaticity component of the pixel according to the following formula to obtain a corrected chromaticity component:
[0013] V ′ (x,y)=e R(x,y) -1
[0014] Where V ′ (x,y) represents the chromaticity component of the pixel (x,y) after correction, R(x,y) represents the reflection component of the pixel (x,y), and its expression can be written as: R(x,y)=Log(V(x,y)+1)(1-G(x,y)), and G(x,y) is the Gaussian kernel function of the pixel (x,y), and V(x,y) represents the chromaticity component of the pixel (x,y) before correction; the first adjustment parameter is determined according to the gray value of the pixel, and combined with the maximum color component and the minimum color component in the second color value of the pixel, and the saturation component of the pixel is corrected according to the following formula to obtain the corrected saturation component:
[0015]
[0016] In the formula, S ′represents the saturation component of the pixel (x, y) after correction, S represents the saturation component of the pixel (x, y) before correction, K represents the first adjustment parameter, max(R, G, B) represents the maximum color component in the second color value of the pixel (x, y), and min(R, G, B) represents the minimum color component in the second color value of the pixel (x, y); according to the preset reference hue value, the hue component of the pixel is corrected according to the following formula to obtain the corrected hue component:
[0017] H ′ (x,y)=[H(x,y)+(H target (x,y)-H(x,y))*t+mod360
[0018] In the formula, H ′ (x, y) represents the hue component of the pixel (x, y) after correction, H(x, y) represents the hue component of the pixel (x, y) before correction, and H target (x, y) represents the reference hue component of the pixel point (x, y), t represents the second adjustment parameter, and the second adjustment parameter t is composed of H target Determined by (x,y)-H(x,y).
[0019] According to another aspect of an embodiment of the present application, an image processing device is also provided, including: an acquisition module, used to acquire an initial image of a target area captured by an image acquisition device, wherein the initial image includes multiple pixels and the grayscale value of each pixel is a grayscale value; an adjustment module, used to adjust the brightness of the initial image based on the grayscale values of each pixel in the initial image, and determine the first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format; an adjustment module, used to correct the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format; a rendering module, used to re-render the initial image based on the target color values of multiple pixels to obtain a rendered target image.
[0020] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned image processing method by running the computer program.
[0021] According to another aspect of an embodiment of the present application, a computer program product is further provided. The computer program product includes a stored computer program, wherein the computer program implements the above-mentioned image processing method when executed by a processor.
[0022] In an embodiment of the present application, an initial image of a target area captured by an image acquisition device is obtained, wherein the initial image includes a plurality of pixels, and the grayscale value of each pixel is a grayscale value; the brightness of the initial image is adjusted based on the grayscale values of each pixel in the initial image, and a first color value of each pixel in the initial image after the brightness adjustment is determined, wherein the first color value is in HSV format; the first color value of each pixel in the initial image is corrected to obtain a target color value of each pixel, wherein the target color value is in RGB format; the initial image is re-rendered based on the target color values of the plurality of pixels to obtain a rendered target image. Among them, by adjusting the brightness of the sub-image according to the grayscale value of each pixel in the sub-image, it is unnecessary to switch between color spaces during the brightness adjustment process, which greatly reduces the image data processing amount; in addition, by adjusting each component of the HSV color value of each pixel in each sub-image in the initial image, and converting the adjusted HSV color value into the target color value in RGB format, the initial image is re-rendered by the target color value of each pixel to obtain an enhanced target image. Compared with the initial image, the final target image has improved overall saturation, chroma, and brightness, greatly improving the image quality. This solves the technical problem that the related image processing technology directly adjusts the RGB color value of each pixel in the image, resulting in poor quality of the processed image. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0024] Figure 1 It is a hardware structure block diagram of an optional computer terminal (or mobile device) for implementing the image processing method according to an embodiment of the present application;
[0025] Figure 2 is a flowchart of an optional image processing method according to an embodiment of the present application;
[0026] Figure 3 is a schematic structural diagram of an optional image processing device according to an embodiment of the present application;
[0027] Figure 4 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] In addition, the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set up between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0031] Example 1
[0032] According to an embodiment of the present application, a method embodiment of an image processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0033] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing an image processing method. Figure 1As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0034] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0035] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the image processing method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the image processing method of the above-mentioned application is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0036] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0037] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0038] In the above operating environment, Figure 2 is a flow chart of an optional image processing method according to an embodiment of the present application, such as Figure 2 As shown, the method at least includes steps S202-S206, wherein:
[0039] Step S202: acquiring an initial image of the target area captured by an image acquisition device.
[0040] In the technical solution provided in step S202, the above-mentioned image acquisition device is a hardware device capable of capturing images, generally including various types of digital cameras, video cameras, scanners, cameras carried by drones, etc.; the above-mentioned target area refers to a specific area or object that the image acquisition device needs to capture, and the selection of the target area depends on the purpose of image acquisition (such as monitoring application scenarios, autonomous driving vehicle scenarios, medical imaging scenarios, etc.), which can be any object, scene or detail within the field of view; and the acquired initial image can be static or dynamic (such as video frame form), and its format can be JPEG, PNG, BMP, TIFF, etc., in addition, the initial image includes a pixel array, and each pixel represents a color value or grayscale value in RGB format of a point in the initial image (L=0.299R+0.587G+0.114B, where R, G, and B are component values of the R, G, and B color channels of the pixel point, respectively), wherein the grayscale value of each pixel point in the initial image is recorded as a grayscale value in the embodiment of the present application.
[0041] Step S204: adjusting the brightness of the initial image based on the grayscale value of each pixel in the initial image, and determining a first color value of each pixel in the initial image after the brightness adjustment.
[0042] In the technical solution provided in step S204, it is considered that the initial image may be collected under different lighting conditions. Therefore, in order to make the initial image clearer and more intuitive, the brightness information of the initial image can be processed separately first. The grayscale value refers to the brightness level of the pixel in the image, so the embodiment of the present application can adjust the brightness of the initial image by the grayscale value of each pixel in the initial image. Among them, the grayscale value can be a value between 0 and 255 (in an 8-bit image), where 0 represents black, 255 represents white, and other values represent different degrees of gray. In addition, considering that the initial image needs to be additionally enhanced later, in order to facilitate the overall processing of the image, the initial image can be mapped from the RGB color space to the HSV color space to determine the first color value of each pixel in the initial image in the HSV format after brightness adjustment.
[0043] As an optional implementation, in the technical solution provided in the above step S204, the method may include:
[0044] Step S2041, dividing the initial image into multiple sub-images.
[0045] Considering that in real environments, the illumination is often not completely uniform, so different sub-images in the target area captured by the image acquisition device receive different light intensities; in addition, considering the inherent properties of different objects or areas, such as color, material (reflectivity) and shape, brightness differences will also occur. Therefore, the brightness of different positions on the initial image is different. In order to make adaptive adjustments for different brightness, the initial image can be divided into multiple sub-images. The size of each sub-image can be the same or different, and can be set according to the actual application scenario. For example, if the initial image is a 1000x1000 pixel image, the initial image can be divided into 100 sub-images of 100x100 pixels.
[0046] Step S2042: for each sub-image, adjust the brightness of the sub-image according to the grayscale value of each pixel in the sub-image, and determine the second color value of each pixel in the sub-image after the brightness adjustment.
[0047] Optionally, since the multiple sub-images in the initial image may include sub-images whose brightness is to be adjusted and sub-images whose brightness does not need to be adjusted, in order to reduce the computing resources occupied by image processing and improve image processing efficiency, before the brightness of the sub-image is adjusted according to the grayscale value of each pixel in the sub-image, the sub-image to be adjusted can be firstly screened out from the multiple sub-images in the initial image through the following steps, including:
[0048] First, the average gray value of the sub-image is determined based on the gray value of each pixel in the sub-image;
[0049] Then, the magnitude relationship between the average grayscale value and a preset grayscale threshold is determined, wherein the grayscale threshold includes: a low brightness grayscale threshold and a high brightness grayscale threshold;
[0050] When the average grayscale value is less than the low brightness grayscale threshold, or the average grayscale value is greater than the high brightness grayscale threshold, the sub-image is determined to be the sub-image to be adjusted.
[0051] In the above screening process, the relationship between the average grayscale value of the sub-image and the low brightness grayscale threshold can be determined, where: if the average grayscale value is less than the low brightness grayscale threshold, it means that the sub-image is a low brightness image, so the brightness of the area needs to be increased; and when the average grayscale value is greater than the low brightness grayscale threshold, it is determined whether the average grayscale value is greater than the high brightness grayscale threshold. If the average grayscale value is greater than the high brightness grayscale threshold, it means that the sub-image is a high brightness image, so the brightness of the area needs to be reduced; when the average grayscale value is greater than the low brightness grayscale threshold and less than the high brightness grayscale threshold, it means that the sub-image is a normal brightness image, and no additional brightness adjustment is required. It should be noted that the above comparison process is only an example, and the average grayscale value of each sub-image can also be compared with the high brightness grayscale threshold and the low brightness grayscale threshold separately, or the high brightness grayscale threshold can be compared first and then the low brightness grayscale threshold.
[0052] Furthermore, for the sub-image to be adjusted selected above, the brightness of the sub-image can be adjusted according to the following steps, and the specific implementation method of determining the second color value of each pixel in the sub-image after the brightness adjustment includes:
[0053] First, a brightness adjustment coefficient of the sub-image to be adjusted is determined based on the average grayscale value of the sub-image.
[0054] Among them, the above-mentioned brightness adjustment coefficient can be a parameter related to the average grayscale value, such as a gain coefficient that is inversely proportional to the average grayscale value (that is, when the average grayscale value of the sub-image is low, the gain coefficient will be larger, thereby increasing the brightness; conversely, if the average grayscale value is high, the gain coefficient will be smaller to avoid overexposure), or a numerical value of an inverse relationship, or a certain function based on the average grayscale value.
[0055] Then, for each pixel point in the sub-image to be adjusted, the grayscale value of the pixel point is brightness adjusted using the brightness adjustment coefficient, and the second color value of the pixel point after the brightness adjustment is determined.
[0056] The brightness condition can be understood as applying a brightness adjustment coefficient to modify the RGB color value of each pixel, which can usually be achieved through an improved gamma function, a linear transformation formula, etc. Taking the linear transformation formula as an example, the grayscale value after brightness adjustment can be determined according to the following formula:
[0057] g(i,j)=af(i,j)+b
[0058] Wherein g(i,j) represents the gray value of the pixel (i,j) after brightness adjustment, f(i,j) represents the initial gray value of the pixel (i,j), a represents the brightness adjustment coefficient, and b represents the brightness offset, wherein the brightness offset b can be the difference between the average gray value and the average gray value of the normal sub-image. For example, if the average gray value of the sub-image to be adjusted is low, the difference between the average gray value and the average gray value of the normal sub-image can be used as the positive offset of the brightness offset b to increase the brightness of the sub-image; and if the average gray value of the sub-image to be adjusted is high, the difference between the average gray value and the average gray value of the normal sub-image can be used as the negative offset of the brightness offset b to reduce the brightness of the sub-image.
[0059] Furthermore, the second color value in RGB format after brightness adjustment is determined according to the grayscale value of each pixel after brightness adjustment. The specific method includes but is not limited to:
[0060] (1) Direct mapping: The grayscale value after brightness adjustment is directly mapped to the three RGB color channels. In this case, the grayscale value after brightness adjustment is equal to the second color value in RGB format.
[0061] (2) Gamma correction: The second color value is obtained according to the following formula: Where L represents the gray value of the pixel after brightness adjustment, L MAX Indicates the maximum grayscale value of all pixels in the sub-image after brightness adjustment.
[0062] Generally, the brightness value of the color value in RGB format is determined by the three values of R, G, and B. There is no single brightness value extracted in the RGB color space. It can be understood that the color value and the brightness value are mixed together. In this case, adjusting the brightness requires adjusting the overall color value. Generally, the image can be mapped from the RGB color space to the HSV color space, and then the brightness is adjusted by modifying the chromaticity (V) value of the pixel point, and then mapped back from the HSV color space to the RGB color space to adjust the image brightness. The present application uses the grayscale value to correct the brightness of the initial image. The entire process does not need to be converted to the HSV space. The image brightness can be adjusted directly in the RGB format to prevent the overall image from being too dark or too bright, thereby achieving a better display effect.
[0063] Step S2043: determining the first color value of each pixel in the sub-image after the brightness is adjusted based on the second color value of each pixel in the sub-image after the brightness is adjusted.
[0064] In order to facilitate subsequent enhancement processing of each pixel in the image, the second color value in RGB format of each pixel in the initial image can be converted into the first color value in HSV format, that is, the color space of the initial image is converted from RGB color space to HSV color space.
[0065] Optionally, the implementation process of converting the second color value in RGB format into the first color value in HSV format includes:
[0066] Step 1: determine each color component in the second color value of each pixel in the sub-image and perform normalization processing;
[0067] Step 2: for each pixel in the sub-image, according to the size relationship between each color component in the normalized second color value, determine a first mapping relationship between the normalized second color value and the HSV format color value;
[0068] Step 3: According to the first mapping relationship, determine the HSV format color value corresponding to the normalized second color value as the first color value.
[0069] Specifically, let (R, G, B) be the second color value of a pixel in an initial image, where R, G, B are the red, green, and blue channel components of the pixel, respectively; let max be equal to the maximum of R, G, and B of the pixel, and let min be equal to the minimum of R, G, and B of the pixel. The first color value of a pixel in the HSV color space can be expressed as (H, S, V), where H, S, and V values represent the hue (H), saturation (S), and brightness (V) of the pixel, respectively; to find the (H, S, V) value in the HSV color space, the conversion formula can be as follows:
[0070]
[0071] V=max
[0072] Among them, the color value in RGB format, its brightness value is determined by the three values of R, G, and B. There is no single brightness value extracted in the RGB color space. It can be understood that the color value and the brightness value are mixed together. However, when the color space can be converted to HSV through the above formula, its brightness value only needs a V value to represent, so it can better distinguish the color value and brightness value of the pixel.
[0073] Finally, the above formula can be used to calculate the H, S, and V values of any pixel in the initial image to obtain the first color value of each pixel in HSV format. It should be noted that for the sub-area where the brightness is not adjusted, the initial color value in RGB format (that is, the original RGB color value) of each pixel in the sub-area can be used to calculate its first color value in HSV format.
[0074] Step S206, correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel.
[0075] In the technical solution provided in step S206, in order to enhance the initial image, it is necessary to further correct the second color value of each pixel in the initial image so that the image quality of the initial image is further improved. In addition, after the correction processing is performed using the first color value in HSV format, it is necessary to convert the color value in HSV format into a color value in RGB format to obtain the target color value of each pixel.
[0076] As an optional implementation, in the technical solution provided in the above step S206, for each pixel in the initial image, the corrected target color value can be obtained by the following steps, including:
[0077] Step S2061, correcting the first color value of the pixel to obtain a corrected first color value, wherein the first color value includes: a chroma component, a saturation component, and a brightness component.
[0078] Specifically, for each component in the first color value, it can be adjusted as follows:
[0079] The Retinex algorithm is used to correct the chromaticity component of the pixel according to the following formula to obtain the corrected chromaticity component:
[0080] V ′ (x,y)=e R(x,y) -1
[0081] Where V ′ (x,y) represents the chromaticity component of the pixel (x,y) after correction, R(x,y) represents the reflection component of the pixel (x,y), and its expression can be written as: R(x,y)=Log(V(x,y)+1)(1-G(x,y)), and G(x,y) is the Gaussian kernel function of the pixel (x,y), and V(x,y) represents the chromaticity component of the pixel (x,y) before correction;
[0082] The first adjustment parameter is determined according to the gray value of the pixel, and the maximum color component and the minimum color component in the second color value of the pixel are combined, and the saturation component of the pixel is corrected according to the following formula to obtain a corrected saturation component:
[0083]
[0084] In the formula, S ′ represents the saturation component of the pixel (x, y) after correction, S represents the saturation component of the pixel (x, y) before correction, K represents the first adjustment parameter, max(R, G, B) represents the maximum color component in the second color value of the pixel (x, y), and min(R, G, B) represents the minimum color component in the second color value of the pixel (x, y);
[0085] According to the preset reference hue value, the hue component of the pixel is corrected according to the following formula to obtain the corrected hue component:
[0086] H ′ (x,y)=[H(x,y)+(H target (x,y)-H(x,y))*t+mod360
[0087] In the formula, H ′ (x, y) represents the hue component of the pixel (x, y) after correction, H(x, y) represents the hue component of the pixel (x, y) before correction, and H target (x, y) represents the reference hue component of the pixel point (x, y), t represents the second adjustment parameter, and the second adjustment parameter t is composed of H target (x,y)-H(x,y).
[0088] The range of H determined above is usually 0 to 360 degrees, and the range of S and V is usually 1.
[0089] Step S2062, determining a second mapping relationship between the modified first color value and the RGB format color value according to the size relationship among the chroma component, the saturation component, and the brightness component in the modified first color value.
[0090] Step S2063 , determining, according to the second mapping relationship, the RGB format color value corresponding to the corrected first color value as the target color value.
[0091] Specifically, the second mapping relationship may be preset, wherein the second mapping relationship may include the following calculation formula:
[0092] The chrominance component H calculated above ′Divided into 6 intervals, each interval corresponds to a primary color: red, yellow, green, cyan, blue, and magenta, then the intermediate variables can be expressed as:
[0093]
[0094] P=V ′ *(1-S ′ )
[0095] Q=V ′ *(1-f*S ′ )
[0096] T=V ′ *(1-(1-f)*S ′ )
[0097] Next, determine the corresponding RGB color value according to different chromaticity intervals:
[0098]
[0099] Step S208 , re-rendering the initial image based on the target color values of the plurality of pixels to obtain a rendered target image.
[0100] In the technical solution provided in step S208, the target color values of a plurality of pixels in the initial image are used to re-render the image to obtain a rendered target image.
[0101] Based on the scheme defined by the above steps S202 to S208, it can be known that in an embodiment, the average grayscale value of each sub-image in the initial image is analyzed to screen out the sub-image to be adjusted from multiple sub-images, and the brightness of the sub-image to be adjusted is adjusted according to the grayscale value of each pixel in the sub-image to be adjusted, so that there is no need to process all the sub-images, which greatly reduces the image data processing volume, and there is no need to switch between color spaces during the brightness adjustment process; then, each component of the HSV color value of the pixel in each sub-image in the initial image is adjusted respectively, and the adjusted HSV color value is converted into a target color value in RGB format, and the initial image is re-rendered according to the target color value of each pixel to obtain a rendered target image. Therefore, compared with the initial image, the overall saturation, chroma, and brightness of the target image are improved, thereby greatly improving the image quality.
[0102] Example 2
[0103] Based on Embodiment 1 of the present application, an embodiment of an image processing device is also provided, and the image processing method of the above embodiment is executed when the device is running. Figure 3 is a schematic diagram of the structure of an optional image processing device according to an embodiment of the present application, such as Figure 3 As shown, the image processing device at least includes an acquisition module 32, an adjustment module 34, a correction module 36 and a rendering module 38, wherein:
[0104] An acquisition module 32 is used to acquire an initial image of a target area captured by an image acquisition device, wherein the initial image includes a plurality of pixels, and the gray value of each pixel is a gray value;
[0105] An adjustment module 34 is used to adjust the brightness of the initial image based on the grayscale value of each pixel in the initial image, and determine a first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format;
[0106] A correction module 36, used to correct the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format;
[0107] The rendering module 38 is used to re-render the initial image based on the target color values of the plurality of pixels to obtain a rendered target image.
[0108] It should be noted that the various modules in the above-mentioned image processing device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0109] Example 3
[0110] According to an embodiment of the present application, a non-volatile storage medium is further provided, in which a program is stored, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the image processing method in Example 1.
[0111] Optionally, the device where the non-volatile storage medium is located implements the following steps by running the program: obtaining an initial image of the target area captured by the image acquisition device, wherein the initial image includes multiple pixels and the grayscale value of each pixel is a grayscale value; adjusting the brightness of the initial image based on the grayscale values of each pixel in the initial image, and determining the first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format; correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format; and re-rendering the initial image based on the target color values of multiple pixels to obtain a rendered target image.
[0112] According to an embodiment of the present application, a computer program product is also provided. The computer program product includes a stored computer program, wherein the image processing method in Embodiment 1 is implemented when the computer program is executed by a processor.
[0113] Optionally, the computer program executes the following steps: obtaining an initial image of the target area captured by an image acquisition device, wherein the initial image includes multiple pixels and the grayscale value of each pixel is a grayscale value; adjusting the brightness of the initial image based on the grayscale values of each pixel in the initial image, and determining the first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format; correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format; and re-rendering the initial image based on the target color values of multiple pixels to obtain a rendered target image.
[0114] According to an embodiment of the present application, a processor is also provided, which is used to run a program, wherein the image processing method in Example 1 is executed when the program is run.
[0115] Optionally, when the program is running, the following steps are executed: obtaining an initial image of the target area captured by the image acquisition device, wherein the initial image includes multiple pixels and the grayscale value of each pixel is a grayscale value; adjusting the brightness of the initial image based on the grayscale value of each pixel in the initial image, and determining the first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format; correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format; and re-rendering the initial image based on the target color values of multiple pixels to obtain a rendered target image.
[0116] According to an embodiment of the present application, an electronic device is also provided, wherein: Figure 4 is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application, such as Figure 4 As shown, the electronic device includes one or more processors; a memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the image processing method in the above-mentioned embodiment 1 when running.
[0117] Optionally, the processor is configured to execute the following steps through a computer program: obtaining an initial image of the target area captured by the image acquisition device, wherein the initial image includes multiple pixels and the grayscale value of each pixel is a grayscale value; adjusting the brightness of the initial image based on the grayscale values of each pixel in the initial image, and determining the first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format; correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format; and re-rendering the initial image based on the target color values of multiple pixels to obtain a rendered target image.
[0118] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0119] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0120] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0121] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0122] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0124] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. An image processing method, characterized in that: include: Acquire an initial image of a target area captured by an image acquisition device, wherein the initial image includes a plurality of pixels, and the grayscale value of each pixel is a grayscale value; Adjusting the brightness of the initial image based on the grayscale value of each pixel in the initial image, and determining a first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format; Correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format; The initial image is re-rendered based on the target color values of the plurality of pixels to obtain a rendered target image.
2. The method according to claim 1, characterized in that The method comprises: adjusting the brightness of the initial image based on the grayscale value of each pixel in the initial image, and determining a first color value of each pixel in the initial image after the brightness adjustment, including: Dividing the initial image into a plurality of sub-images; For each of the sub-images, adjusting the brightness of the sub-image according to the grayscale value of each pixel in the sub-image, and determining a second color value of each pixel in the sub-image after the brightness adjustment, wherein the second color value is in RGB format; The first color value of each pixel point in the sub-image after brightness adjustment is determined based on the second color value of each pixel point in the sub-image after brightness adjustment.
3. The method according to claim 2, characterized in that Before adjusting the brightness of the sub-image according to the grayscale value of each pixel in the sub-image, the method further includes: Determining an average grayscale value of the sub-image according to the grayscale value of each pixel in the sub-image; Determine the magnitude relationship between the average grayscale value and a preset grayscale threshold, wherein the grayscale threshold includes: a low brightness grayscale threshold and a high brightness grayscale threshold; When the average grayscale value is less than the low brightness grayscale threshold, or the average grayscale value is greater than the high brightness grayscale threshold, the sub-image is determined to be the sub-image to be adjusted.
4. The method according to claim 3, characterized in that The brightness of the sub-image is adjusted according to the grayscale value of each pixel in the sub-image, and a second color value of each pixel in the sub-image after the brightness adjustment is determined, including: Determining a brightness adjustment coefficient of the sub-image to be adjusted based on an average grayscale value of the sub-image; For each pixel in the sub-image to be adjusted, the grayscale value of the pixel is brightness adjusted using the brightness adjustment coefficient, and a second color value of the pixel after the brightness adjustment is determined, wherein the second color value is in RGB format.
5. The method according to claim 2, characterized in that: Determining the first color value of each pixel in the sub-image after brightness adjustment based on the second color value of each pixel in the sub-image after brightness adjustment includes: Determine and normalize each color component in the second color value of each pixel in the sub-image; For each pixel in the sub-image, determining a first mapping relationship between the normalized second color value and the HSV format color value according to a size relationship between each color component in the normalized second color value; According to the first mapping relationship, the HSV format color value corresponding to the second color value after normalization is determined to be the first color value.
6. The method according to claim 1, characterized in that Correcting the first color value of each pixel in the initial image to obtain the target color value of each pixel includes: For each pixel in the initial image, correct the first color value of the pixel to obtain a corrected first color value, wherein the first color value includes: a chroma component, a saturation component, and a brightness component; Determine a second mapping relationship between the modified first color value and the RGB format color value according to the magnitude relationship between the chroma component, the saturation component, and the brightness component in the modified first color value; According to the second mapping relationship, the RGB format color value corresponding to the corrected first color value is determined as the target color value of the pixel.
7. The method according to claim 6, characterized in that Correcting the first color value of the pixel to obtain a corrected first color value includes: The Retinex algorithm is used to correct the chromaticity component of the pixel point according to the following formula to obtain the corrected chromaticity component: V ′ (x,y)=e R(x,y) -1 Where V ′ (x,y) represents the chromaticity component of the pixel (x,y) after correction, R(x,y) represents the reflection component of the pixel (x,y), and its expression can be written as: R(x,y)=Log(V(x,y)+1)(1-G(x,y)), and G(x,y) is the Gaussian kernel function of the pixel (x,y), and V(x,y) represents the chromaticity component of the pixel (x,y) before correction; The first adjustment parameter is determined according to the gray value of the pixel, and the maximum color component and the minimum color component in the second color value of the pixel are combined, and the saturation component of the pixel is corrected according to the following formula to obtain a corrected saturation component: In the formula, S ′ represents the saturation component of the pixel point (x, y) after correction, S represents the saturation component of the pixel point (x, y) before correction, K represents the first adjustment parameter, max(R, G, B) represents the maximum color component in the second color value of the pixel point (x, y), and min(R, G, B) represents the minimum color component in the second color value of the pixel point (x, y); According to the preset reference hue value, the hue component of the pixel point is corrected according to the following formula to obtain a corrected hue component: H ′ (x,y)=[H(x,y)+(H target (x,y)-H(x,y))*t+mod360 In the formula, H ′ (x, y) represents the hue component of the pixel (x, y) after correction, H(x, y) represents the hue component of the pixel (x, y) before correction, and H target (x, y) represents the reference hue component of the pixel point (x, y), t represents the second adjustment parameter, and the second adjustment parameter t is composed of H target Determined by (x,y)-H(x,y).
8. An image processing device, characterized in that: include: An acquisition module, used for acquiring an initial image of a target area captured by an image acquisition device, wherein the initial image includes a plurality of pixels, and the grayscale value of each pixel is a grayscale value; an adjustment module, configured to adjust the brightness of the initial image based on the grayscale value of each pixel in the initial image, and determine a first color value of each pixel in the initial image after the brightness adjustment, wherein the first color value is in HSV format; A correction module, used for correcting the first color value of each pixel in the initial image to obtain a target color value of each pixel, wherein the target color value is in RGB format; A rendering module is used to re-render the initial image based on the target color values of the multiple pixels to obtain a rendered target image.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, wherein the device where the non-volatile storage medium is located executes the image processing method according to any one of claims 1 to 7 by running the computer program.
10. A computer program product, characterized in that include: A computer program, wherein when the computer program is executed by a processor, the image processing method according to any one of claims 1 to 7 is implemented.
