Image processing method, apparatus and electronic device
By detecting the contextual information of the target region in the image, calculating the modulation intensity and enhancing the contrast, the problem of poor visual effects in the prior art is solved, and better image visual effects and scene adaptability are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AXERA TECH (BEIJING) CO LTD
- Filing Date
- 2023-03-10
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies, when enhancing image contrast, struggle to balance contrast in bright areas and detail in dark areas, resulting in poor visual effects and poor scene adaptability.
By detecting the target region in the image to be processed, determining its contextual information, calculating the modulation intensity, and enhancing the contrast of the target region based on the modulation intensity, image segmentation and contrast adjustment are performed using a region neural network and a modulation neural network.
It improves the visual effect of images, adapts to the image quality requirements of different scenes, enhances scene adaptability, and avoids distortion caused by local contrast enhancement.
Smart Images

Figure CN116309159B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information processing, and more specifically, to an image processing method, apparatus, and electronic device. Background Technology
[0002] Contrast ratio refers to the measurement of the different brightness levels between the brightest white and the darkest black in an image. The larger the range of difference, the greater the contrast. Contrast ratio has a crucial impact on visual effects. Generally speaking, the higher the contrast ratio, the clearer and more striking the image, and the more vivid and vibrant the colors; while low contrast ratio makes the entire image appear hazy and dull.
[0003] In related technologies, the grayscale histogram of an image can be statistically analyzed, and then global histogram equalization can be performed to expand the grayscale range of the image, thereby redistributing the pixel values and enhancing contrast. However, this approach struggles to balance contrast in bright areas with detail in dark areas. Furthermore, while noise in flat areas is amplified, detail in texture areas is not significantly improved, resulting in poor scene adaptability and ultimately, unsatisfactory visual effects in the processed image. Summary of the Invention
[0004] The purpose of this application is to provide an image processing method, apparatus, and electronic device to improve the contrast of an image to be processed while enhancing its visual effect.
[0005] Firstly, embodiments of this application provide an image processing method, which includes: upon detecting a target region in an image to be processed, determining contextual information of the target region; calculating the modulation intensity of the target region based on the contextual information; and enhancing the contrast of the target region based on the modulation intensity to obtain a target image. The contrast can be adaptively adjusted according to the contextual information of the target region, taking into account the contrast of bright and dark areas, as well as the contrast of textured and flat areas. Furthermore, since the target region can be identified as the main part of the image of interest, targeted enhancement of its contrast can meet the image quality requirements of different scenarios, thereby covering a wider range of application scenarios and exhibiting strong scene adaptability. Consequently, the target image obtained after enhancing the contrast has a better visual effect.
[0006] Optionally, determining the context information of the target region when a target region is detected in the image to be processed includes: segmenting the target region to obtain multiple slice regions; and determining the context information corresponding to each slice region; wherein the context information of the target region includes the context information of multiple slice regions. This allows for the targeted determination of the modulation intensity of each slice region, facilitating the processing of image details in the target region. Furthermore, since the computational load of each slice region is relatively small, the image processing hardware can process each slice region in parallel, improving computational efficiency.
[0007] Optionally, the context information of the sliced region includes: the brightness range of the sliced region in the entire image, the proportion of the pixel value of the sliced region to the total pixel value of the entire image, and the proportion of the pixel value of each pixel in the sliced region to the same pixel value in the entire image. This better highlights the difference between the target area and other parts, achieving the goal of increasing overall contrast.
[0008] Optionally, calculating the modulation intensity of the target region based on the context information includes: classifying multiple brightness intervals corresponding to the image to be processed according to the brightness intervals occupied by the sliced region; wherein the overall brightness interval of the image to be processed is divided into multiple brightness intervals based on a preset rule; for a type of brightness interval, calculating the proportion of the pixel value of that type of brightness interval to the total pixel value of the image; and calculating the modulation intensity of the sliced region based on the proportion of the pixel value of that type of brightness interval to the total pixel value of the image, the proportion of the pixel value of the sliced region to the total pixel value of the image, and the proportion of the pixel value of each pixel in the sliced region to the same pixel value in the entire image; wherein the modulation intensity of the target region includes the modulation intensity of multiple sliced regions. In this way, mathematical statistics can be performed on different brightness intervals during the contrast enhancement process to take into account the contrast of different brightness intervals in the image to be processed.
[0009] Optionally, the modulation intensity of the sliced region is calculated using a modulation neural network. The training process of the modulation neural network includes: acquiring modulation sample slices; for each modulation sample slice, labeling the modulation intensity of the modulation sample slice to obtain a modulation sample label; using the proportion of the pixel value of the modulation sample slice to the total pixel value, the proportion of the pixel value of each pixel in the modulation sample slice to the same pixel value in the total image, and the proportion of the pixel value of different brightness ranges to the total pixel value as input to the modulation neural network, and using the modulation sample label as the expected output of the modulation neural network; for each modulation sample slice, calculating the loss value between the modulation sample label corresponding to the modulation sample slice and the actual sample label output by the modulation neural network, and determining that the modulation neural network has converged when the loss value reaches a preset requirement. This allows for a more convenient acquisition of the modulation intensity.
[0010] Optionally, the step of enhancing the contrast of the target region based on the modulation intensity to obtain the target image includes: for a slice region, enhancing the contrast of the slice region based on the modulation intensity of the slice region to obtain an intermediate contrast; and performing global tone mapping processing based on the original contrast of the slice region before enhancement and the intermediate contrast to generate a target slice region; wherein the target image includes multiple target slice regions. This avoids distortion caused by local contrast enhancement.
[0011] Optionally, the target region is detected by a region neural network. The training process of the region neural network includes: acquiring sample images; for each sample image, labeling the target sample region of the sample image to obtain a region sample label; using the sample image as the input of the region neural network, and using the sample mask corresponding to the target sample region as the expected output of the region neural network; for each sample image, calculating the loss value between the region sample label corresponding to the sample image and the actual sample mask output by the region neural network, and determining that the region neural network has converged when the loss value reaches a preset requirement. In this way, the region neural network can be used to generate a small-sized image mask to achieve spatial selection, obtain additional information to help enhance contrast without significantly introducing additional computational burden, thus reducing the processing burden on image processing hardware.
[0012] Secondly, embodiments of this application provide an image processing apparatus, comprising: a determining module, configured to determine context information of a target region when a target region in an image to be processed is detected; a calculating module, configured to calculate the modulation intensity of the target region based on the context information; and an enhancing module, configured to enhance the contrast of the target region based on the modulation intensity to obtain a target image. This allows for a better visual effect in the target image after contrast enhancement.
[0013] Thirdly, embodiments of this application provide an electronic device, including a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the method provided in the first aspect above are performed.
[0014] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps of the method provided in the first aspect above.
[0015] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing embodiments of this application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart illustrating an image processing method provided in an embodiment of this application;
[0018] Figure 2 A structural block diagram of an image processing apparatus provided in an embodiment of this application;
[0019] Figure 3 This is a schematic diagram of the structure of an electronic device for performing an image processing method, provided as an embodiment of this application. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0021] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0022] It should be noted that, unless otherwise specified, the embodiments or technical features in the embodiments of this application may be combined.
[0023] In related technologies, there is a problem that enhancing image contrast does not result in good visual effects. To solve this problem, this application provides an image processing method, apparatus, and electronic device. Furthermore, the brightness information of a target region in the image to be processed is redistributed based on the contextual information of that target region. The image can then be processed based on the redistributed brightness information to achieve enhanced contrast. By using the contextual information of the target region, the brightness relationship between that target region and the entire image to be processed can be clearly defined. Therefore, the contrast can be adaptively adjusted to balance the contrast of bright and dark areas, textured areas, and flat areas. Moreover, since the target region can be identified as the main part of the image of interest, it can cover a wider range of application scenarios, exhibiting strong scene adaptability. Consequently, after enhancing the contrast, the visual effect of the target image is improved.
[0024] In some applications, the image processing method described above can be applied to image processing software. In other applications, it can also be applied to image processing hardware. This hardware may include, for example, chips and sensors. These chips and sensors may be used in user terminals such as cameras, camcorders, or mobile phones.
[0025] This application is described below as being applied to image processing hardware.
[0026] The defects in the solutions in the above-mentioned related technologies are all the result of the inventors' practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the embodiments of the present invention in the following text should be the inventors' contributions to the present invention.
[0027] Please refer to Figure 1 The diagram illustrates a flowchart of an image processing method provided in an embodiment of this application. Figure 1 As shown, the image processing method includes the following steps 101 to 103.
[0028] Step 101: When a target region is detected in the image to be processed, the context information of the target region is determined;
[0029] In some applications, image processing hardware can detect target regions in an image to be processed. This target region can be considered, for example, the main body of the image. That is, the target region can be, for example, a face, text, or other object other than the background. In these applications, the image processing hardware can detect the target region in the image to be processed using object detection algorithms.
[0030] After the image processing hardware detects the target region, it can determine the context information of that target region. This context information can be considered as the brightness relationship between the target region and the entire image to be processed. This brightness relationship can be, for example, the proportion of the pixel values of the target region in the total pixel values of the image to be processed. For instance, the proportion of the pixel values of target region 'a' in the pixel values of image 'A'.
[0031] Step 102: Calculate the modulation intensity of the target region based on the context information;
[0032] After the image processing hardware determines the context information of the target region, it can calculate the modulation intensity of the target region based on this context information. This modulation intensity can be considered as a contrast enhancement coefficient. For example, for the target region 'a', the proportion of the pixel values of target region 'a' in the pixel values of the image A to be processed can be determined as the modulation intensity.
[0033] It should be noted that context information can refer to a single piece of information or include multiple pieces of information. When the context information includes a single piece of information, for example, this information can be normalized and used as the modulation intensity, or the modulation intensity can be determined by combining this information with pre-assigned weights. When the context information includes multiple pieces of information, the modulation intensity can be determined by combining each piece of information with its corresponding weight.
[0034] Step 103: Enhance the contrast of the target region according to the modulation intensity to obtain the target image.
[0035] After determining the modulation intensity of the target region, the image processing hardware can adaptively enhance the contrast of the target region. In some applications, for example, the modulation intensity can be multiplied by the pixel value of the target region to obtain the enhanced contrast of that target region.
[0036] In some applications, image processing hardware enhances the contrast of the target region to obtain the target image. In these applications, regions other than the target region can be left unprocessed, or the corresponding modulation intensity can be calculated based on the context information of that region, and then the contrast can be enhanced based on the corresponding modulation intensity.
[0037] In this embodiment, the contrast can be adaptively adjusted based on the contextual information of the target area, taking into account the contrast of bright and dark areas, as well as the contrast of textured and flat areas. Furthermore, since the target area can be identified as the main part of the image of interest, targeted enhancement of its contrast can meet the image quality requirements of different scenarios, thus covering a wider range of application scenarios and exhibiting strong scene adaptability. Therefore, after processing through steps 101 to 103, the visual effect of the target image with enhanced contrast is improved.
[0038] In some optional implementations, the target region is detected by a region neural network; the training process of the region neural network includes:
[0039] First, obtain the sample image;
[0040] Image processing hardware can acquire a large number of sample images, which may include corresponding main image components. These main image components may include, for example, a human face, geese in the sky, or houses in front of a mountain.
[0041] Then, for each of the sample images, the target sample region of the sample image is labeled to obtain the region sample label;
[0042] After the image processing hardware acquires a large number of sample images, the target sample region can be manually marked, for example, and this target sample region can be regarded as the main part of the image of interest in the sample image.
[0043] Secondly, the sample image is used as the input of the region neural network, and the sample mask corresponding to the target sample region is used as the expected output of the region neural network.
[0044] In other words, multiple sample images can be used as inputs to a region neural network, and the sample mask corresponding to each sample image can be used as the output to train the region neural network. The sample mask mentioned above can be regarded as an image used to cover the target sample region, and its visual effect is close to that of the region sample label.
[0045] In some application scenarios, the sample image can first be scaled to W×H; then the scale of the desired output sample mask can be set to (W×H) / r. Where W represents the width; H represents the height; and r represents the downsampling factor (the network structure of the neural network in this region can be adjusted according to the fine granularity required by the application scenario to obtain a sample mask of arbitrary scale).
[0046] Finally, for each sample image, the loss value between the region sample label corresponding to the sample image and the actual sample mask output by the region neural network is calculated, and the region neural network is determined to have converged when the loss value reaches a preset requirement.
[0047] For a large number of sample images, the loss value between the region sample label of each sample image and the actual sample mask output by the region neural network can be calculated iteratively. When this loss value meets a preset requirement, the region neural network can be considered to have converged. At this point, when the region neural network is used to process the actual image to be processed, it can output a relatively accurate image mask. The target region can be determined through this image mask, and this target region can be considered as the region of interest in the image to be processed. The preset requirement for the aforementioned loss value can include, for example, the loss value being within a small error range such as 0.05 or 0.1, or multiple consecutively calculated loss values being the same.
[0048] In this implementation, a small image mask can be generated using the neural network in this region to achieve spatial selection. This provides additional information to enhance contrast without significantly introducing additional computational burden, thus reducing the processing burden on the image processing hardware.
[0049] In some alternative implementations, the step 101 above, which involves determining the context information of the target region when a target region in the image to be processed is detected, includes the following sub-steps:
[0050] Sub-step 1011: When a target region is detected in the image to be processed, the target region is segmented to obtain multiple slice regions;
[0051] In some applications, when image processing hardware detects a target region, it can segment that region to obtain multiple slices. For example, it can obtain an image mask corresponding to the target region, and then, based on the image mask and the image to be processed, use image segmentation methods such as the watershed algorithm, linear iterative clustering algorithm, normalized segmentation algorithm, and maximum entropy segmentation algorithm for segmentation.
[0052] Sub-step 1012: For a given slice region, determine the context information corresponding to the slice region;
[0053] After obtaining multiple slice regions, each slice region can be processed separately. Specifically, for a single slice region, its contextual information can be determined. That is, the brightness relationship between the slice region and the global region of the image to be processed can be determined.
[0054] In this way, the target region can correspond to multiple slice regions, each slice region has corresponding context information, and the context information of the target region can include the context information of multiple slice regions.
[0055] In this implementation, the target region can be divided into multiple slice regions, and the context information of each slice region can be determined separately. This allows for the targeted determination of the modulation intensity of each slice region, facilitating the processing of image details in the target region. Furthermore, since the computational load of each slice region is relatively small, the image processing hardware can process each slice region in parallel, improving computational efficiency.
[0056] In some optional implementations, the context information of the sliced region includes: the brightness range of the region occupied by the sliced region in the whole image, the proportion of the pixel value of the sliced region to the total pixel value of the whole image, and the proportion of the pixel value of each pixel in the sliced region to the same pixel value of the whole image.
[0057] In some application scenarios, the minimum and maximum brightness of the sliced area can be detected. The brightness range corresponding to the minimum and maximum brightness can be regarded as the brightness range of the sliced area in the whole image.
[0058] In some application scenarios, the pixel values of the sliced region and the pixel values of the entire image to be processed can be detected. Then, the pixel values of the sliced region can be divided by the pixel values of the entire image to obtain the proportion of the pixel values of the sliced region to the pixel values of the entire image.
[0059] In some applications, the pixel value of each pixel in a sliced region can be detected. Then, for a given pixel value, multiple pixels in the entire image containing the same value can be counted, and the proportion of that pixel value to all the pixels in the entire image can be calculated. This proportion is the percentage of each pixel value in the sliced region relative to the total number of identical pixels in the entire image. For example, if a pixel value of 2 exists in the sliced region, multiple pixels with the value 2 in the entire image can be counted. If 10 identical pixels are found, then the proportion of each pixel value in the sliced region relative to the total number of identical pixels in the entire image can be 1 / 10.
[0060] In this implementation, the proportion of local information corresponding to the sliced area in the global information of the whole image can be determined. Then, the modulation intensity determined based on this proportion is more suitable for the current sliced area, and can better highlight the difference between the target area and other parts, thereby achieving the purpose of increasing the overall contrast.
[0061] In some alternative implementations, step 102 above, which involves calculating the modulation intensity of the target region based on the context information, includes the following sub-steps:
[0062] Sub-step 1021: According to the brightness range of the sliced region, classify the multiple brightness ranges corresponding to the image to be processed; wherein, the overall brightness range of the image to be processed is divided into multiple brightness ranges based on a preset rule;
[0063] Image processing hardware can pre-divide the overall brightness range of the image to be processed into multiple brightness intervals based on preset rules. In some application scenarios, the preset rules can, for example, divide the overall brightness range equally according to bit values. For example, if the overall brightness range of the image to be processed is 16 bits, then the overall brightness range of the image to be processed can be evenly divided into 16 brightness intervals. Specifically, these 16 brightness intervals can be: [0, 4096-1], [4096, 2*4096-1]...[15*4096, 16*4096-1]. In other application scenarios, the preset rules can, for example, divide the overall brightness range into multiple brightness intervals based on powers of two. For example, the overall brightness range can be divided into the following brightness intervals: [0, 1), [1, 2), [2, 4)...[32768, 65535).
[0064] After dividing the overall brightness range of the image to be processed into multiple brightness ranges, the image processing hardware can classify these multiple brightness ranges according to the brightness range of the sliced region in the whole image. For example, for the image to be processed with the above value of 16 bits, if the brightness range of the sliced region is [0, 4096-1], then the multiple brightness ranges corresponding to the image to be processed can be divided into 16 categories.
[0065] Sub-step 1022: For a certain type of brightness range, calculate the proportion of the pixel value of that type of brightness range to the total pixel value of the image.
[0066] After dividing multiple brightness ranges into multiple classes, image processing hardware can calculate the proportion of pixel values in each brightness range to the total pixel values of the entire image. That is, for each brightness range, the average brightness (pixel value) corresponding to that range is calculated as a proportion of the average brightness of the entire image.
[0067] Sub-step 1023: Calculate the modulation intensity of the sliced region based on the proportion of the pixel value of the brightness range to the total pixel value of the whole image, the proportion of the pixel value of the sliced region to the total pixel value of the whole image, and the proportion of the pixel value of each pixel in the sliced region to the same pixel value of the whole image.
[0068] After the image processing hardware determines the proportion of pixel values in each brightness range to the total pixel values in the image, it can further calculate the modulation intensity of the sliced region by combining the determined context information.
[0069] In some optional implementations, the modulation intensity of the slice region can be calculated using a modulation neural network; the training process of the modulation neural network includes the following steps:
[0070] Step 1, obtain the modulated sample slice;
[0071] In some applications, image processing hardware can acquire a large number of sample slices. For example, it can acquire a large number of color-rich slices as modulation sample slices. The size of each modulation sample slice can be the same as the size of the aforementioned slice region to better suit the calculation of the modulation intensity of the slice region.
[0072] Step 2: For each of the modulation sample slices, mark the modulation intensity of the modulation sample slice to obtain the modulation sample label;
[0073] After obtaining multiple modulation sample slices from an image, the modulation intensity of each modulation sample slice can be labeled. For example, the modulation intensity of each modulation sample slice can be manually labeled to obtain the modulation sample label corresponding to each modulation sample slice.
[0074] Step 3: The proportion of the pixel value of the modulation sample slice to the total pixel value, the proportion of the pixel value of each pixel in the modulation sample slice to the same pixel value in the total image, and the proportion of the pixel value of different brightness ranges to the total pixel value are used as the input of the modulation neural network, and the modulation sample label is used as the expected output of the modulation neural network.
[0075] In some applications, the aforementioned modulation neural network can function as a multilayer perceptron containing two hidden layers. In these applications, the image processing hardware can use the proportion of pixel values in the modulation sample slice to the total pixel value, the proportion of pixel values in each pixel slice to the same pixel value in the total pixel value, and the proportion of pixel values in different brightness ranges to the total pixel value as inputs to the multilayer perceptron, to train the modulation neural network to output modulation sample labels.
[0076] It should be noted that the process of obtaining the proportion of the pixel value of the above-mentioned modulation sample slice to the total pixel value, the proportion of the pixel value of each pixel in the modulation sample slice to the same pixel value in the total image, and the proportion of the pixel value of different brightness ranges to the total pixel value can be referred to the relevant steps of obtaining the context information of the slice area mentioned above, and will not be repeated here.
[0077] Step 4: For each modulation sample slice, calculate the loss value between the modulation sample label corresponding to the modulation sample slice and the actual sample label output by the modulation neural network, and determine that the modulation neural network has converged when the loss value reaches a preset requirement.
[0078] For a large number of modulated sample slices, the loss value between the modulated sample label labeled on each slice and the actual sample label output by the modulation neural network can be calculated iteratively. When this loss value meets a preset requirement, the modulation neural network can be considered to have converged. At this point, when the modulation neural network is used to process the actual slice region, it can output a more accurate modulation intensity. The preset requirement for the loss value can include, for example, that the loss value be within a small error range such as 0.05 or 0.1, or that multiple consecutively calculated loss values are the same.
[0079] After the modulation neural network is trained, it can be applied to multiple slice regions obtained from the segmentation of the image to be processed, to obtain the modulation intensity corresponding to each slice region. Subsequently, the modulation intensity of the target region can include the modulation intensities of multiple slice regions.
[0080] In this implementation, by classifying the multiple brightness ranges corresponding to the image to be processed and then calculating the modulation intensity of the target region, mathematical statistics can be performed on different brightness ranges during the contrast enhancement process, so as to take into account the contrast of different brightness ranges in the image to be processed.
[0081] In some alternative implementations, the step 103 above, which involves enhancing the contrast of the target region based on the modulation intensity to obtain the target image, may include the following sub-steps:
[0082] Sub-step 1031: For a slice region, enhance the contrast of the slice region according to the modulation intensity of the slice region to obtain the intermediate contrast.
[0083] After image processing hardware divides the target area into multiple slices, it can enhance the contrast of each slice based on the modulation intensity corresponding to that slice. In some applications, for example, the brightness of each pixel can be multiplied by the value corresponding to the modulation intensity to obtain the enhanced brightness of each pixel, and thus the intermediate contrast.
[0084] Sub-step 1032: Perform global tone mapping processing based on the original contrast of the sliced area before enhancement and the intermediate contrast to generate the target sliced area;
[0085] After obtaining the intermediate contrast of each slice region, the image processing hardware can perform global tone mapping processing by combining it with the original contrast before enhancement to obtain the target slice region. Specifically, for example, global tone mapping processing can be performed based on a computational formula, which can be P... O =αP a +(1-α)P b , where P O P represents the contrast after global tone mapping; a Indicates the original contrast before enhancement; P b α represents the intermediate contrast; α represents the degree to which the original contrast is preserved. The value range of α can be [0,1]. The smaller the value, the lower the degree to which the original contrast is preserved, and the larger the value, the higher the degree to which the original contrast is preserved.
[0086] In this way, the target region can correspond to multiple slice regions, and each slice region corresponds to a target slice region. Therefore, the image that includes multiple target slice regions is the target image.
[0087] In this implementation, global tone mapping is performed based on the original contrast and intermediate contrast of the sliced region, which can avoid distortion caused by local contrast enhancement.
[0088] Please refer to Figure 2This diagram illustrates a structural block diagram of an image processing apparatus according to an embodiment of this application. The image processing apparatus may be a module, program segment, or code on an electronic device. It should be understood that this apparatus is similar to the one described above. Figure 1 The method implementation corresponds to this and can be executed. Figure 1 The specific functions of the device involved in the method embodiments can be found in the description above. To avoid repetition, detailed descriptions are omitted here.
[0089] Optionally, the image processing apparatus described above includes a determining module 201, a calculating module 202, and an enhancing module 203. The determining module 201 is used to determine the context information of the target region when a target region is detected in the image to be processed; the calculating module 202 is used to calculate the modulation intensity of the target region based on the context information; and the enhancing module 203 is used to enhance the contrast of the target region based on the modulation intensity to obtain a target image.
[0090] Optionally, the determining module 201 is further configured to: when a target region is detected in the image to be processed, segment the target region to obtain multiple slice regions; for a slice region, determine the context information corresponding to the slice region; wherein the context information of the target region includes the context information of multiple slice regions.
[0091] Optionally, the context information of the sliced region includes: the brightness range of the sliced region in the whole image, the proportion of the pixel value of the sliced region to the total pixel value of the whole image, and the proportion of the pixel value of each pixel in the sliced region to the same pixel value in the whole image.
[0092] Optionally, the calculation module 202 is further configured to: classify multiple brightness intervals corresponding to the image to be processed according to the brightness intervals occupied by the sliced regions; wherein, the overall brightness interval of the image to be processed is divided into multiple brightness intervals based on a preset rule; for a type of brightness interval, calculate the proportion of the pixel value of that type of brightness interval to the total pixel value of the image; and calculate the modulation intensity of the sliced region according to the proportion of the pixel value of that type of brightness interval to the total pixel value of the image, the proportion of the pixel value of the sliced region to the total pixel value of the image, and the proportion of the pixel value of each pixel in the sliced region to the same pixel value in the entire image; wherein, the modulation intensity of the target region includes the modulation intensity of multiple sliced regions.
[0093] Optionally, the modulation intensity of the sliced region is calculated by a modulation neural network; the training process of the modulation neural network includes: acquiring modulation sample slices; for each modulation sample slice, labeling the modulation intensity of the modulation sample slice to obtain a modulation sample label; using the proportion of the pixel value of the modulation sample slice to the total pixel value, the proportion of the pixel value of each pixel in the modulation sample slice to the same pixel value in the total image, and the proportion of the pixel value of different brightness ranges to the total pixel value as input to the modulation neural network, and using the modulation sample label as the expected output of the modulation neural network; for each modulation sample slice, calculating the loss value between the modulation sample label corresponding to the modulation sample slice and the actual sample label output by the modulation neural network, and determining that the modulation neural network has converged when the loss value reaches a preset requirement.
[0094] Optionally, the enhancement module 203 is further configured to: enhance the contrast of a slice region according to the modulation intensity of the slice region to obtain an intermediate contrast; and perform global tone mapping processing based on the original contrast of the slice region before enhancement and the intermediate contrast to generate a target slice region; wherein the target image includes multiple target slice regions.
[0095] Optionally, the target region is detected by a region neural network; the training process of the region neural network includes: acquiring sample images; for each sample image, labeling the target sample region of the sample image to obtain a region sample label; using the sample image as the input of the region neural network, and using the sample mask corresponding to the target sample region as the expected output of the region neural network; for each sample image, calculating the loss value between the region sample label corresponding to the sample image and the actual sample mask output by the region neural network, and determining that the region neural network has converged when the loss value reaches a preset requirement.
[0096] It should be noted that those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system or device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0097] Please refer to Figure 3 , Figure 3This is a schematic diagram of an electronic device for executing an image processing method, provided in an embodiment of this application. The electronic device may include: at least one processor 301, such as a CPU, at least one communication interface 302, at least one memory 303, and at least one communication bus 304. The communication bus 304 is used to establish direct communication between these components. In this embodiment, the communication interface 302 is used for signaling or data communication with other node devices. The memory 303 may be high-speed RAM or non-volatile memory, such as at least one disk storage device. Optionally, the memory 303 may also be at least one storage device located remotely from the aforementioned processor. The memory 303 stores computer-readable instructions. When these computer-readable instructions are executed by the processor 301, the electronic device can perform the aforementioned... Figure 1 The method and process are shown.
[0098] Understandable. Figure 3 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 3 The more or fewer components shown, or having the same Figure 3 The different configurations shown. Figure 3 The components shown can be implemented using hardware, software, or a combination thereof.
[0099] This application provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it can perform actions such as... Figure 1 The method process executed by the electronic device in the illustrated method embodiment.
[0100] This application provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer can perform the methods provided in the above-described method embodiments. For example, the method may include: when a target region in an image to be processed is detected, determining context information of the target region; calculating the modulation intensity of the target region based on the context information; and enhancing the contrast of the target region based on the modulation intensity to obtain a target image.
[0101] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0102] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0103] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0104] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.
[0105] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. An image processing method, characterized in that, include: When a target region is detected in the image to be processed, the context information of the target region is determined; Calculate the modulation intensity of the target region based on the context information; The contrast of the target region is enhanced based on the modulation intensity to obtain the target image; When a target region is detected in the image to be processed, determining the context information of the target region includes: when a target region is detected in the image to be processed, segmenting the target region to obtain multiple slice regions; for each slice region, determining the context information corresponding to that slice region; wherein, the context information of the target region includes the context information of multiple slice regions; The step of enhancing the contrast of the target region according to the modulation intensity to obtain a target image includes: for a slice region, enhancing the contrast of the slice region according to the modulation intensity of the slice region to obtain an intermediate contrast; and performing global tone mapping processing based on the original contrast of the slice region before enhancement and the intermediate contrast to generate a target slice region; wherein, the target image includes multiple target slice regions.
2. The method according to claim 1, characterized in that, The context information of the slice region includes: The brightness range of the sliced area in the whole image, the proportion of the pixel value of the sliced area to the total pixel value of the whole image, and the proportion of the pixel value of each pixel in the sliced area to the same pixel value in the whole image.
3. The method according to claim 2, characterized in that, The step of calculating the modulation intensity of the target region based on the context information includes: According to the brightness range of the area occupied by the slice region, the multiple brightness ranges corresponding to the image to be processed are classified; wherein, the overall brightness range of the image to be processed is divided into multiple brightness ranges based on a preset rule; For a given brightness range, calculate the proportion of pixel values in that brightness range to the total pixel values of the entire image; and The modulation intensity of the sliced region is calculated based on the proportion of the pixel value of the brightness range to the total pixel value of the whole image, the proportion of the pixel value of the sliced region to the total pixel value of the whole image, and the proportion of the pixel value of each pixel in the sliced region to the same pixel value of the whole image. The modulation intensity of the target region includes the modulation intensity of multiple slice regions.
4. The method according to claim 3, characterized in that, The modulation intensity of the slice region is calculated using a modulation neural network; The training process of the modulation neural network includes: Obtain modulated sample slices; For each of the modulation sample slices, the modulation intensity of the modulation sample slice is marked to obtain the modulation sample label; The proportion of pixel values in the modulated sample slice to the total pixel values, the proportion of pixel values in each pixel of the modulated sample slice to the same pixel values in the total pixel values, and the proportion of pixel values in different brightness ranges to the total pixel values are used as inputs to the modulation neural network, and the modulation sample label is used as the expected output of the modulation neural network. For each of the modulation sample slices, the loss value between the modulation sample label corresponding to the modulation sample slice and the actual sample label output by the modulation neural network is calculated, and the modulation neural network is determined to have converged when the loss value reaches a preset requirement.
5. The method according to any one of claims 1-4, characterized in that, The target region is detected by a regional neural network; the training process of the regional neural network includes: Acquire sample images; For each of the sample images, the target sample region of the sample image is labeled to obtain the region sample label; The sample image is used as the input to the region neural network, and the sample mask corresponding to the target sample region is used as the expected output of the region neural network. For each sample image, the loss value between the region sample label corresponding to the sample image and the actual sample mask output by the region neural network is calculated, and the region neural network is determined to have converged when the loss value reaches a preset requirement.
6. An image processing apparatus, characterized in that, include: The determination module is used to determine the context information of the target region when a target region is detected in the image to be processed; The calculation module is used to calculate the modulation intensity of the target region based on the context information; An enhancement module is used to enhance the contrast of the target region according to the modulation intensity to obtain a target image; The determining module is further configured to: when a target region is detected in the image to be processed, segment the target region to obtain multiple slice regions; for a slice region, determine the context information corresponding to the slice region; wherein, the context information of the target region includes the context information of multiple slice regions; The enhancement module is further configured to: enhance the contrast of a slice region based on the modulation intensity of the slice region to obtain an intermediate contrast; and perform global tone mapping processing based on the original contrast of the slice region before enhancement and the intermediate contrast to generate a target slice region; wherein the target image includes multiple target slice regions.
7. An electronic device, characterized in that, It includes a processor and a memory, the memory storing computer-readable instructions that, when executed by the processor, perform the method as described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it performs the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Image enhancing method and device
CN104517272A
Image processing method and device, electronic equipment and computer readable storage medium
CN114219729A