Image enhancement method and device, equipment and storage medium
By performing grayscale mapping and fusion of various mapping methods on the regions of interest in the image, the limitations of the image enhancement method in the prior art are solved, and a higher quality image enhancement effect is achieved.
Patent Information
- Application Number
- CN202411750236.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-05-06
AI Technical Summary
Existing image enhancement methods have limitations when processing specific types of images, and cannot effectively enhance image details with lower contrast or lead to excessive compression of high-brightness area information.
By extracting the region of interest from the original image of the target object, grey-map the original grayscale data using different mapping methods, fuse the grayscale mapping data of each mapping method to obtain the target grayscale mapping data, and adjust the original grayscale data based on this to obtain the target image.
This method can avoid the limitations of a single mapping method, improve the accuracy of image enhancement, and thus improve the enhanced target image quality.
Smart Images

Figure CN119941599A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image enhancement method, device, equipment and storage medium. Background Art
[0002] In the field of image processing, image enhancement is a crucial technology that aims to improve the visual effect of images or facilitate subsequent image analysis, recognition and other processing. Among them, when enhancing images, most of the existing grayscale mapping methods use a single mapping method, such as linear mapping, logarithmic mapping, etc. These methods may show certain limitations when processing specific types of images. For example, linear mapping may not be able to effectively enhance the details of the image when processing images with low contrast; while logarithmic mapping may cause excessive compression of information when processing high-brightness areas. Therefore, how to improve the quality of image enhancement is an urgent problem to be solved. Summary of the invention
[0003] The main technical problem solved by the present application is to provide an image enhancement method, device, equipment and storage medium, which can improve the quality of the enhanced image.
[0004] In order to solve the above technical problems, a technical solution adopted in the present application is: to provide an image enhancement method, the method comprising: extracting a region of interest from an original image of a target object; performing grayscale mapping on the original grayscale data of the region of interest using different mapping methods to obtain grayscale mapping data corresponding to each of the mapping methods; obtaining target grayscale mapping data of the region of interest based on first fusion data of the grayscale mapping data corresponding to each of the mapping methods; adjusting the original grayscale data of the region of interest based on the target grayscale mapping data to obtain a corresponding target image.
[0005] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide an image enhancement device, including: an extraction module, a mapping module, a first acquisition module and a second acquisition module; the extraction module is used to extract a region of interest from an original image of a target object; the mapping module is used to perform grayscale mapping on the original grayscale data of the region of interest using different mapping methods to obtain grayscale mapping data corresponding to each mapping method; the first acquisition module is used to obtain target grayscale mapping data of the region of interest based on first fusion data of the grayscale mapping data corresponding to each mapping method; the second acquisition module is used to adjust the original grayscale data of the region of interest based on the target grayscale mapping data to obtain a corresponding target image.
[0006] To solve the above technical problems, another technical solution adopted in the present application is: to provide an electronic device, comprising a memory and a processor coupled to each other, the memory storing program instructions; the processor is used to execute the program instructions stored in the memory to implement the above method.
[0007] In order to solve the above technical problem, another technical solution adopted by the present application is: providing a computer-readable storage medium for storing program instructions, which can be executed to implement the above method.
[0008] The above scheme uses different mapping methods to grayscale map the original grayscale data in the region of interest in the original image, obtains the grayscale mapping data corresponding to each mapping method, fuses the grayscale mapping data corresponding to each mapping method, and obtains the target grayscale mapping data of the region of interest based on the corresponding first fusion result, and finally uses the target grayscale mapping data to adjust the original grayscale data of the region of interest to obtain the corresponding target image. It can be seen that the target grayscale mapping data of the present application is obtained by fusing the grayscale mapping data corresponding to each mapping method. Compared with the method of obtaining the target grayscale mapping data using a single mapping method, the above method of the present application can avoid the limitations of a single mapping method, thereby improving the accuracy of the mapping, and further improving the quality of the enhanced target image. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is a flowchart of an embodiment of an image enhancement method provided by the present application;
[0010] Figure 2 yes Figure 1 The flowchart of an embodiment before step S13 is shown;
[0011] Figure 3 yes Figure 1 The flowchart of step S13 is shown as an embodiment;
[0012] Figure 4 It is a schematic diagram of the framework of an embodiment of an image enhancement device provided by the present application;
[0013] Figure 5 It is a schematic diagram of a framework of an embodiment of an electronic device provided by the present application;
[0014] Figure 6 It is a schematic diagram of the framework of the computer-readable storage medium provided by this application. DETAILED DESCRIPTION
[0015] In order to make the purpose, technical solution and effect of the present application clearer and more specific, the present application is further described in detail below with reference to the accompanying drawings and examples.
[0016] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0017] The original image in this article can be any image to be enhanced, such as a medical image, a remote sensing image, or an infrared image. It should be noted that the following text of this application uses a specific image (infrared image) and a corresponding specific scene as an example to explain the method provided by this application, and the scope of application of this application solution cannot be limited by this.
[0018] Taking infrared images as an example, the data of infrared images after normal processing can meet normal viewing needs, but in scenes such as animal observation, outdoor exploration, search and rescue, and security patrols, general infrared images cannot meet the visual needs in these scenes. These scenes need to increase the contrast between the region of interest and the background area so that the region of interest can be clearly and quickly focused on. Furthermore, in scenes such as animal observation, outdoor exploration, search and rescue, and security patrols, the main region of interest of infrared images is the higher energy radiation area in the scene, and the high energy radiation area is the area with relatively large grayscale values in the infrared image. Therefore, before improving the contrast of the region of interest, it is necessary to first extract the region of interest from the original image of the target object.
[0019] For infrared images, the region of interest is the high temperature region in the original image, that is, the region with a large grayscale value, and image enhancement of the infrared image requires increasing the contrast between the region of interest and the background region. Image enhancement can be achieved by mapping the grayscale range in the original image to a range more suitable for display, thereby increasing the contrast between the region of interest and the background region.
[0020] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of an embodiment of an image enhancement method provided by the present application. It should be noted that if there are substantially the same results, this embodiment does not necessarily refer to FIG. Figure 1 The process sequence shown is limited. Figure 1 As shown, this embodiment includes:
[0021] S11: Extracting a region of interest from an original image of a target object.
[0022] This embodiment is used to fuse the grayscale mapping data corresponding to each mapping method to obtain target grayscale mapping data, and use the target grayscale mapping data to adjust the original grayscale data of the region of interest to obtain an enhanced target image.
[0023] In this embodiment, extracting the region of interest from the original image of the target object includes the following steps:
[0024] First, obtain the gray level threshold of the original image.
[0025] Second, the area corresponding to the pixels in the original image whose grayscale values are greater than the grayscale threshold is taken as the region of interest.
[0026] This embodiment is used to use the grayscale threshold to take the area corresponding to the pixels in the original image whose grayscale value is greater than or equal to the grayscale threshold as the area of interest, and take the area corresponding to the pixels whose grayscale value is less than the grayscale threshold as the area of no interest, that is, the background area. It can be understood that in this embodiment, the first grayscale value corresponding to each first pixel in the area of interest is greater than the second grayscale value corresponding to each second pixel in the area of no interest in the original image.
[0027] In one embodiment, in order to facilitate the distinction between the region of interest and the region of non-interest, each first pixel point determined as the region of interest may be marked as a first mark, and a second pixel point determined as the region of non-interest may be marked as a second mark, and the first mark and the second mark are different marks, such as different symbols or different numbers. Exemplarily, the pixel points in the region of interest may be marked as 1, and the pixel points in the region of non-interest may be marked as 0.
[0028] The preset value may be set based on experience, for example, the preset value is the grayscale mean or median in the original image.
[0029] In one implementation scenario, considering that the region of interest is the region corresponding to the pixel points with larger grayscale values in the original image, the grayscale statistical data of the original image can also be used to determine the grayscale threshold. The grayscale statistical data is the number of pixels corresponding to each grayscale in the original image. Among them, the grayscale threshold is determined by using the grayscale statistical data of the original image, including: first accumulating the number of pixels corresponding to each grayscale in the order of grayscale from high to low, until the cumulative sum of the number of pixels is greater than the preset number of pixels; then, the most recently accumulated grayscale is used as the grayscale threshold.
[0030] Specifically, all pixels in the original image can be traversed first to construct a grayscale histogram and set a preset number of pixels. Then, the number of pixels corresponding to the grayscale level in the histogram is accumulated from high to low in grayscale level (0-255). The calculation stops when the accumulated sum is greater than or equal to the preset number of pixels. At this time, the accumulated grayscale level in the corresponding histogram is the grayscale threshold.
[0031] The preset number of pixels is determined by the number of pixels included in the expected size of the region of interest. By setting the preset number of pixels, a highlight region (region with a larger grayscale value) in the original image is determined as the region of interest.
[0032] S12: grayscale mapping is performed on the original grayscale data of the region of interest using different mapping methods to obtain grayscale mapping data corresponding to each mapping method.
[0033] In one embodiment, the different mapping modes include at least two mapping modes. For example, at least two mapping modes of linear mapping, gamma transformation and histogram equalization are included. Of course, the specific mapping mode can be selected according to actual needs and is not specifically limited here.
[0034] In one embodiment, the grayscale mapping range corresponding to each mapping method can be preset, and then the original grayscale data of the area of interest can be directly grayscale mapped using each mapping method to obtain the grayscale mapping data corresponding to each mapping method, so as to map the grayscale range in the original image to a range more suitable for display.
[0035] In another embodiment, in order to improve the contrast of the region of interest itself, segmented grayscale mapping may be performed on the region of interest of the original image, which specifically includes the following steps:
[0036] First: Get the grayscale median value of the region of interest and the corresponding grayscale median mapping value.
[0037] The original grayscale data includes the grayscale value of each pixel in the region of interest. First, the maximum grayscale value and the minimum grayscale value of the region of interest in the original image are determined, and then the maximum grayscale value, the minimum grayscale value and the first parameter are used to determine the grayscale intermediate value of the region of interest in the original image.
[0038] Furthermore, the grayscale intermediate mapping value (the grayscale intermediate value after mapping) is determined according to the preset maximum grayscale mapping value, the above-mentioned minimum grayscale value and the second parameter, wherein the first parameter and the second parameter are adjustable parameters, which can be adjusted by relevant personnel according to needs or the visual effects of the image.
[0039] For example, please refer to the following formula:
[0040] GrayMid=GrayMin+(GrayMax-GrayMin) / Ratio1
[0041] GrayMid'=GrayMin+(GrayMax'-GrayMin) / Ratio2
[0042] In the formula, GrayMid represents the grayscale middle value, GrayMid' represents the grayscale middle mapping value, GrayMin represents the minimum grayscale value, GrayMax represents the maximum grayscale value, GrayMax' is the preset maximum grayscale mapping value, Ratio1 and Ratio2 are the first parameter and the second parameter respectively.
[0043] Second: based on the grayscale intermediate value, the first grayscale range of the area of interest in the original image is divided to obtain several original grayscale intervals, and based on the grayscale intermediate mapping value, the preset second grayscale range is divided to obtain the grayscale mapping intervals corresponding to each original grayscale interval.
[0044] In this embodiment, the number of grayscale intermediate values and corresponding grayscale intermediate mapping values is at least one.
[0045] Taking the case where the number of determined grayscale intermediate values and corresponding grayscale intermediate mapping values are both one as an example: based on the grayscale intermediate value, the first grayscale range of the region of interest in the original image can be divided into two original grayscale intervals, that is, the original grayscale range of the region of interest in the original image is divided into two range segments: one is from the minimum grayscale value to the grayscale intermediate value, and the other is from the grayscale intermediate value to the maximum grayscale value; based on the grayscale intermediate mapping value, the preset second grayscale range can also be divided into two grayscale mapping intervals: one is from the preset minimum grayscale mapping value to the grayscale intermediate mapping value, and the other is from the grayscale intermediate mapping value to the preset maximum grayscale mapping value. Among them, the preset minimum grayscale mapping value can be the minimum grayscale value in the region of interest.
[0046] Third: using various mapping methods, the original grayscale values in each original grayscale interval are mapped to the corresponding grayscale mapping interval, and the corresponding grayscale mapping values are obtained.
[0047] Exemplarily, the original grayscale interval corresponding to the minimum grayscale value to the grayscale intermediate value is mapped to the grayscale mapping interval corresponding to the preset minimum grayscale mapping value to the grayscale intermediate mapping value; the original grayscale interval corresponding to the grayscale intermediate value to the maximum grayscale value is mapped to the grayscale mapping interval corresponding to the grayscale intermediate mapping value to the preset maximum grayscale mapping value.
[0048] Specifically, the preset second grayscale range corresponding to each mapping mode can be preset according to actual needs or experience, and is not specifically limited here.
[0049] In one embodiment, before step S12, it is also necessary to determine the minimum grayscale value and the maximum grayscale value in the region of interest of the original image.
[0050] The grayscale values of the pixels in the region of interest may be sorted, and the minimum grayscale value and the maximum grayscale value may be found according to the sorting result.
[0051] You can also first find the pixel with the highest brightness in the region of interest, and use the grayscale value corresponding to the pixel with the highest brightness as the maximum grayscale value, or traverse the grayscale values in the region of interest, find the maximum grayscale value, and then use the maximum grayscale value as the minimum grayscale value, traverse the pixels in the region of interest, if the grayscale value of the pixel is less than the current minimum grayscale value, adjust the current minimum grayscale value to the grayscale value corresponding to the pixel, repeat this step until no pixel with a grayscale value less than the current minimum grayscale value is found, and use the latest current minimum grayscale value as the minimum grayscale value in the region of interest.
[0052] In some embodiments, after step S12, a grayscale mapping table corresponding to each mapping method may be constructed so that the grayscale values before and after mapping in the grayscale mapping table may be directly used to obtain first fused data of grayscale mapping data corresponding to each mapping method.
[0053] Among them, each constructed grayscale mapping table includes multiple grayscale index values and grayscale mapping values corresponding to each grayscale index value. The grayscale mapping values corresponding to each grayscale index value are combined to form grayscale mapping data. The multiple grayscale index values include the first grayscale value corresponding to each first pixel point in the area of interest.
[0054] In one implementation scenario, considering that the minimum grayscale value and the maximum grayscale value in the region of interest in the original images collected at different times are different, in order to facilitate the subsequent fusion of the grayscale mapping table constructed based on the current original image and the grayscale mapping table constructed based on the historical original image, multiple grayscale index values can be set to include any grayscale level in the entire grayscale range (0-255).
[0055] Furthermore, in order to avoid image anomalies or grayscale jumps when the grayscale mapping table constructed based on the current original image is subsequently fused with the grayscale mapping table constructed based on the historical original image, the mapping grayscale corresponding to each grayscale index value less than the minimum grayscale value of the area of interest can be set as the minimum grayscale value (of course, it can also be a grayscale value whose difference with the minimum grayscale value is less than a first preset threshold), and the mapping grayscale corresponding to each grayscale index value greater than the maximum grayscale value of the area of interest is set as the preset maximum grayscale mapping value (of course, it can also be a grayscale value whose difference with the preset maximum grayscale mapping value is less than a second preset threshold).
[0056] For example, the grayscale mapping table corresponding to each mapping method includes grayscale index values corresponding to 0-255, and grayscale mapping values corresponding to each grayscale index value. Among them, the first grayscale value (for example, 150-230) corresponding to each first pixel point in the region of interest is respectively mapped to the grayscale mapping value corresponding to the first grayscale value (for example, 150-250, calculated by the corresponding mapping method), and the grayscale mapping value corresponding to the grayscale index value less than 150 is the minimum grayscale value of 150, and the grayscale mapping value corresponding to the grayscale index value greater than 230 is the preset maximum grayscale mapping value of 250.
[0057] S13: Obtain target grayscale mapping data of the region of interest based on the first fused data of the grayscale mapping data corresponding to each mapping method.
[0058] In this embodiment, before step S13, it is necessary to first obtain weight parameters corresponding to each mapping method, and then use each weight parameter to perform weighted fusion on the grayscale mapping data corresponding to each mapping method to obtain first fused data.
[0059] The weight parameter corresponding to each mapping method can be a preset fixed parameter, or a parameter that can be customized according to at least one of the first grayscale difference value of the region of interest and the grayscale variance of the original grayscale data, and the first grayscale difference value is the difference between the maximum grayscale value and the minimum grayscale value in the region of interest of the original grayscale data. The specific implementation process can be referred to below Figure 2 Description of the illustrated embodiment.
[0060] In this embodiment, the first fused data obtained by fusing the grayscale mapping data can be directly used as the target grayscale mapping data of the region of interest; the first fused data of the current original image obtained can be further fused with the second fused data obtained by fusing the historical original image, and the mapping data obtained by fusing the second fused data can be used as the target grayscale mapping data of the region of interest in the current original image to avoid the grayscale fault phenomenon of the original images of different frames collected. For specific implementation methods, please refer to the following Figure 3 Description of the illustrated embodiment.
[0061] S14: adjusting the original grayscale data of the region of interest based on the target grayscale mapping data to obtain a corresponding target image.
[0062] In this embodiment, the original grayscale data of the region of interest can be directly adjusted to the target grayscale mapping data, and the grayscale value of each pixel in the non-region of interest remains unchanged to obtain the corresponding target image.
[0063] In one embodiment, after obtaining the above target image, neighborhood mean processing may be performed on the region of interest in the target image, and the target image after the neighborhood mean processing is used as the final target image.
[0064] For example, for any pixel in the region of interest or any pixel in the region of interest adjacent to the non-interest region, the pixel is taken as the target pixel, and the average grayscale value of a certain number of pixels around the target pixel is taken as the target grayscale value of the target pixel. The specific number of surrounding pixels can be preset according to actual needs or experience.
[0065] The above scheme uses different mapping methods to grayscale map the original grayscale data in the region of interest in the original image, obtains the grayscale mapping data corresponding to each mapping method, fuses the grayscale mapping data corresponding to each mapping method, and obtains the target grayscale mapping data of the region of interest based on the corresponding first fusion result, and finally uses the target grayscale mapping data to adjust the original grayscale data of the region of interest to obtain the corresponding target image. It can be seen that the target grayscale mapping data of the present application is obtained by fusing the grayscale mapping data corresponding to each mapping method. Compared with the method of obtaining the target grayscale mapping data using a single mapping method, the above method of the present application can avoid the limitations of a single mapping method, thereby improving the accuracy of the mapping, and further improving the quality of the enhanced target image.
[0066] In some embodiments, see Figure 2 , Figure 2 yes Figure 1 The flowchart of an embodiment before step S13 is shown. This embodiment includes:
[0067] S21: Obtain weight parameters corresponding to each mapping method.
[0068] S22: performing weighted fusion on the grayscale mapping data corresponding to each mapping method using each weight parameter to obtain first fused data.
[0069] In this embodiment, the weight parameter corresponding to each mapping method can be a preset fixed parameter, or a parameter that can be customized according to at least one of the first grayscale difference of the region of interest and the grayscale variance of the original grayscale data. The first grayscale difference is the difference between the maximum grayscale value and the minimum grayscale value in the original grayscale data.
[0070] In one embodiment, the different mapping modes include at least two mapping modes, and the weight parameters corresponding to the at least two mapping modes are at least two of the first weight parameter, the second weight parameter and the third weight parameter.
[0071] In a specific embodiment, at least two mapping methods include linear mapping, gamma transform and histogram equalization; the weight parameter corresponding to the linear mapping is the first weight parameter, the weight parameter corresponding to the gamma transform is the second weight parameter, and the weight parameter corresponding to the histogram equalization is the third weight parameter.
[0072] Among them, the first weight parameter is the maximum of the first constant and the first comparison result, the first comparison result is the minimum of the second constant and the first ratio, the first ratio is the ratio of the first difference between the first grayscale difference and the first preset value to the first grayscale difference, and the first preset value is greater than or equal to the first constant.
[0073] The second weight parameter is a second difference between the second constant and the first weight parameter.
[0074] The third weight parameter is the maximum of the first constant and the second comparison result, the second comparison result is the minimum of the second constant and the second ratio, and the second ratio is the ratio of the second preset value to the grayscale variance.
[0075] To facilitate understanding of the above weight parameters, the relationship between different weight parameters, and step S22, please refer to the following formula:
[0076]
[0077] In the formula, α represents the first weight parameter, 0 represents the first constant, and 1 represents the second constant.
[0078] represents the first comparison result, Th1 represents the first preset value (the value is greater than or equal to 0), Graymax-Graymin represents the first grayscale difference, Represents the first ratio.
[0079]
[0080] Wherein, 1-β represents the third weight parameter, Th2 represents the second preset value (the value is greater than or equal to 0), represents the second comparison result, Represents the second ratio, and Var represents the grayscale variance.
[0081] Further, for example, different mapping methods include a first mapping method (for example, linear mapping), a second mapping method (for example, gamma transformation) and a third mapping method (for example, histogram equalization). In one embodiment, the grayscale mapping data corresponding to each mapping method is weighted and fused using each weight parameter to obtain the first fused data as follows:
[0082] Table=β(αTable1+(1-α)Table2+(1-β)Table3
[0083] In the formula, Table represents a grayscale mapping table obtained by fusing the grayscale mapping data corresponding to each mapping method, the mapping table includes each grayscale index value and the corresponding grayscale mapping fusion data, each grayscale mapping fusion data is combined into the first fusion data, α represents the first weight parameter, 1-α represents the second weight parameter, 1-β represents the third weight parameter, Table1 represents the grayscale mapping table obtained by the first mapping method (for example, linear mapping), Table2 represents the grayscale mapping table obtained by the second mapping method (for example, gamma transformation), and Table3 represents the grayscale mapping table obtained by the third mapping method (for example, histogram equalization). For the grayscale mapping table corresponding to each mapping method, please refer to the relevant description of the previous embodiment.
[0084] In this implementation, the grayscale mapping data corresponding to the linear mapping and the grayscale mapping data corresponding to the gamma transform are first weightedly fused using the first weight parameter and the second weight parameter to obtain initial fused data, and then the initial fused data and the grayscale mapping data corresponding to the histogram equalization are further weightedly fused using the sixth weight parameter (β) and the third weight parameter to obtain first fused data.
[0085] In another embodiment, the grayscale mapping data corresponding to each mapping method is weightedly fused using each weight parameter to obtain the first fused data as follows:
[0086] Table=αTable1+(1-α)Table2+(1-β)Table3
[0087] In the formula, Table represents a grayscale mapping table obtained by fusing the grayscale mapping data corresponding to each mapping method, the mapping table includes each grayscale index value and the corresponding grayscale mapping fusion data, each grayscale mapping fusion data is combined into the first fusion data, α represents the first weight parameter, 1-α represents the second weight parameter, 1-β represents the third weight parameter, Table1 represents the grayscale mapping table obtained by the first mapping method (for example, linear mapping), Table2 represents the grayscale mapping table obtained by the second mapping method (for example, gamma transformation), and Table3 represents the grayscale mapping table obtained by the third mapping method (for example, histogram equalization). For the grayscale mapping table corresponding to each mapping method, please refer to the relevant description of the previous embodiment.
[0088] Of course, in some embodiments, the second mapping method represented by Table 2 may be histogram equalization, and the third mapping method represented by Table 3 may be gamma transformation, which may be determined based on the actual fusion effect of each grayscale mapping data.
[0089] In this embodiment, the first weight parameter, the second weight parameter and the third weight parameter are directly used to perform weighted fusion on the corresponding grayscale mapping data to obtain the first fused data. Among them, each grayscale mapping data can be obtained by querying the grayscale mapping table. Of course, in other embodiments, the grayscale mapping values corresponding to each grayscale value in the region of interest and corresponding to each mapping method can be pre-stored, and then the first weight parameter, the second weight parameter and the third weight parameter are used to perform weighted fusion on the corresponding grayscale mapping data to obtain the first fused data.
[0090] In the above manner, the weight parameter corresponding to the linear mapping is the first weight parameter, the weight parameter corresponding to the gamma transform is the second weight parameter, and the weight parameter corresponding to the histogram equalization is the third weight parameter.
[0091] It should be noted that different mapping methods correspond to different mapping effects. The present application integrates the grayscale mapping data determined by multiple different mapping methods, which can utilize the advantages of each mapping method, avoid the limitations of a single mapping method, and thus help improve the image enhancement effect.
[0092] Furthermore, the above-mentioned method of adaptively adjusting the weight parameters corresponding to each mapping method according to at least one of the first grayscale difference of the region of interest and the grayscale variance of the original grayscale data can flexibly select and optimize different grayscale mapping methods according to the specific characteristics of the image and processing requirements. This helps to improve the contrast and clarity of the image while maintaining the image details, thereby improving the overall quality of the image. In addition, adaptively adjusting the weight parameters based on the grayscale difference and other features of the region of interest can ensure that the contrast of the region of interest is significantly enhanced during the fusion process, making the target or key information more prominent, which is convenient for subsequent analysis and recognition.
[0093] In some embodiments, see Figure 3 , Figure 3 yes Figure 1 The flowchart of an embodiment of step S13 is shown. In this embodiment, step S13 further includes:
[0094] S31: Acquire the second fusion data of the historical original image, and acquire the fourth weight parameter corresponding to the historical original image and the fifth weight parameter corresponding to the current original image.
[0095] The first fusion data of this embodiment is the fusion data of each grayscale mapping data of the current original image. This embodiment is used to further fuse the first fusion data of the current original image and the second fusion data of the historical original image to obtain the target grayscale mapping data of the current original image. The method of fusing the current original image with the historical original image in this embodiment can effectively reduce the grayscale fault phenomenon in the historical image and the current image. Among them, the historical frame original image can be, but is not limited to, the previous frame of the current original image, and can also be several frames of historical original images adjacent to the current original image.
[0096] S32: Using the fourth weight parameter and the fifth weight parameter, perform weighted fusion on the first fused data and the second fused data to obtain target grayscale mapping data.
[0097] In one embodiment, the fourth weight parameter and the fifth weight parameter are pre-set fixed weight parameters. In another embodiment, the fourth weight parameter and the fifth weight parameter are weight parameters that can change based on the absolute value of the third difference between the first grayscale difference and the second grayscale difference. Among them, the fifth weight parameter corresponding to the current original image is determined based on the absolute value of the third difference between the first grayscale difference and the second grayscale difference, the fourth weight parameter corresponding to the historical original image is the difference between the second constant and the fifth weight parameter, the first grayscale difference is the difference between the maximum grayscale value and the minimum grayscale value in the region of interest of the current original image, and the second grayscale difference is the difference between the maximum grayscale value and the minimum grayscale value in the region of interest of the historical original image.
[0098] In a specific embodiment, obtaining a fifth weight parameter corresponding to the current original image based on the absolute value of a third difference between the first grayscale difference and the second grayscale difference includes the following steps:
[0099] First, a third ratio of the third preset value to the absolute value is obtained.
[0100] Second, the largest one between the second constant and the third ratio is used as a candidate weight parameter.
[0101] Third, the largest one between the candidate weight parameter and the first constant is used as the fifth weight parameter; the second constant is greater than the first constant.
[0102] To facilitate understanding of the fifth weight parameter, the fourth weight parameter, the relationship between different weight parameters, and step S32, please refer to the following formula:
[0103]
[0104] In the formula, Graymax k Graymin kGraymax represents the maximum and minimum grayscale values in the region of interest of the original image. k-1 Graymin k-1 Graymax represents the maximum grayscale value and the minimum grayscale value in the region of interest of the historical original image. k -Graymin k Represents the first grayscale difference, Graymax k-1 -Graymin k-1 represents the second grayscale difference, Th3 represents the third preset value, and μ represents the fifth weight parameter.
[0105] Table=μTable k +(1-μ)Table k-1
[0106] In the formula, Table k Indicates the grayscale mapping table corresponding to the first fusion data of the current original image, Table k-1 represents the grayscale mapping table corresponding to the second fusion data of the historical original image, Table represents the grayscale mapping table corresponding to the target grayscale mapping data, μ represents the fifth weight parameter, and 1-μ represents the fourth weight parameter. The data included in the specific grayscale mapping table can be referred to the description of the relevant embodiments above, and will not be repeated here.
[0107] It should be noted that the grayscale mapping table is constructed to facilitate the fusion of grayscale mapping data corresponding to each mapping method, and / or, when fusing the fusion data corresponding to original images of different frames, the target grayscale mapping value corresponding to each grayscale value can be quickly determined by looking up the table (the target grayscale mapping value of each pixel point in the area of interest constitutes the target grayscale mapping data).
[0108] Of course, in other embodiments, other grayscale values and grayscale mapping values may be associated to perform subsequent grayscale mapping data fusion, such as a histogram, where each histogram block includes a grayscale value and a corresponding grayscale mapping value.
[0109] See also Figure 4 , Figure 4: is a schematic diagram of a framework of an embodiment of an image enhancement device provided by the present application. In this embodiment, the image enhancement device 40 includes an extraction module 41, a mapping module 42, a first acquisition module 43, and a second acquisition module 44. The extraction module 41 is used to extract a region of interest from an original image of a target object; the mapping module 42 is used to perform grayscale mapping on the original grayscale data of the region of interest using different mapping methods to obtain grayscale mapping data corresponding to each mapping method; the first acquisition module 43 is used to obtain target grayscale mapping data of the region of interest based on first fusion data of the grayscale mapping data corresponding to each mapping method; the second acquisition module 44 is used to adjust the original grayscale data of the region of interest based on the target grayscale mapping data to obtain the corresponding target image.
[0110] In some embodiments, before the mapping module 42 obtains the target grayscale mapping data of the area of interest based on the first fusion data of the grayscale mapping data corresponding to each mapping method, it also includes: obtaining the weight parameters corresponding to each mapping method; using each weight parameter to perform weighted fusion on the grayscale mapping data corresponding to each mapping method to obtain the first fusion data.
[0111] In some embodiments, the weight parameters corresponding to each mapping method are determined based on at least one of a first grayscale difference value of the region of interest and a grayscale variance of the original grayscale data, and the first grayscale difference value is the difference between the maximum grayscale value and the minimum grayscale value in the original grayscale data.
[0112] In some embodiments, different mapping methods include at least two mapping methods, and the weight parameters corresponding to the at least two mapping methods are at least two of the first weight parameter, the second weight parameter and the third weight parameter; the first weight parameter is the maximum of the first constant and the first comparison result, the first comparison result is the minimum of the second constant and the first ratio, the first ratio is the ratio of the first difference between the first grayscale difference and the first preset value to the first grayscale difference, and the first preset value is greater than or equal to the first constant; the second weight parameter is the second difference between the second constant and the first weight parameter; the third weight parameter is the difference between the second constant and the maximum of the first constant and the second comparison result, the second comparison result is the minimum of the second constant and the second ratio, and the second ratio is the ratio of the second preset value to the grayscale variance.
[0113] In some embodiments, at least two mapping methods include linear mapping, gamma transform and histogram equalization; the weight parameter corresponding to the linear mapping is the first weight parameter, the weight parameter corresponding to the gamma transform is the second weight parameter, and the weight parameter corresponding to the histogram equalization is the third weight parameter.
[0114] In some embodiments, the first fusion data is the fusion data of each grayscale mapping data about the current original image; the first acquisition module 43 obtains the target grayscale mapping data of the area of interest based on the first fusion data of the grayscale mapping data corresponding to each mapping method, including: obtaining the second fusion data of the historical original image, and obtaining the fourth weight parameter corresponding to the historical original image and the fifth weight parameter corresponding to the current original image; using the fourth weight parameter and the fifth weight parameter, the first fusion data and the second fusion data are weightedly fused to obtain the target grayscale mapping data.
[0115] In some embodiments, the fifth weight parameter corresponding to the current original image is determined based on the absolute value of the third difference between the first grayscale difference and the second grayscale difference, and the fourth weight parameter corresponding to the historical original image is the difference between the second constant and the fifth weight parameter; wherein the first grayscale difference is the difference between the maximum grayscale value and the minimum grayscale value in the area of interest of the current original image, and the second grayscale difference is the difference between the maximum grayscale value and the minimum grayscale value in the area of interest of the historical original image.
[0116] In some embodiments, obtaining the fifth weight parameter corresponding to the current original image includes: obtaining a third ratio of a third preset value to an absolute value; using the maximum of the second constant and the third ratio as a candidate weight parameter; using the maximum of the candidate weight parameter and the first constant as the fifth weight parameter; the second constant is greater than the first constant.
[0117] In some embodiments, the extraction module 41 extracts a region of interest from an original image of a target object, including: obtaining a grayscale threshold of the original image; wherein the grayscale threshold is a preset value or is determined using grayscale statistics of the original image, and the grayscale statistics are the number of pixels corresponding to each grayscale in the original image; the region corresponding to the pixel points in the original image whose grayscale values are greater than or equal to the grayscale threshold is taken as the region of interest; wherein the grayscale threshold is determined using the grayscale statistics of the original image, including: accumulating the number of pixels corresponding to each grayscale in order from high to low until the accumulated sum of the number of pixels is greater than the preset number of pixels; and taking the most recently accumulated grayscale as the grayscale threshold.
[0118] In some embodiments, the original grayscale data includes the maximum grayscale value and the minimum grayscale value of the area of interest; the mapping module 42 uses different mapping methods to grayscale map the original grayscale data of the area of interest to obtain grayscale mapping data corresponding to each mapping method, including: obtaining the grayscale intermediate value of the area of interest and the corresponding grayscale intermediate mapping value; wherein the grayscale intermediate value is determined by using the maximum grayscale value, the minimum grayscale value and the first parameter, and the grayscale intermediate mapping value is determined by using the preset maximum grayscale mapping value, the minimum grayscale value and the second parameter, and the first parameter and the second parameter are adjustable parameters; based on the grayscale intermediate value, the first grayscale level range of the area of interest in the original image is divided to obtain a number of original grayscale intervals, and based on the grayscale intermediate mapping value, the preset second grayscale level range is divided to obtain the grayscale mapping interval corresponding to each original grayscale interval; using each mapping method, the original grayscale value in each original grayscale interval is mapped to the corresponding grayscale mapping interval, and the corresponding grayscale mapping values are obtained.
[0119] In some embodiments, after the mapping module 42 uses different mapping methods to perform grayscale mapping on the original grayscale data of the area of interest and obtains the grayscale mapping data corresponding to each mapping method, it also includes: constructing a grayscale mapping table corresponding to each mapping method; each grayscale mapping table includes multiple grayscale index values and grayscale mapping values corresponding to each grayscale index value, and the multiple grayscale index values include the first grayscale value corresponding to each first pixel point in the area of interest.
[0120] In some embodiments, the original image is an infrared image, and the first grayscale value corresponding to each first pixel in the region of interest is greater than the second grayscale value corresponding to each second pixel in the non-interest region in the original image; and / or, the second acquisition module 44 adjusts the original grayscale data of the region of interest based on the target grayscale mapping data to obtain the corresponding target image, including: adjusting the original grayscale data of the region of interest to the target grayscale mapping data; and / or, after the second acquisition module 44 adjusts the original grayscale data of the region of interest based on the target grayscale mapping data to obtain the corresponding target image, it also includes: performing neighborhood mean processing on the region of interest in the target image.
[0121] See also Figure 5 , Figure 5 1 is a schematic diagram of a framework of an electronic device according to an embodiment of the present application. In this embodiment, the electronic device 50 includes a memory 51 and a processor 52 coupled to each other.
[0122] The memory 51 stores program instructions, and the processor 52 is used to execute the program instructions stored in the memory 51 to implement the steps of any of the above method implementations. In a specific implementation scenario, the electronic device 50 may include, but is not limited to: a microcomputer, a server, and in addition, the electronic device 50 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0123] Specifically, the processor 52 is used to control itself and the memory 51 to implement the steps of any of the above-mentioned embodiments. The processor 52 can also be called a CPU (Central Processing Unit). The processor 52 may be an integrated circuit chip with signal processing capabilities. The processor 52 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 52 can be implemented by an integrated circuit chip.
[0124] See also Figure 6 , Figure 6 It is a schematic diagram of the framework of the computer-readable storage medium provided by the present application. The computer-readable storage medium 60 of the embodiment of the present application stores a program instruction 61, and when the program instruction 61 is executed, the method provided by any embodiment of the above method and any non-conflicting combination is implemented. Among them, the program instruction 61 can form a program file and be stored in the above-mentioned computer-readable storage medium 60 in the form of a software product, so that a computer device (which can be a personal computer, a server, or a network device, etc.) executes all or part of the steps of each implementation method of the present application. The aforementioned computer-readable storage medium 60 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, or a terminal device such as a computer, a server, a mobile phone, and a tablet.
[0125] The above scheme uses different mapping methods to grayscale map the original grayscale data in the region of interest in the original image, obtains the grayscale mapping data corresponding to each mapping method, fuses the grayscale mapping data corresponding to each mapping method, and obtains the target grayscale mapping data of the region of interest based on the corresponding first fusion result, and finally uses the target grayscale mapping data to adjust the original grayscale data of the region of interest to obtain the corresponding target image. It can be seen that the target grayscale mapping data of the present application is obtained by fusing the grayscale mapping data corresponding to each mapping method. Compared with the method of obtaining the target grayscale mapping data using a single mapping method, the above method of the present application can avoid the limitations of a single mapping method, thereby improving the accuracy of the mapping, and further improving the quality of the enhanced target image.
[0126] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0127] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0128] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0129] 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 units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0130] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0131] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0132] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. An image enhancement method, characterized in that: The method comprises: Extracting a region of interest from an original image of a target object; Performing grayscale mapping on the original grayscale data of the region of interest using different mapping methods to obtain grayscale mapping data corresponding to each of the mapping methods; Based on the first fused data of the grayscale mapping data corresponding to each of the mapping modes, the target grayscale mapping data of the region of interest is obtained; The original grayscale data of the region of interest is adjusted based on the target grayscale mapping data to obtain a corresponding target image.
2. The method according to claim 1, characterized in that Before obtaining the target grayscale mapping data of the region of interest based on the first fused data of the grayscale mapping data corresponding to each of the mapping modes, the method further includes: Obtaining weight parameters corresponding to each of the mapping modes; The grayscale mapping data corresponding to each of the mapping modes are weightedly fused using each of the weight parameters to obtain the first fused data.
3. The method according to claim 2, characterized in that The weight parameters corresponding to each of the mapping modes are determined based on at least one of a first grayscale difference value of the region of interest and a grayscale variance of the original grayscale data, wherein the first grayscale difference value is a difference between a maximum grayscale value and a minimum grayscale value in the original grayscale data.
4. The method according to claim 3, characterized in that The different mapping modes include at least two mapping modes, and the weight parameters corresponding to the at least two mapping modes are at least two of a first weight parameter, a second weight parameter and a third weight parameter; The first weight parameter is the maximum of a first constant and a first comparison result, the first comparison result is the minimum of a second constant and a first ratio, the first ratio is a ratio of a first difference between the first grayscale difference and a first preset value to the first grayscale difference, and the first preset value is greater than or equal to the first constant; The second weight parameter is a second difference between the second constant and the first weight parameter; The third weight parameter is the difference between the second constant and the largest of the first constant and the second comparison result, the second comparison result is the smallest of the second constant and the second ratio, and the second ratio is the ratio of the second preset value to the grayscale variance.
5. The method according to claim 2 or 4, characterized in that: The at least two mapping methods include linear mapping, gamma transform and histogram equalization; the weight parameter corresponding to the linear mapping is a first weight parameter, the weight parameter corresponding to the gamma transform is a second weight parameter, and the weight parameter corresponding to the histogram equalization is a third weight parameter.
6. The method according to claim 1, characterized in that The first fused data is fused data of each grayscale mapping data of the current original image; The first fusion data based on the grayscale mapping data corresponding to each of the mapping modes is used to obtain the target grayscale mapping data of the region of interest, including: Acquire second fusion data of the historical original image, and acquire a fourth weight parameter corresponding to the historical original image and a fifth weight parameter corresponding to the current original image; The first fused data and the second fused data are weightedly fused using the fourth weight parameter and the fifth weight parameter to obtain the target grayscale mapping data.
7. The method according to claim 6, characterized in that The fifth weight parameter corresponding to the current original image is determined based on the absolute value of the third difference between the first grayscale difference and the second grayscale difference, and the fourth weight parameter corresponding to the historical original image is the difference between the second constant and the fifth weight parameter; The first grayscale difference is the difference between the maximum grayscale value and the minimum grayscale value in the region of interest of the current original image, and the second grayscale difference is the difference between the maximum grayscale value and the minimum grayscale value in the region of interest of the historical original image.
8. The method according to claim 7, characterized in that Obtaining a fifth weight parameter corresponding to the current original image includes: Acquire a third ratio of a third preset value to the absolute value; taking the largest one of the second constant and the third ratio as a candidate weight parameter; The largest one between the candidate weight parameter and the first constant is used as the fifth weight parameter; the second constant is greater than the first constant.
9. The method according to claim 1, characterized in that: The step of extracting the region of interest from the original image of the target object comprises: Obtaining a grayscale threshold of the original image; wherein the grayscale threshold is a preset value or is determined using grayscale statistical data of the original image, and the grayscale statistical data is the number of pixels corresponding to each grayscale in the original image; The region corresponding to the pixel points whose grayscale values in the original image are greater than or equal to the grayscale threshold is used as the region of interest; Wherein, determining the gray level threshold by using gray level statistics of the original image includes: Accumulating the number of pixels corresponding to each gray level in order from high to low gray levels until the accumulated sum of the number of pixels is greater than the preset number of pixels; The most recently accumulated gray level is used as the gray level threshold.
10. The method according to claim 1, characterized in that The original grayscale data includes the maximum grayscale value and the minimum grayscale value of the region of interest; The grayscale mapping of the original grayscale data of the region of interest by using different mapping methods to obtain grayscale mapping data corresponding to each mapping method includes: Obtaining a grayscale intermediate value and a corresponding grayscale intermediate mapping value of the region of interest; wherein the grayscale intermediate value is determined by using the maximum grayscale value, the minimum grayscale value and a first parameter, and the grayscale intermediate mapping value is determined by using a preset maximum grayscale mapping value, the minimum grayscale value and a second parameter, and the first parameter and the second parameter are adjustable parameters; Based on the grayscale intermediate value, dividing the first grayscale range of the region of interest in the original image to obtain a plurality of original grayscale intervals, and based on the grayscale intermediate mapping value, dividing the preset second grayscale range to obtain grayscale mapping intervals corresponding to each of the original grayscale intervals; By using the mapping methods, the original grayscale values in the original grayscale intervals are mapped to the corresponding grayscale mapping intervals, and the corresponding grayscale mapping values are obtained.
11. The method according to claim 1, characterized in that: After grayscale mapping is performed on the original grayscale data of the region of interest using different mapping methods to obtain grayscale mapping data corresponding to each mapping method, the method further includes: Construct a grayscale mapping table corresponding to each of the mapping methods; each of the grayscale mapping tables includes a plurality of grayscale index values and grayscale mapping values corresponding to each of the grayscale index values, and the plurality of grayscale index values include a first grayscale value corresponding to each first pixel point in the region of interest.
12. The method according to claim 1, characterized in that The original image is an infrared image, and a first grayscale value corresponding to each first pixel point in the region of interest is greater than a second grayscale value corresponding to each second pixel point in the non-interest region in the original image; And / or, adjusting the original grayscale data of the region of interest based on the target grayscale mapping data to obtain a corresponding target image includes: Adjusting the original grayscale data of the region of interest to the target grayscale mapping data; And / or, after adjusting the original grayscale data of the region of interest based on the target grayscale mapping data to obtain a corresponding target image, the method further includes: Perform neighborhood mean processing on the region of interest in the target image.
13. An image enhancement device, characterized in that: The device comprises: An extraction module, used for extracting a region of interest from an original image of a target object; A mapping module, used to perform grayscale mapping on the original grayscale data of the region of interest using different mapping methods to obtain grayscale mapping data corresponding to each mapping method; A first acquisition module, configured to obtain target grayscale mapping data of the region of interest based on first fused data of grayscale mapping data corresponding to each of the mapping modes; The second acquisition module is used to adjust the original grayscale data of the region of interest based on the target grayscale mapping data to obtain a corresponding target image.
14. An electronic device, characterized in that: comprising a memory and a processor coupled to each other, The memory stores program instructions; The processor is used to execute the program instructions stored in the memory to implement the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions that can be run by a processor, and the program instructions can be executed by the processor to implement the method according to any one of claims 1 to 12.
Citation Information
Cited By
Detection model training method, detection method and detection model training device
CN120913006A
Fire point detection method based on binocular camera, electronic equipment and readable storage medium
CN121304776A
Endoscopic image enhancement method and device, electronic equipment and storage medium
CN121961964A