Image processing method and device, electronic equipment and storage medium
By exponential transformation and convolutional filtering on the image, the light spot effect with preset shapes is generated, which solves the problem that traditional mobile phone cameras are difficult to achieve high-end camera bokeh effects, and improves the robustness and artistic value of image processing.
Patent Information
- Application Number
- CN202411201572.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-12-03
AI Technical Summary
Traditional mobile phone cameras are difficult to achieve the bokeh effect of high-end cameras at the hardware level, and spot detection errors will affect image quality.
By exponential transformation and convolutional filtering processing on the image to be processed, a preset spot effect is generated, and the entire image is directly processed to avoid spot detection errors.
It improves the robustness of image processing, generates natural and robust spot effects, and enhances the artistic value of photos.
Smart Images

Figure CN119067901A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art
[0002] When high-end SLR cameras and lenses take photos with a shallow depth of field, the out-of-focus highlight area will form a certain shape of light spot (also called "blurred light spot" or "bokeh"). Many users like to take high-quality, artistic photos with their mobile phones, but it is difficult for traditional mobile phone cameras to achieve the bokeh effect of high-end cameras at the hardware level. In related technologies, light spot detection can be used to detect the highlight light spots in the image, and then the detected light spots are filtered through the aperture blur operation to form a light spot effect. However, this method of first detecting and then filtering will encounter some problems. For example, incorrect light spot detection will lead to unsatisfactory light spot effect, thus affecting the overall image quality. Summary of the invention
[0003] The present application provides an image processing method, device, electronic device and storage medium to solve the technical problem of how to generate a natural light spot effect through image processing.
[0004] In a first aspect, the present application provides an image processing method, the method comprising:
[0005] Acquire an image to be processed; wherein the image to be processed includes at least one highlight area, and the ratio of the current first brightness of the highlight area to the current second brightness of other areas except all the highlight areas is greater than a first threshold; and the first threshold is greater than one;
[0006] Performing exponential transformation processing on the image to be processed to obtain a transformed image; wherein, in the transformed image, a ratio of the current third brightness of the highlight area to the current fourth brightness of the other areas is greater than a second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; and the second threshold is greater than the first threshold;
[0007] Using a filter of a preset shape to perform convolution filtering on the transformed image, so as to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape;
[0008] Performing logarithmic transformation processing on the filtered image to obtain a processed image; wherein the difference between the brightness of the other areas of the processed image and the first brightness is less than a third threshold.
[0009] Optionally, performing exponential transformation on the image to be processed to obtain a transformed image includes:
[0010] Get the weight information of exponential transformation;
[0011] According to the weight information, exponential transformation processing is performed on the highlight area and the other areas of the image to be processed respectively to obtain the transformed image.
[0012] Optionally, performing exponential transformation processing on the highlight area and the other areas of the image to be processed respectively according to the weight information to obtain the transformed image includes:
[0013] Acquire information of each pixel point contained in the highlight area and other areas of the image to be processed;
[0014] Performing exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information;
[0015] The transformed image is determined according to all the transformed data.
[0016] Optionally, performing exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information includes:
[0017] Performing pixel normalization on the pixel point information to obtain normalized target data;
[0018] The target data is subjected to exponential transformation processing according to the weight information to obtain the transformation data corresponding to the pixel point information.
[0019] Optionally, obtaining an image to be processed includes:
[0020] Get the input image;
[0021] Converting the input image into a double-precision image;
[0022] The double-precision image is used as the image to be processed.
[0023] Optionally, using a filter of a preset shape to perform convolution filtering on the transformed image to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape, comprises:
[0024] Using a filter of a preset shape to perform convolution filtering on the highlight area of the transformed image, to obtain a first filtered image that converts the highlight area into a light spot of a preset shape;
[0025] Using a filter of a preset shape to perform convolution filtering on the other regions of the transformed image, to obtain a second filtered image after smoothing the other regions;
[0026] The first filtered image and the second filtered image are used as the filtered images.
[0027] Optionally, before performing convolution filtering on the transformed image using a filter of a preset shape to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape, the method further comprises:
[0028] The filter of the preset shape is configured; wherein the filter of the preset shape includes at least one of a cardioid filter, a star filter, a diamond filter and a circular filter.
[0029] In a second aspect, the present application provides an image processing device, the device comprising:
[0030] An acquisition module, used for acquiring an image to be processed; wherein the image to be processed includes at least one highlight area, and a ratio of a current first brightness of the highlight area to a current second brightness of other areas except the highlight area is greater than a first threshold; and the first threshold is greater than one;
[0031] A first processing module is used to perform exponential transformation processing on the image to be processed to obtain a transformed image; wherein, in the transformed image, the ratio of the current third brightness of the highlight area to the current fourth brightness of the other areas is greater than a second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; and the second threshold is greater than the first threshold;
[0032] A second processing module is used to perform convolution filtering on the transformed image using a filter of a preset shape to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape;
[0033] The third processing module is used to perform logarithmic transformation on the filtered image to obtain a processed image; wherein the difference between the brightness of the other areas of the processed image and the first brightness is less than a third threshold.
[0034] In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0035] Memory, used to store computer programs;
[0036] The processor is used to implement the image processing method described in any embodiment of the first aspect when executing the program stored in the memory.
[0037] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the image processing method as described in any one of the embodiments of the first aspect.
[0038] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application obtains an image to be processed; wherein, the image to be processed includes at least one highlight area, and the ratio of the current first brightness of the highlight area to the current second brightness of other areas except all highlight areas is greater than a first threshold; the first threshold is greater than one; exponential transformation is performed on the image to be processed to obtain a transformed image; wherein, in the transformed image, the ratio of the current third brightness of the highlight area to the current fourth brightness of other areas is greater than the second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; the second threshold is greater than the first threshold; a filter of a preset shape is used to perform convolution filtering on the transformed image to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape; logarithmic transformation is performed on the filtered image to obtain a processed image; wherein the difference between the brightness of other areas of the processed image and the first brightness is less than the third threshold. The method performs exponential transformation on the image to be processed to obtain a transformed image, which can make the brightness of the highlight area in the image higher, and then uses a preset shape filter to perform convolution filtering on the transformed image, so that the entire image is smoothed and the highlight area forms a preset shape of spot effect, and then performs logarithmic transformation on the filtered image to restore the brightness range of the image to a normal range, and at the same time can further enhance the spot effect. The method does not need to perform light spot detection and blur the local light spot, but directly processes the entire image, avoiding the possibility of light spot detection errors and improving the robustness of image processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0041] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0042] Figure 1 A system architecture diagram of an image processing method provided in one embodiment of the present application;
[0043] Figure 2 A flowchart of an image processing method provided by an embodiment of the present application;
[0044] Figure 3 A flowchart of an image processing method provided by another embodiment of the present application;
[0045] Figure 4 A schematic diagram of the effects before and after image processing provided by an embodiment of the present application;
[0046] Figure 5 Another schematic diagram of the effects before and after image processing provided by an embodiment of the present application;
[0047] Figure 6 A schematic diagram of the structure of an image processing device provided by one embodiment of the present application;
[0048] Figure 7 A schematic diagram of the structure of an electronic device provided in accordance with an embodiment of the present application. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, 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 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 making creative work are within the scope of protection of this application.
[0050] The disclosure below provides many different embodiments or examples to implement the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0051] In order to solve the technical problem of how to generate a natural light spot effect through image processing in the prior art, the present application provides an image processing method, device, electronic device and storage medium, which can achieve direct processing of the entire image without the need to perform light spot detection and then perform local blurred light spot processing on the detected light spots, thereby avoiding the possibility of light spot detection errors and improving the robustness of image processing.
[0052] The first embodiment of the present application provides an image processing method, which can be applied to Figure 1 The system architecture shown includes at least an image acquisition module 101 and an image processing module 102, and the image acquisition module 101 and the image processing module 102 establish a communication connection. Specifically, the system architecture can be an intelligent terminal, such as a smart phone, a tablet computer, etc., without limitation.
[0053] Next, based on the system architecture, the image processing method is described in detail. Figure 2 , the image processing method comprises:
[0054] Step 201, obtaining an image to be processed; wherein the image to be processed includes at least one highlight area, and the ratio of the current first brightness of the highlight area to the current second brightness of other areas except all highlight areas is greater than a first threshold; and the first threshold is greater than one.
[0055] The image to be processed may be an image that needs to be processed, for example, an image that needs to generate a spot effect for a highlight area. The first brightness and the second brightness may refer to the average brightness of the area, for example, the first brightness is the average brightness of the highlight area, the second brightness is the average brightness of other areas except all highlight areas in the image to be processed, the first brightness of the highlight area is higher than the second brightness of other areas, and the ratio of the first brightness to the second brightness is greater than a first threshold value, the first threshold value may be any value greater than one, and may be set as needed without limitation.
[0056] In one embodiment, obtaining an image to be processed includes: obtaining an input image; converting the input image into a double-precision type image; and using the double-precision type image as the image to be processed.
[0057] In this embodiment, the input image may be preprocessed to convert the input image into a double-precision image so as to facilitate subsequent mathematical operations such as exponential transformation.
[0058] In one embodiment, obtaining an input image may be obtaining an image captured by a camera, or obtaining an image that has already been taken, such as obtaining it from a local storage address or from the cloud. Of course, it may also be obtained from other devices with shooting functions without limitation.
[0059] Specifically, a first image captured by a camera may be obtained and used as an input image, or a stored second image may be obtained and used as an input image.
[0060] Step 202, performing exponential transformation on the image to be processed to obtain a transformed image; wherein, in the transformed image, the ratio of the current third brightness of the highlight area to the current fourth brightness of other areas is greater than the second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; the second threshold is greater than the first threshold.
[0061] For the transformed image obtained after the exponential transformation, the average brightness will be higher than that before the processing, the third brightness is the current average brightness of the highlighted area, and the fourth brightness is the current average brightness of other areas, that is, the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness. In addition, the brightness increase of the highlighted area in the transformed image is higher than the brightness increase of other areas. In other words, the second threshold is greater than the first threshold, which can make the brightness of the highlighted area more prominent, and avoid missing a highlighted area in subsequent processing.
[0062] It should be noted that the highlight area may be a plurality of highlight areas, and each highlight area corresponds to a third brightness.
[0063] In one embodiment, exponential transformation is performed on the image to be processed to obtain a transformed image, including: obtaining weight information of the exponential transformation; and performing exponential transformation on the highlight area and other areas of the image to be processed respectively according to the weight information to obtain the transformed image.
[0064] In this embodiment, weight information of the exponential transformation is obtained, and the entire image to be processed is subjected to exponential transformation according to the weight information to obtain a transformed image, that is, both the highlight area and other areas are subjected to exponential transformation, which can make the brightness of the highlight area in the image higher, and the intensity of the exponential transformation can be adjusted according to the weight information to control the weight of the brightness adjustment of the highlight area, wherein the weight information can be a preset fixed weight or a customized adjustment by the user according to the scene requirements without limitation.
[0065] In this embodiment, there is no need to perform light spot detection, and the entire image is directly subjected to exponential transformation processing, thereby avoiding the possibility of light spot detection errors and improving the robustness of image processing.
[0066] In one embodiment, exponential transformation processing is performed on the highlight area and other areas of the image to be processed respectively according to the weight information to obtain the transformed image, including: obtaining each pixel point information contained in the highlight area and other areas of the image to be processed; performing exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information; and determining the transformed image based on all the transformation data.
[0067] In this embodiment, in the process of performing exponential transformation on the image to be processed, the entire image to be processed can be exponentially transformed point by point to further highlight the highlighted area in the image to be processed. Specifically, the information of each pixel point contained in the highlighted area and other areas in the image to be processed is obtained, and the information of each pixel point is exponentially transformed according to the weight information to obtain the transformed image.
[0068] In one embodiment, exponential transformation processing is performed on pixel point information according to weight information to obtain transformation data corresponding to the pixel point information, including: pixel normalization is performed on the pixel point information to obtain normalized target data; exponential transformation processing is performed on the target data according to the weight information to obtain transformation data corresponding to the pixel point information.
[0069] In this embodiment, in the process of performing exponential transformation processing on pixel information according to weight information to obtain transformation data corresponding to the pixel information, the pixel information may be firstly subjected to pixel normalization processing. For example, in image processing, an image may be represented as a two-dimensional or three-dimensional array, wherein the pixel information may represent the value of each pixel, representing the color intensity of the point. For a grayscale image, the value of the pixel information is usually an integer between 0 and 255 (in the case of 8-bit depth), wherein 0 represents black and 255 represents white. At this point, the value may be subjected to normalization processing, scaling the range of pixel values from [0, 255] to [0, 1], thereby making the mathematical processing in the exponential transformation process more convenient.
[0070] For example, exponential transformation can be performed using the following formula:
[0071]
[0072] Among them, I exp (x, y) represents data after exponential transformation, I(x, y) represents the data of the image to be processed, m represents weight information, and exp represents the exponential transformation function.
[0073] The code representation can be as follows:
[0074] imori_exp=exp(mExpWeight*imori / 255);
[0075] mExpWeight=1;%Exponential transformation weight information
[0076] Among them, mExpWeight represents the weight information of the exponential transformation, that is, m, imori represents the data of the image to be processed, that is, I(x, y), and imori_exp represents the image data after the exponential transformation.
[0077] Step 203, using a filter of a preset shape to perform convolution filtering on the transformed image, to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape.
[0078] The transformed image is subjected to convolution filtering using a filter of a preset shape, so that the entire image is smoothed, and a light spot effect of a preset shape is formed in a highlight area of the filtered image. The convolution filtering process may be a convolution filtering process performed on the entire transformed image, so that a light spot effect is formed in a highlight area.
[0079] In one embodiment, a filter of a preset shape is used to perform convolution filtering on the transformed image to obtain a filtered image in which a highlight area is converted into a light spot of a preset shape, including: using a filter of a preset shape to perform convolution filtering on the highlight area of the transformed image to obtain a first filtered image in which the highlight area is converted into a light spot of a preset shape; using a filter of a preset shape to perform convolution filtering on other areas of the transformed image to obtain a second filtered image after smoothing the other areas; and using the first filtered image and the second filtered image as the filtered image.
[0080] In this embodiment, the convolution filtering process may be to perform convolution filtering on the highlight area in the entire transformed image. For example, a filter of a preset shape is used to perform convolution filtering on the highlight area of the transformed image to obtain a first filtered image that converts the highlight area into a light spot of a preset shape; and a filter of a preset shape is used to perform convolution filtering on other areas of the transformed image to obtain a second filtered image after smoothing the other areas. While smoothing the entire image, the highlight area is formed into a light spot of a preset shape.
[0081] In one embodiment, before performing convolution filtering on the transformed image using a filter of a preset shape to obtain a filtered image in which a highlight area is converted into a light spot of a preset shape, the method further includes: configuring a filter of a preset shape; wherein the filter of the preset shape includes at least one of a cardioid filter, a star filter, a diamond filter and a circular filter.
[0082] In this embodiment, a filter of a preset shape may be pre-configured, for example, a cardioid filter, a star filter, a diamond filter, a circular filter, etc., and the preset shape is not specifically limited.
[0083] Users can select any shape from pre-configured filters to make the generated spot effect meet user needs.
[0084] For example, convolution filtering can be performed using the following formula:
[0085] I blur (x, y) = (I exp×F)(x,y)
[0086] Among them, I blur (x, y) represents the data after convolution filtering, and F represents a filter of a preset shape.
[0087] The code representation can be as follows:
[0088] imori_filer=filter_func(shape,img_exp)
[0089] Among them, imori_filer represents the data after convolution filtering, filter_func represents the filter function, img_exp represents the image data that needs to be processed by convolution filtering, and img_exp can be a part of the data in imori_exp.
[0090] Here are several implementations of preset shape filters:
[0091] 1. Cardioid filter
[0092] The cardioid pattern can be defined by a polar coordinate equation, such as: (x 2 +y 2 -1) 3 -x 2 y 3 ≤0
[0093] 2. Pentagram filter
[0094] The five-pointed star can be defined by parametric equations, such as: x(t) = Rcos(t) + cos(2t), y(t) = Rsin(t) + sin(2t)
[0095] 3. Circular filter
[0096] Circular filters can be defined by simple circle equations, such as: 2 +y 2 ≤R 2
[0097] The specific code implementation can be as follows:
[0098]
[0099]
[0100] It should be noted that the implementation of the above preset shape filter is only an example and does not represent a limitation on the preset shape filter.
[0101] Step 204, performing logarithmic transformation processing on the filtered image to obtain a processed image; wherein the difference between the brightness of other areas of the processed image and the first brightness is less than a third threshold.
[0102] Performing logarithmic transformation on the filtered image can restore the brightness range of the image to the normal range, which means that the difference between the average brightness of other areas in the processed image and the first brightness of other areas in the image before processing is less than a preset third threshold. At the same time, during the logarithmic transformation process, the spot effect of the highlight area can be further enhanced.
[0103] For example, logarithmic transformation can be performed using the following formula:
[0104]
[0105] Among them, I log (x, y) represents the data after logarithmic transformation, log represents logarithmic transformation, and m represents weight information. Specifically, m can be equal to the weight information during exponential transformation.
[0106] The method performs exponential transformation on the image to be processed to obtain a transformed image, which can make the brightness of the highlight area in the image higher, and then uses a preset shape filter to perform convolution filtering on the transformed image, so that the entire image is smoothed and the highlight area forms a preset shape of spot effect, and then performs logarithmic transformation on the filtered image to restore the brightness range of the image to a normal range, and at the same time can further enhance the spot effect. The method directly processes the entire image and has higher adaptability to various image scenes, generating a robust blur effect, without the need to perform light spot detection and blur spot processing on local light spots, thus avoiding the possibility of light spot detection errors and improving the robustness of image processing.
[0107] In a specific embodiment, Figure 3 Schematic diagram of the image processing method.
[0108] Among them, exponential transformation: through point-by-point exponential transformation of the image, the weight of the highlight area is enhanced, making these areas more prominent in the subsequent filtering process.
[0109] Shape filtering: Use custom shape filters (such as circle, diamond, five-pointed star, heart, etc.) to filter the entire image, so that the entire image is smoothed and forms light spot effects of different shapes.
[0110] Logarithmic transformation: Perform a logarithmic transformation on the filtered image to restore the brightness range of the image to the normal range and further enhance the spot effect.
[0111] The advantages of this embodiment are:
[0112] No need for light spot detection: The entire image is processed directly, avoiding the step of light spot detection and reducing the possibility of detection errors.
[0113] Strong flexibility: By designing filters of different shapes, a variety of light spots of different shapes can be generated to enhance the artistic effect of the photo.
[0114] High robustness: It has higher adaptability to various image scenes and generates a robust blur effect.
[0115] Based on the method of any of the above embodiments, the input image is processed, wherein: Figure 4 The figure is a schematic diagram of the effects before and after image processing, where the image on the left is the image before image processing, and the image on the right is the image after image processing. Figure 5 Another image processing effect diagram is shown below, where the left image is the image before processing and the right image is the image after processing. It can be seen that after image processing, the out-of-focus highlight area forms a certain shape of light spot, which has an artistic effect, allowing traditional mobile phone cameras to achieve the bokeh effect of high-end cameras, improving user experience, making the background of the photo more colorful and enhancing visual appeal.
[0116] Based on the same technical concept, the second embodiment of the present application provides an image processing device, such as Figure 6 , the device comprises:
[0117] The acquisition module 601 is used to acquire an image to be processed; wherein the image to be processed includes at least one highlight area, and the ratio of the current first brightness of the highlight area to the current second brightness of other areas except all the highlight areas is greater than a first threshold; and the first threshold is greater than one;
[0118] The first processing module 602 is used to perform exponential transformation processing on the image to be processed to obtain a transformed image; wherein, in the transformed image, the ratio of the current third brightness of the highlight area to the current fourth brightness of the other areas is greater than a second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; and the second threshold is greater than the first threshold;
[0119] The second processing module 603 is used to perform convolution filtering on the transformed image using a filter of a preset shape to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape;
[0120] The third processing module 604 is used to perform logarithmic transformation on the filtered image to obtain a processed image; wherein the difference between the brightness of the other areas of the processed image and the first brightness is less than a third threshold.
[0121] The device performs exponential transformation processing on the image to be processed to obtain a transformed image, which can make the brightness of the highlight area in the image higher, and then uses a preset shape filter to perform convolution filtering processing on the transformed image, so that the entire image is smoothed and the highlight area forms a preset shape of spot effect, and then performs logarithmic transformation processing on the filtered image to restore the brightness range of the image to a normal range, and at the same time can further enhance the spot effect. This method does not need to perform light spot detection and blur the local light spot, but directly processes the entire image, avoiding the possibility of light spot detection errors and improving the robustness of image processing.
[0122] Optionally, the acquisition module includes:
[0123] A first acquisition unit, used to acquire an input image;
[0124] A first conversion unit, used for converting the input image into a double-precision type image;
[0125] The first determining unit is configured to use the double-precision image as the image to be processed.
[0126] Optionally, the first acquisition unit is specifically used to acquire a first image captured by a camera; and use the first image as the input image; or, acquire a stored second image; and use the second image as the input image.
[0127] Optionally, the first processing module includes:
[0128] A second acquisition unit, used to acquire weight information of the exponential transformation;
[0129] An exponential transformation unit is used to perform exponential transformation processing on the highlight area and the other areas of the image to be processed according to the weight information to obtain the transformed image.
[0130] Optionally, the exponential transformation unit includes:
[0131] A first acquisition subunit, used for acquiring information of each pixel point included in the highlight area and other areas of the image to be processed;
[0132] A transformation subunit, configured to perform exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information;
[0133] A determination subunit is used to determine the transformed image according to all the transformed data.
[0134] Optionally, the transformation subunit is specifically used to perform pixel normalization on the pixel point information to obtain normalized target data; perform exponential transformation processing on the target data according to the weight information to obtain the transformation data corresponding to the pixel point information.
[0135] Optionally, the second processing module is specifically used to: use a filter of a preset shape to perform convolution filtering on the highlight area of the transformed image to obtain a first filtered image that converts the highlight area into a light spot of a preset shape; use a filter of a preset shape to perform convolution filtering on the other areas of the transformed image to obtain a second filtered image after smoothing the other areas; and use the first filtered image and the second filtered image as the filtered image.
[0136] Optionally, the device further comprises a configuration module, which is specifically used to configure the filter of the preset shape; wherein the filter of the preset shape comprises at least one of a cardioid filter, a star filter, a diamond filter and a circular filter.
[0137] like Figure 7 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0138] Memory 113, used for storing computer programs;
[0139] In one embodiment of the present application, the processor 111 is used to execute the program stored in the memory 113 to implement the image processing method provided by any of the above method embodiments, including:
[0140] Acquire an image to be processed; wherein the image to be processed includes at least one highlight area, and the ratio of the current first brightness of the highlight area to the current second brightness of other areas except all the highlight areas is greater than a first threshold; and the first threshold is greater than one;
[0141] Performing exponential transformation processing on the image to be processed to obtain a transformed image; wherein, in the transformed image, a ratio of the current third brightness of the highlight area to the current fourth brightness of the other areas is greater than a second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; and the second threshold is greater than the first threshold;
[0142] Using a filter of a preset shape to perform convolution filtering on the transformed image, so as to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape;
[0143] Performing logarithmic transformation processing on the filtered image to obtain a processed image; wherein the difference between the brightness of the other areas of the processed image and the first brightness is less than a third threshold.
[0144] Optionally, performing exponential transformation on the image to be processed to obtain a transformed image includes:
[0145] Get the weight information of exponential transformation;
[0146] According to the weight information, exponential transformation processing is performed on the highlight area and the other areas of the image to be processed respectively to obtain the transformed image.
[0147] Optionally, performing exponential transformation processing on the highlight area and the other areas of the image to be processed respectively according to the weight information to obtain the transformed image includes:
[0148] Acquire information of each pixel point contained in the highlight area and other areas of the image to be processed;
[0149] Performing exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information;
[0150] The transformed image is determined according to all the transformed data.
[0151] Optionally, performing exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information includes:
[0152] Performing pixel normalization on the pixel point information to obtain normalized target data;
[0153] The target data is subjected to exponential transformation processing according to the weight information to obtain the transformation data corresponding to the pixel point information.
[0154] Optionally, obtaining an image to be processed includes:
[0155] Get the input image;
[0156] Converting the input image into a double-precision image;
[0157] The double-precision image is used as the image to be processed.
[0158] Optionally, using a filter of a preset shape to perform convolution filtering on the transformed image to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape, comprises:
[0159] Using a filter of a preset shape to perform convolution filtering on the highlight area of the transformed image, to obtain a first filtered image that converts the highlight area into a light spot of a preset shape;
[0160] Using a filter of a preset shape to perform convolution filtering on the other regions of the transformed image, to obtain a second filtered image after smoothing the other regions;
[0161] The first filtered image and the second filtered image are used as the filtered images.
[0162] Optionally, before performing convolution filtering on the transformed image using a filter of a preset shape to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape, the method further comprises:
[0163] The filter of the preset shape is configured; wherein the filter of the preset shape includes at least one of a cardioid filter, a star filter, a diamond filter and a circular filter.
[0164] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0165] The communication interface is used for communication between the above terminal and other devices.
[0166] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0167] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0168] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the image processing method provided by any one of the aforementioned method embodiments is implemented.
[0169] The device embodiments described above are merely illustrative, wherein 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 network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0170] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0171] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0172] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. In the description, the suffixes such as "module", "component" or "unit" used to represent the elements are only used to facilitate the description of the present application and have no specific meaning in themselves. Therefore, "module", "component" or "unit" can be used in a mixed manner.
[0173] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. An image processing method, characterized in that: The method comprises: Acquire an image to be processed; wherein the image to be processed includes at least one highlight area, and the ratio of the current first brightness of the highlight area to the current second brightness of other areas except all the highlight areas is greater than a first threshold; and the first threshold is greater than one; Performing exponential transformation processing on the image to be processed to obtain a transformed image; wherein, in the transformed image, a ratio of the current third brightness of the highlight area to the current fourth brightness of the other areas is greater than a second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; and the second threshold is greater than the first threshold; Using a filter of a preset shape to perform convolution filtering on the transformed image, so as to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape; Performing logarithmic transformation processing on the filtered image to obtain a processed image; wherein the difference between the brightness of the other areas of the processed image and the first brightness is less than a third threshold.
2. The method according to claim 1, characterized in that Performing exponential transformation on the image to be processed to obtain a transformed image, including: Get the weight information of exponential transformation; According to the weight information, exponential transformation processing is performed on the highlight area and the other areas of the image to be processed respectively to obtain the transformed image.
3. The method according to claim 2, characterized in that According to the weight information, exponential transformation is performed on the highlight area and the other areas of the image to be processed respectively to obtain the transformed image, including: Acquire information of each pixel point contained in the highlight area and other areas of the image to be processed; Performing exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information; The transformed image is determined according to all the transformed data.
4. The method according to claim 3, characterized in that Performing exponential transformation processing on the pixel point information according to the weight information to obtain transformation data corresponding to the pixel point information includes: Performing pixel normalization on the pixel point information to obtain normalized target data; The target data is subjected to exponential transformation processing according to the weight information to obtain the transformation data corresponding to the pixel point information.
5. The method according to claim 1, characterized in that Get the image to be processed, including: Get the input image; Converting the input image into a double-precision image; The double-precision image is used as the image to be processed.
6. The method according to claim 1, characterized in that The transformed image is subjected to convolution filtering using a filter of a preset shape to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape, comprising: Using a filter of a preset shape to perform convolution filtering on the highlight area of the transformed image, to obtain a first filtered image that converts the highlight area into a light spot of a preset shape; Using a filter of a preset shape to perform convolution filtering on the other regions of the transformed image, to obtain a second filtered image after smoothing the other regions; The first filtered image and the second filtered image are used as the filtered images.
7. The method according to claim 1, characterized in that Before performing convolution filtering on the transformed image using a filter of a preset shape to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape, the method further includes: The filter of the preset shape is configured; wherein the filter of the preset shape includes at least one of a cardioid filter, a star filter, a diamond filter and a circular filter.
8. An image processing device, characterized in that: The device comprises: An acquisition module, used for acquiring an image to be processed; wherein the image to be processed includes at least one highlight area, and the ratio of the current first brightness of the highlight area to the current second brightness of other areas except all the highlight areas is greater than a first threshold; and the first threshold is greater than one; A first processing module is used to perform exponential transformation processing on the image to be processed to obtain a transformed image; wherein, in the transformed image, the ratio of the current third brightness of the highlight area to the current fourth brightness of the other areas is greater than a second threshold; the third brightness is greater than the first brightness, and the fourth brightness is greater than the second brightness; and the second threshold is greater than the first threshold; A second processing module is used to perform convolution filtering on the transformed image using a filter of a preset shape to obtain a filtered image in which the highlight area is converted into a light spot of a preset shape; The third processing module is used to perform logarithmic transformation on the filtered image to obtain a processed image; wherein the difference between the brightness of the other areas of the processed image and the first brightness is less than a third threshold.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the image processing method according to any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 7 is implemented.
