Image processing method and device, driving assistance system and storage medium
By using technical means such as grayscale transformation, Fibonacci sequence division and kernel function adjustment in image processing, the problem of easy segmentation errors and loss of details in the existing technology is solved, and the clearer contour performance of night scene pictures and the improvement of night driving safety is achieved.
Patent Information
- Application Number
- CN202411915529.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-28
AI Technical Summary
The image enhancement methods used in the prior art are prone to problems such as segmentation errors and loss of details, and it is difficult to clearly express the outline of things in the night scene, affecting the safety of driving at night.
By acquiring the image to be processed, performing grayscale transformation and obtaining the grayscale histogram, using the Fibonacci sequence to divide the grayscale levels, adjust the histogram based on the division results and the preset kernel function, generate the adjusted image, and perform edge enhancement processing.
It realizes a clearer expression of the outline of the night scene pictures, which makes it easier for the human eye to observe the road details and improves the safety of driving at night.
Smart Images

Figure CN119722473A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing, and in particular to an image processing method, device, driving assistance system and storage medium. Background Art
[0002] With the popularization of automobiles and the rapid development of highways, the speed of automobiles has also increased. When driving at night, there are problems such as uneven brightness distribution, weak light, generally dark image acquisition information, and reduced visibility in night road images, which often lead to low quality of acquired images, insufficient clarity, and blurred images.
[0003] The image enhancement methods used in the prior art have problems such as easy segmentation errors and loss of details. Therefore, it is difficult to clearly show the outlines of objects in night scenes, making it inconvenient for the human eye to observe road details, which is not conducive to improving the safety of night driving. Summary of the invention
[0004] The purpose of the present invention is to at least provide an image processing method, device, driving assistance system and storage medium, which can at least solve the problem that the image enhancement method used in the prior art is prone to segmentation errors, detail loss and other problems, and therefore it is difficult to clearly show the outlines of objects in night scenes. At least it can make the outlines of objects in night scene pictures clearer, making it easier for the human eye to observe road details, thereby improving the safety of night driving.
[0005] To solve the above technical problems, at least one embodiment of the present application provides an image processing method, including:
[0006] Get the image to be processed;
[0007] After performing grayscale transformation on the image to be processed, a grayscale histogram of the image to be processed is obtained;
[0008] Using the Fibonacci sequence to divide the grayscale levels of the grayscale histogram to obtain a grayscale level division result;
[0009] Based on the grayscale classification result, the grayscale histogram is adjusted using a preset kernel function to obtain a standardized histogram, and an adjusted image is generated based on the standardized histogram;
[0010] The adjusted image is subjected to edge enhancement processing to obtain a processed target image.
[0011] At least one embodiment of the present application further provides an image processing device, including:
[0012] An acquisition module, used for acquiring an image to be processed;
[0013] A grayscale histogram acquisition module, used to acquire a grayscale histogram of the image to be processed after performing grayscale transformation on the image to be processed;
[0014] A grayscale classification module is used to classify the grayscale of the grayscale histogram using the Fibonacci sequence to obtain a grayscale classification result;
[0015] A histogram regulation module, used for adjusting the grayscale histogram based on the grayscale classification result by using a preset kernel function to obtain a regulated histogram, and generating an adjusted image based on the regulated histogram, wherein the kernel function is a piecewise function, the number of the piecewise functions is consistent with the number of the grayscale levels, each grayscale level corresponds to a piecewise function for adjustment, each piecewise function corresponds to a weight coefficient, the weight coefficient is calculated by the Fibonacci sequence, and the weight coefficient is used to adjust the contrast enhancement degree of the grayscale domain of different grayscale levels;
[0016] The edge enhancement module is used to perform edge enhancement processing on the adjusted image to obtain a processed target image.
[0017] At least one embodiment of the present application also provides a driving assistance system, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the above-mentioned image processing method.
[0018] At least one embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above-mentioned image processing method when executed by a processor.
[0019] The image processing method, device, driving assistance system and storage medium provided by the embodiments of the present application achieve effective improvement of image contrast and clarity by combining grayscale transformation, grayscale level division and kernel function adjustment based on the Fibonacci sequence, and edge enhancement processing. The application of the Fibonacci sequence makes the grayscale level division more reasonable, which helps to improve the naturalness and significance of the image after subsequent contrast enhancement processing. Edge enhancement processing further enhances the visual effect of the image, making it more suitable for night application scenes, so as to make the outlines of objects in night scene pictures clearer, making it easier for the human eye to observe road details, thereby improving the safety of night driving.
[0020] In some optional embodiments, the kernel function is a piecewise function, the number of the piecewise functions is consistent with the number of the grayscale levels, each of the grayscale levels corresponds to a piecewise function for adjustment, each of the piecewise functions corresponds to a weight coefficient, the weight coefficient is calculated based on the Fibonacci sequence, and the weight coefficient is used to adjust the contrast enhancement degree of the grayscale domain of different grayscale levels.
[0021] In this embodiment, the weight coefficient is calculated based on the Fibonacci sequence, which not only provides a mathematical basis for contrast enhancement of different gray levels, but also makes the distribution of weight coefficients more reasonable and orderly. The characteristics of the Fibonacci sequence make the weight coefficient present a natural growth trend in the sequence, which helps to enhance the details of a specific gray area while maintaining the overall contrast balance of the image.
[0022] In some optional embodiments, the grayscale histogram is divided into grayscale levels by using the Fibonacci sequence to obtain a grayscale level division result, including:
[0023] The Nth term, the N+1th term, and the N+2th term in the Fibonacci sequence are summed to obtain a first calculated value;
[0024] Calculating a first ratio of the value corresponding to the Nth item to the first calculated value, and obtaining a first grayscale domain segmentation threshold according to the product of the first ratio and a preset maximum grayscale value;
[0025] Calculate a second ratio of the sum of the value corresponding to the Nth item and the value corresponding to the N+1th item to the first calculated value, and obtain a second grayscale domain segmentation threshold according to the product of the second ratio and the maximum value of the grayscale value;
[0026] Based on the first grayscale domain segmentation threshold and the second grayscale domain segmentation threshold, combined with the grayscale mean of the grayscale histogram of the image to be processed, the grayscale levels of the grayscale histogram are divided into low grayscale levels, medium grayscale levels and high grayscale levels.
[0027] In this embodiment, the Fibonacci sequence, as a classic mathematical sequence, has unique mathematical properties and aesthetic value. Each of its terms is the sum of the previous two terms, and this characteristic makes the numerical distribution in the sequence present a natural and harmonious proportional relationship. By using the Fibonacci sequence to divide the grayscale levels, it can be ensured that the result of the division is more in line with mathematical laws and natural laws, thereby improving the rationality and scientificity of the division. And the numerical growth rate of the Fibonacci sequence is moderate, neither too fast to cause the division to be too detailed, nor too slow to cause the division to be too rough. This moderate growth rate enables the division result to adapt to the distribution characteristics of the grayscale histogram, thereby more accurately reflecting the grayscale information of the image.
[0028] In some optional embodiments, the kernel function is set as follows:
[0029] The kernel function includes a first piecewise function, a second piecewise function and a third piecewise function,
[0030] The first piecewise function is used to process the pixel value of the low gray level, and the weight coefficient of the first piecewise function is the ratio of the value corresponding to the N+2th item to the first calculated value;
[0031] The second piecewise function is used to process the pixel value of the medium grayscale level, and the weight coefficient of the second piecewise function is the ratio of the value corresponding to the N+1th item to the first calculated value;
[0032] The third piecewise function is used to process pixel values with high grayscale levels, and the weight coefficient of the third piecewise function is the ratio of the value corresponding to the Nth item to the first calculated value.
[0033] In this embodiment, by dividing the grayscale into three intervals of low, medium and high, and applying different piecewise functions for processing respectively, fine control of pixel values in different grayscale areas can be achieved. By using the Fibonacci sequence to set different weight coefficients for different piecewise functions, precise adjustment of the contrast enhancement degree of different grayscale areas can be achieved, which helps to avoid excessive enhancement or weakening of the contrast of certain areas, thereby maintaining the naturalness and realism of the image and better retaining the detailed information in the image, such as edges, textures, etc.
[0034] In some optional embodiments, the adjusting the grayscale histogram by using a preset kernel function includes:
[0035] Determine a grayscale transformation function with the goal of minimizing the difference between the cumulative histogram of the grayscale histogram of the image to be processed and the cumulative histogram of the normalized histogram after grayscale transformation using the kernel function;
[0036] The grayscale transformation function is used to map the grayscale histogram of the image to be processed in the form of the kernel function to obtain the standardized histogram.
[0037] In this embodiment, by minimizing the difference between the cumulative histograms, it is possible to ensure that the grayscale transformation function more accurately reflects the grayscale distribution characteristics of the image to be processed, which helps to maintain the detail information in the image and avoid the loss of important information during the grayscale transformation process. At the same time, since the normalized histogram is obtained by mapping based on the kernel function, it is possible to ensure that the adjusted image is more in line with the preset requirements in terms of contrast, brightness, etc.
[0038] In some optional embodiments, performing edge enhancement processing on the adjusted image to obtain a processed target image includes:
[0039] Converting the adjusted image into a pixel matrix;
[0040] A Sobel operator is used to perform a convolution operation with the pixel matrix to perform edge enhancement processing on the adjusted image to obtain the target image.
[0041] In this embodiment, the Sobel operator can perform a certain degree of smoothing on noise while detecting edges, thereby improving the accuracy and reliability of edge detection. The calculation process of the Sobel operator is relatively simple and has high computational efficiency, so that the edge enhancement process can be completed in a relatively short time, meeting application scenarios with high real-time requirements.
[0042] In some optional embodiments, after performing grayscale transformation on the image to be processed, obtaining a grayscale histogram of the image to be processed includes:
[0043] Performing grayscale transformation on the image to be processed to obtain a first image;
[0044] Performing grayscale enhancement on the first image by using gamma transformation to obtain a second image;
[0045] A grayscale histogram of the second image is obtained as the grayscale histogram of the image to be processed.
[0046] In this embodiment, the image to be processed is converted from a color or original grayscale level to a new grayscale level through grayscale transformation, which helps to unify the grayscale representation of the image and provide consistent input for subsequent processing. The gamma transformation further nonlinearly adjusts the grayscale to enhance the contrast of the image, especially the details of the dark and bright parts. This enhancement enables the grayscale histogram to more accurately reflect the grayscale distribution of the image, providing more reliable information for subsequent image processing tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] One or more embodiments are exemplarily described by the pictures in the corresponding drawings, and these exemplary descriptions do not constitute limitations on the embodiments.
[0048] Figure 1 This is a flow chart of an image processing method provided by an embodiment of the present application. Figure 1 ;
[0049] Figure 2 This is a flow chart of an image processing method provided by an embodiment of the present application. Figure 2 ;
[0050] Figure 3is an image after grayscale enhancement processing provided by an embodiment of the present application;
[0051] Figure 4 An embodiment of the present application provides Figure 1 Comparison chart before and after histogram normalization;
[0052] Figure 5 An embodiment of the present application provides Figure 1 The corresponding kernel function;
[0053] Figure 6 An embodiment of the present application provides Figure 2 Comparison chart before and after histogram normalization;
[0054] Figure 7 An embodiment of the present application provides Figure 2 The corresponding kernel function;
[0055] Figure 8 An embodiment of the present application provides Figure 3 Comparison chart before and after histogram normalization;
[0056] Fig. 9 An embodiment of the present application provides Figure 3 The corresponding kernel function;
[0057] Fig.10 An embodiment of the present application provides Figure 4 Comparison chart before and after histogram normalization;
[0058] Fig.11 An embodiment of the present application provides Figure 4 The corresponding kernel function;
[0059] Fig.12 is a structural schematic diagram of an image processing system provided by an embodiment of the present application;
[0060] Fig.13 It is a schematic diagram of an image processing device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0061] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the present application, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can also be implemented. The division of the following embodiments is for the convenience of description, and the specific implementation of the present application should not be construed as any limitation, and the various embodiments can be combined and referenced with each other under the premise of no contradiction.
[0062] In order to facilitate understanding of the embodiments of the present application, relevant content about image processing is first introduced here.
[0063] With the popularization of automobiles and the rapid development of highways, the speed of automobiles has also increased. When driving at night, there are problems such as uneven brightness distribution, weak light, generally dark image acquisition information, and reduced visibility in night road images, which often lead to low quality of acquired images, insufficient clarity, and blurred images, which can easily cause cars to hit obstacles, resulting in vehicle damage and traffic accidents. Therefore, it is of great significance to improve the driver's ability to recognize road conditions.
[0064] In the prior art, the image enhancement methods used generally include gamma transform, histogram equalization, histogram normalization, edge detection algorithms, etc. In actual processing, multiple image processing methods are often combined and used in combination to increase image clarity and better show the outlines of objects in night scenes.
[0065] However, the existing histogram normalization processing usually relies on fixed grayscale mapping functions or transformation rules to adapt to specific images or application requirements. Therefore, it is easy to lack sufficient adaptability and flexibility when processing images with different grayscale distribution characteristics, resulting in the normalized image still not meeting expectations in some aspects, resulting in segmentation errors, loss of details and other problems.
[0066] In order to solve the technical problem that the above-mentioned image enhancement method is prone to segmentation errors, detail loss, etc., and therefore it is difficult to clearly show the outlines of objects in night scenes, the present invention proposes an image processing method. The implementation details of the image processing method of this embodiment are specifically described below. The following content is only the implementation details provided for ease of understanding and is not necessary for the implementation of this solution.
[0067] Embodiment 1:
[0068] The image processing method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities. The specific process can be as follows: Figure 1 As shown, including:
[0069] Step 110, obtaining an image to be processed;
[0070] In this embodiment, an image acquisition device (such as a camera, scanner, driving recorder, etc.) or an image loading tool (such as an image browser, image editing software, etc.) is used to obtain the image to be processed. Ensure that the format and resolution of the acquired image meet the requirements of subsequent processing. Load the image data into the memory or image processing software for subsequent operations.
[0071] The image to be processed can be a natural scene image, such as a landscape photo, a portrait photo, or a nighttime road photo, or a medical image such as an X-ray, CT scan, or MRI image, which usually has specific grayscale distribution and texture features. The image to be processed needs to be processed by grayscale transformation and contrast enhancement to improve the visual effect.
[0072] Step 120, after grayscale transformation of the image to be processed, a grayscale histogram of the image to be processed is obtained;
[0073] In this embodiment, the image to be processed is converted from the color space to the gray space to obtain a gray image, which can be achieved by using a gray transformation formula (such as a weighted average method, a maximum method, a minimum method, etc.). A gray histogram is a statistical chart that shows the number of pixels at each gray level (or gray range) in an image. A gray histogram can be obtained by traversing each pixel of the gray image, counting the number of pixels at each gray level, and then drawing a histogram.
[0074] Step 130, using the Fibonacci sequence to divide the grayscale of the grayscale histogram to obtain a grayscale division result;
[0075] The Fibonacci sequence is also known as the golden section sequence, which is defined as the first two numbers are both 1, and starting from the third number, each number is the sum of the first two numbers. That is, F(n) = F(n-1) + F(n-2), where F(1) = F(2) = 1. Based on the unique growth characteristics and mathematical beauty of the Fibonacci sequence, in this embodiment, the Fibonacci sequence is applied to image processing for grayscale division.
[0076] Specifically, first, determine the grayscale range of the grayscale image, usually 0 to 255 (for 8-bit grayscale images). Then, according to the characteristics of the Fibonacci sequence, divide the grayscale into multiple intervals. The boundaries of these intervals can be determined by the values in the Fibonacci sequence, or the values of the Fibonacci sequence can be mapped to the grayscale range through a certain mapping relationship. For example, the first N items of the Fibonacci sequence (N is determined according to actual needs) can be mapped to the grayscale range to form N-1 segmentation points, thereby dividing the grayscale into N intervals.
[0077] Next, the starting grayscale value, ending grayscale value and number of pixels in each grayscale interval are recorded to obtain the grayscale classification result. This information will be used to define and adjust the kernel function in the subsequent steps.
[0078] In this embodiment, grayscale division is performed by the Fibonacci sequence, and grayscale intervals can be allocated in a mathematically elegant and non-uniform manner. The growth characteristics of the Fibonacci sequence make the lower grayscale intervals narrower and the higher grayscale intervals wider, which helps to achieve a balance between low-grayscale areas with rich details and high-grayscale areas where contrast needs to be enhanced.
[0079] Step 140, based on the grayscale classification result, the grayscale histogram is adjusted using a preset kernel function to obtain a normalized histogram, and an adjusted image is generated based on the normalized histogram.
[0080] In this embodiment, the kernel function is a piecewise function, the number of the piecewise functions is consistent with the number of the gray levels, and each gray level corresponds to a piecewise function for targeted adjustment.
[0081] In some optional embodiments, each piecewise function corresponds to a weight coefficient, the weight coefficient is calculated based on the Fibonacci sequence, and the weight coefficient is used to adjust the contrast enhancement degree of the grayscale domain of different grayscale levels. The shape and parameters of the piecewise function can be defined according to actual needs. The weight coefficient is calculated based on the Fibonacci sequence and is used to adjust the contrast enhancement degree of the grayscale domain of different grayscale levels. The calculation of the weight coefficient can be based on a certain item or a combination of several items of the Fibonacci sequence, or the value of the Fibonacci sequence can be mapped to the range of the weight coefficient through a certain mapping relationship. The size and distribution of the weight coefficient will affect the contrast enhancement effect between different grayscale levels.
[0082] According to the grayscale division result and the definition of the kernel function, the grayscale histogram is adjusted. Specifically, for each pixel in the grayscale interval, the adjusted grayscale value is calculated according to its original grayscale value and the definition of the kernel function. Then, the number of pixels corresponding to the grayscale level in the grayscale histogram is updated. According to the adjusted grayscale histogram, an adjusted image is generated. The adjusted image will have enhanced contrast and more uniform grayscale distribution.
[0083] Based on the grayscale classification result, the grayscale histogram is adjusted using a preset piecewise kernel function, and the contrast of different grayscale levels is enhanced by combining the weight coefficient calculated by the Fibonacci sequence. This setting brings at least the following beneficial effects:
[0084] 1) Fine contrast adjustment:
[0085] Each grayscale level corresponds to a piecewise function, which enables fine contrast adjustment for each grayscale interval. By designing different piecewise functions for different grayscale levels, the contrast enhancement strategy can be customized for a specific grayscale range, thereby achieving a more delicate and natural image processing effect.
[0086] 2) Intelligent allocation of weight coefficients:
[0087] The weight coefficient is calculated based on the Fibonacci sequence, which not only provides a mathematical basis for contrast enhancement of different gray levels, but also makes the distribution of weight coefficients more reasonable and orderly. The characteristics of the Fibonacci sequence make the weight coefficient show a natural growth trend in the sequence, which helps to enhance the details of specific gray areas while maintaining the overall contrast balance of the image.
[0088] 3) Enhanced image visual effects:
[0089] The grayscale histogram adjusted by the above method will have a more uniform and reasonable grayscale distribution, which can not only improve the contrast of the image, but also enhance the detail visibility and overall visual effect of the image. Especially when processing images with low contrast or blurred details, the method of this embodiment can significantly improve the clarity and readability of the image.
[0090] 4) Flexibility and scalability:
[0091] The method of this embodiment allows the piecewise function and weight coefficient to be adjusted and optimized according to actual needs. For example, the grayscale division accuracy and the degree of contrast enhancement can be adjusted by changing the starting term or number of terms of the Fibonacci sequence. In addition, other mathematical tools or algorithms can be introduced to further expand and optimize the performance and application scope of the method.
[0092] In summary, the method proposed in this embodiment for adjusting the grayscale histogram based on the grayscale division result using the piecewise kernel function and the Fibonacci series weight coefficient has significant advantages and potential in the field of image processing. It can not only improve the contrast and detail visibility of the image, but also realize adaptive grayscale division and fine contrast adjustment, providing better ideas and methods for image processing and visual analysis.
[0093] Step 150: perform edge enhancement processing on the adjusted image to obtain a processed target image.
[0094] In this embodiment, the Sobel operator, Prewitt operator, Laplacian operator, etc. may be selected to perform edge enhancement processing on the adjusted image to further enhance the contrast, brightness, etc. of the edge image. Alternatively, edge enhancement may be achieved by superimposing the edge image with the adjusted image.
[0095] The processed target image is obtained, which has enhanced edge features and contrast, so that the contours of objects in the image can be better identified.
[0096] In summary, the image processing method provided in this embodiment achieves effective improvement of image contrast and clarity by combining grayscale transformation, grayscale level division and kernel function adjustment based on the Fibonacci sequence, and edge enhancement processing. The application of the Fibonacci sequence makes the grayscale level division more reasonable, while the introduction of piecewise functions and weight coefficients ensures the naturalness and significance of contrast enhancement. Edge enhancement processing further enhances the visual effect of the image, making it more suitable for nighttime application scenes, thereby making the outlines of objects in nighttime scene pictures clearer, making it easier for the human eye to observe road details, thereby improving the safety of nighttime driving.
[0097] In some embodiments, the grayscale levels of the grayscale histogram are divided by using the Fibonacci sequence to obtain a grayscale level division result, including: summing the Nth item, the N+1th item, and the N+2th item in the Fibonacci sequence to obtain a first calculated value; calculating a first ratio of a value corresponding to the Nth item to the first calculated value, and obtaining a first grayscale domain segmentation threshold according to the product of the first ratio and a preset maximum grayscale value; calculating a second ratio of the sum of the value corresponding to the Nth item and the value corresponding to the N+1th item to the first calculated value, and obtaining a second grayscale domain segmentation threshold according to the product of the second ratio and the maximum grayscale value; based on the first grayscale domain segmentation threshold and the second grayscale domain segmentation threshold, combined with the grayscale mean of the grayscale histogram of the image to be processed, the grayscale levels of the grayscale histogram are divided into low grayscale levels, medium grayscale levels, and high grayscale levels.
[0098] Specifically, the following division method can be adopted:
[0099] Known Fibonacci numbers
[0100] fib = [1,1,2,3,5];
[0101] By dividing the grayscale of the 3rd, 4th, and 5th items of the Fibonacci sequence, we can get
[0102] sum_fib=fib(3)+fib(4)+fib(5);
[0103] hx=1:256;
[0104] Define the first grayscale domain segmentation threshold
[0105] x1=fix(fib(3) / sum_fib*256);
[0106] Define the second grayscale domain segmentation threshold
[0107] x2=fix((fib(3)+fib(4)) / sum_fib*256);
[0108] Wherein, hx is used to represent the grayscale from 0 to 255. According to the first grayscale domain segmentation threshold x1 and the second grayscale domain segmentation threshold x2, the grayscale is divided into low grayscale, medium grayscale and high grayscale, where,
[0109] The grayscale domain corresponding to the low grayscale level is the grayscale element in the range of 1 to x1;
[0110] The grayscale domain corresponding to the medium grayscale level is the grayscale element in the range from x1 to x2;
[0111] The grayscale domain corresponding to the high grayscale level is the grayscale element in the range of x2 to 256.
[0112] It can be understood that x1 and x2 calculated in the above process are fixed values, which is an unchanging and standardized grayscale classification method. After that, by combining x1 and x2 with the grayscale mean (mean_hist) of the grayscale histogram of the image to be processed (or using the grayscale mean of the grayscale histogram of the image to be processed as an adjustment coefficient), it can be adaptive to the target image to be processed, so that the grayscale classification results of each image are different.
[0113] In this embodiment, by using the Fibonacci sequence to divide the grayscale levels, it can be ensured that the division result is more in line with mathematical laws and natural laws, thereby improving the rationality and scientificity of the division. In addition, the numerical growth rate of the Fibonacci sequence is moderate, which is neither too fast to cause the division to be too detailed nor too slow to cause the division to be too rough. This moderate growth rate enables the division result to adapt to the distribution characteristics of the grayscale histogram, thereby more accurately reflecting the grayscale information of the image.
[0114] Using the grayscale mean as an adjustment coefficient helps maintain the naturalness of the image. As a statistical feature of image brightness, the grayscale mean can reflect the overall brightness distribution of the image. By using it as an adjustment coefficient, the adjusted image can be closer to the original image in brightness, avoiding image distortion or exaggeration caused by excessive adjustment, and improving the versatility and applicability of image processing.
[0115] In some optional embodiments, the kernel function is set as follows: the kernel function includes a first piecewise function, a second piecewise function and a third piecewise function, wherein the first piecewise function is used to process the pixel values of the low grayscale level, and the weight coefficient of the first piecewise function is the ratio of the value corresponding to the N+2th item to the first calculated value; the second piecewise function is used to process the pixel values of the medium grayscale level, and the weight coefficient of the second piecewise function is the ratio of the value corresponding to the N+1th item to the first calculated value; the third piecewise function is used to process the pixel values of the high grayscale level, and the weight coefficient of the third piecewise function is the ratio of the value corresponding to the Nth item to the first calculated value.
[0116] In this embodiment, by dividing the grayscale into three intervals of low, medium and high, and applying different piecewise functions for processing respectively, fine control of pixel values in different grayscale areas can be achieved. By using the Fibonacci sequence to set different weight coefficients for different piecewise functions, precise adjustment of the contrast enhancement degree of different grayscale areas can be achieved, which helps to avoid excessive enhancement or weakening of the contrast of certain areas, thereby maintaining the naturalness and realism of the image and better retaining the detailed information in the image, such as edges, textures, etc.
[0117] Specifically, the following method can be used to set the weight coefficient:
[0118] Known Fibonacci numbers
[0119] fib = [1,1,2,3,5];
[0120] sum_fib=fib(3)+fib(4)+fib(5);
[0121] The weight coefficient of the first piecewise function hgram(1:x1) is fib(5) / sum_fib;
[0122] The weight coefficient of the second piecewise function hgram(x1:x2) is fib(4) / sum_fib;
[0123] The weight coefficient of the second piecewise function hgram(x2:256) is (fib(3) / sum_fib).
[0124] In some optional embodiments, the 5th, 6th, and 7th items of the Fibonacci sequence may also be used to set the weight coefficients, depending on actual adjustment requirements, which are not specifically limited here.
[0125] In some optional embodiments, each of the piecewise functions further uses the grayscale mean of the grayscale histogram of the image to be processed as an adjustment coefficient to adjust the grayscale histogram of the image to be processed.
[0126] In this embodiment, using the grayscale mean as the adjustment coefficient helps to maintain the naturalness of the image. The grayscale mean, as a statistical feature of image brightness, can reflect the overall brightness distribution of the image. By using it as the adjustment coefficient, the adjusted image can be closer to the original image in brightness, avoiding image distortion or exaggeration caused by excessive adjustment, and improving the versatility and applicability of image processing.
[0127] For example, the numerical vector of the kernel function looks like this:
[0128] hgram(1:x1)=1-(1 / mean_hist)*(fib(5) / sum_fib)*(hx(1:x1). / 256);
[0129] hgram(x1:x2)=1-(1 / mean_hist)*(fib(4) / sum_fib)*hx(x1:x2). / 256;
[0130] hgram(x2:256)=1-(1 / mean_hist)*(fib(3) / sum_fib)*hx(x2:256). / 256;
[0131] The kernel function has a high threshold in the low frequency band of hgram(), which can fully preserve the dark details of the dark night image. The mid-frequency band maintains balanced output, most of the image content is restored, and the high frequency band changes from high to low, which can ensure that details are not lost while minimizing the deterioration of the image equalization effect caused by overexposure.
[0132] In some optional embodiments, the grayscale histogram is adjusted using a preset kernel function, including: determining a grayscale transformation function with the goal of minimizing the difference between the cumulative histogram of the grayscale histogram of the image to be processed and the cumulative histogram of the standardized histogram after grayscale transformation using the kernel function; using the grayscale transformation function, mapping the grayscale histogram of the image to be processed in the form of the kernel function to obtain the standardized histogram.
[0133] In this embodiment, by minimizing the difference between the cumulative histograms, it is possible to ensure that the grayscale transformation function more accurately reflects the grayscale distribution characteristics of the image to be processed, which helps to maintain the detail information in the image and avoid the loss of important information during the grayscale transformation process. At the same time, since the normalized histogram is obtained by mapping based on the kernel function, it is possible to ensure that the adjusted image is more in line with the preset requirements in terms of contrast, brightness, etc.
[0134] Specifically, the implementation method is as follows:
[0135] The grayscale transformation T is chosen to minimize |c1(T(k))-c0(k)|. Here c0 is the cumulative histogram of the grayscale histogram of the image to be processed, and c1 is the cumulative sum over all intensities k in the kernel function. This minimization is subject to the following constraints: T must be monotonic, and c1(T(a)) cannot overshoot c0(a) by more than half the difference between the histogram counts at a.
[0136] After that, the gray levels in the grayscale histogram of the image to be processed are mapped to their new values using the transformation b=T(a). Histogram normalization is to enhance the contrast within a certain grayscale value range through the grayscale mapping function so that the distribution of the image grayscale values can meet the requirements. The details are as follows:
[0137] 1) List the grayscale levels k of the grayscale histogram of the image to be processed, k = 0, 1, 2, ..., L-1, L is the number of grayscale levels, and the normalized expression of the k-th grayscale value is s k , the number of grayscale pixels is n k , and obtain the normalized probability expression of the grayscale statistical histogram:
[0138] P s (S k )=n k / N
[0139] Where N is the number of pixels in the grayscale histogram of the image to be processed, and the grayscale cumulative histogram is calculated based on the cumulative distribution function:
[0140]
[0141] 2) List the gray levels I of the standardized histogram, I = 0, 1, 2, ..., M-1, M is the number of gray levels, and the normalized expression of the gray value of level I is t l , the normalized probability expression of the grayscale statistical histogram:
[0142] P t (t l )=n l / N
[0143] Calculate the grayscale cumulative histogram of the normalized histogram based on the cumulative distribution function:
[0144]
[0145] 3) Using the grayscale mapping rule, calculate the normalized expression of the grayscale value corresponding to each grayscale level of the output image after mapping t k , determine the mapping relationship S k ->t k , the number of pixels at each gray level after statistical mapping n l, and obtain the normalized probability expression of the new grayscale statistical histogram:
[0146] p t (t l )=n l / N
[0147] In some optional embodiments, the edge enhancement processing is performed on the adjusted image to obtain a processed target image, including: converting the adjusted image into a pixel matrix; performing a convolution operation with the pixel matrix using a Sobel operator to perform edge enhancement processing on the adjusted image to obtain the target image.
[0148] In this embodiment, the Sobel edge detection algorithm based on digital image convolution determines whether the pixel is located on the boundary of an object by detecting the state of each pixel and its neighborhood. The Sobel edge detection algorithm includes two 3*3 matrices, and the pixels are slide-detected in the horizontal and vertical directions. The Sobel operator is used to perform a plane convolution with the image to obtain the horizontal and vertical brightness difference approximations.
[0149] While detecting edges, the Sobel operator can also smooth noise to a certain extent, thereby improving the accuracy and reliability of edge detection. The calculation process of the Sobel operator is relatively simple and has high computational efficiency, so that edge enhancement processing can be completed in a shorter time, meeting application scenarios with high real-time requirements.
[0150] In some optional embodiments, after performing grayscale transformation on the image to be processed, obtaining a grayscale histogram of the image to be processed includes: performing grayscale transformation on the image to be processed to obtain a first image; performing grayscale enhancement on the first image using gamma transformation to obtain a second image; and obtaining a grayscale histogram of the second image as the grayscale histogram of the image to be processed.
[0151] In this embodiment, the image to be processed is converted from a color or original grayscale level to a new grayscale level through grayscale transformation, which helps to unify the grayscale representation of the image and provide consistent input for subsequent processing. The gamma transformation further nonlinearly adjusts the grayscale to enhance the contrast of the image, especially the details of the dark and bright parts. This enhancement enables the grayscale histogram to more accurately reflect the grayscale distribution of the image, providing more reliable information for subsequent image processing tasks.
[0152] Embodiment 2:
[0153] Based on the above embodiment, this embodiment provides an application example, which is applied to the enhancement processing of nighttime road images. The specific process can be as follows: Figure 2 As shown, including:
[0154] Step 210, obtaining an image to be processed;
[0155] Step 220, grayscale conversion;
[0156] Step 230, using the 3rd and 4th items of the Fibonacci sequence to divide the grayscale levels of the histogram,
[0157] Step 240, using piecewise function to perform adaptive algorithm processing;
[0158] Step 250, converting the image into a matrix;
[0159] Step 260, convolve the image using a Sobel operator;
[0160] Step 270, the edge on the image is consistent with the edge of the operator, and the edge is deepened;
[0161] Step 280, extracting the edge image;
[0162] Step 290, identifying a vehicle or obstacle with a clear outline.
[0163] Specifically, in step 210-step 220, based on the grayscale enhancement of LabVIEW, the image is grayed, an image is read in, and the RGB color mode uses the additive color model, that is, the image is processed by the three components of R, G, and B. R, G, and B represent the red primary color channel, the green primary color channel, and the blue primary color channel, respectively. The red primary color channel, the green primary color channel, and the blue primary color channel are made to have the same value, and the RGB image is converted into a gray image. The color image is grayed by using the weighted average method. The weighted average of the three RGB components can be used to obtain a more reasonable grayscale image according to the following formula:
[0164] f(i,j)=0.30R(i,j)+0.59G(i,j)+0.11B(i,j)
[0165] Using LabVIEW software, the collected RGB color image is converted into a gray image, and the image is enhanced in grayscale based on the mathematical principle of gamma transformation. Figure 3 shown.
[0166] In step 220, since the image after grayscale enhancement processing by LabVIEW software cannot achieve the purpose of balancing the overall brightness of the image, widening the dark details, brightening the image, and facilitating the human eye to observe the road details, MATLAB is used to use an adaptive histogram normalization method based on Fibonacci series segmentation. The histogram of the original image is normalized according to the defined kernel function, so that the histogram of the target function satisfies the kernel function trend, so as to achieve the functions of improving the image contrast and brightness, enhancing the dark details of the image, etc.
[0167] In step 230-step 240, the grayscale of the histogram is divided into three frequency domains of high, medium and low using the 3rd and 4th items of the Fibonacci sequence, and then the adaptive algorithm is processed using the piecewise function. The weight of each segment of the piecewise function is processed according to the coefficient of the 3rd, 4th and 5th items of the Fibonacci sequence. At the same time, the kernel function hgram() uses the average grayscale of the original image as the coefficient factor to achieve adaptive adaptation of different images. The specific implementation process is as follows:
[0168] Known Fibonacci numbers
[0169] fib = [1,1,2,3,5];
[0170] Summing the 3rd, 4th, and 5th terms of the Fibonacci sequence, we get
[0171] sum_fib=fib(3)+fib(4)+fib(5);
[0172] Define the hgram() function
[0173] hx=1:256;
[0174] Define the first grayscale domain segmentation threshold
[0175] x1=fix(fib(3) / sum_fib*256);
[0176] Define the second grayscale domain segmentation threshold
[0177] x2=fix((fib(3)+fib(4)) / sum_fib*256);
[0178] Generate hgram numeric vector
[0179] hgram(1:x1)=1-(1 / mean_hist)*(fib(5) / sum_fib)*(hx(1:x1). / 256);
[0180] hgram(x1:x2)=1-(1 / mean_hist)*(fib(4) / sum_fib)*hx(x1:x2). / 256;
[0181] hgram(x2:256)=1-(1 / mean_hist)*(fib(3) / sum_fib)*hx(x2:256). / 256;
[0182] The grayscale transformation T is chosen to minimize |c1(T(k))-c0(k)|,
[0183] where c0 is the cumulative histogram of the input image I and c1 is the cumulative sum over all intensities k in hgram. This minimization is subject to the following constraints: T must be monotonic and c1(T(a)) cannot overshoot c0(a) by more than half the difference between the histogram counts at a. A transformation b=T(a) is used to map the gray levels in x (or the color map) to their new values.
[0184] The above-mentioned adaptive histogram specification method based on Fibonacci sequence segmentation is used to process the first image. The image before and after processing and the histogram are as follows: Figure 4 As shown, the corresponding kernel function is Figure 5 shown.
[0185] Process the second image, the image before and after processing and the histogram are as follows Figure 6 As shown, the corresponding kernel function is Figure 7 shown.
[0186] Process the third image. The image before and after processing and the histogram are as follows: Figure 8 As shown, the corresponding kernel function is Fig. 9 ,
[0187] Process the fourth image. The image before and after processing and the histogram are as follows: Fig.10 As shown, the corresponding kernel function is Fig.11 shown.
[0188] In step 250-step 290, LabVIEW and MATLAB are used to design a Sobel edge detection algorithm based on digital image convolution. A MATLAB program script is added to the LabVIEW program to determine whether the pixel is located on the boundary of an object by detecting the state of each pixel and its neighborhood. The Sobel edge detection algorithm is used, which contains two 3*3 matrices, and the pixels are slide-detected in the horizontal and vertical directions. The Sobel operator is used to perform a plane convolution with the image to obtain the horizontal and vertical brightness difference approximations. If A represents the original image, Gx and Gy represent the images after horizontal and vertical edge detection, respectively, the formula is as follows:
[0189]
[0190] The gradient represents the edge strength and direction of an image ▽f outside the (x, y) position.
[0191] The magnitude and direction of the gradient vector are as follows:
[0192]
[0193]
[0194] After the image is converted into a matrix, the Sobel operator is used for convolution. The corresponding elements in the covered area are multiplied, and then the 9 values are added as a pixel value and assigned to the output matrix. However, this will cause the image to become smaller, so 0 is added around the image matrix and then the operation is performed again. The operator convolves the image, and the places where there are elements will be strengthened. After convolution, the edges on the image are consistent with the edges of the operator, and the edges are deepened. The edge image is extracted, and vehicles or obstacles with obvious outlines can be identified, so that the outline of the night road is enhanced and the edge information of the night road can be identified.
[0195] The following is the road edge detection program code based on the Sobel operator.
[0196] HEAD=1;
[0197] TAIL = 367500 * 3;
[0198] i=HEAD+3;
[0199] pic=zeros(1,367500*3)
[0200] while i <TAIL
[0201] pic(i)=img(1,i);
[0202] i=i+3;
[0203] end
[0204] pit1 = edge(pic,'sobel');
[0205] img = 255 * pit1;
[0206] like Fig.12 As shown, it is a structural diagram of the image processing system of this embodiment.
[0207] In this embodiment, an image processing system is provided by using LabVIEW and MATLAB in combination, which is applied to the enhancement processing of night road images, the purpose of which is to balance the overall brightness of the image, widen the dark details, make the image brighter, and facilitate the human eye to observe the road details. The present invention adopts two schemes in the enhancement of night road images. The first scheme is to grayscale the image after graying it based on LabVIEW and relying on the mathematical principle of gamma transformation. The second is based on an adaptive histogram regulation method based on Fibonacci sequence segmentation, and the histogram of the original image is regulated according to the defined kernel function, so that the histogram of the target function satisfies the kernel function trend, so as to achieve the functions of improving image contrast and brightness, enhancing the dark details of the image, and giving full play to the ease of use of MATLAB for image processing. And using the edge detection algorithm, the Sobel edge detection algorithm based on digital image convolution is adopted to enhance the contour of the night road. The Sobel operator can be more easily realized in space, better handle images with more interference information and grayscale gradient, and identify some non-convex obstacle road conditions such as concave road surfaces through edge detection, and identify the edge information of the night road.
[0208] Embodiment three:
[0209] Another embodiment of the present application relates to an image processing device. The implementation details of the image processing device of this embodiment are described in detail below. The following content is only provided for the convenience of understanding the implementation details and is not necessary for implementing this solution. The schematic diagram of the image processing device of this embodiment can be as follows Fig.13 As shown, it includes an acquisition module 1310, a grayscale histogram acquisition module 1320, a grayscale level division module 1330, a histogram specification module 1340 and an edge enhancement module 1350.
[0210] An acquisition module 1310 is used to acquire an image to be processed;
[0211] A grayscale histogram acquisition module 1320 is used to acquire a grayscale histogram of the image to be processed after performing grayscale transformation on the image to be processed;
[0212] A grayscale classification module 1330 is used to classify the grayscale of the grayscale histogram using the Fibonacci sequence to obtain a grayscale classification result;
[0213] A histogram regulation module 1340 is used to adjust the grayscale histogram based on the grayscale classification result using a preset kernel function to obtain a regulated histogram, and generate an adjusted image based on the regulated histogram;
[0214] The edge enhancement module 1350 is used to perform edge enhancement processing on the adjusted image to obtain a processed target image.
[0215] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed by this application, but this does not mean that there are no other units in this embodiment.
[0216] Embodiment 4:
[0217] Another embodiment of the present application relates to a driving assistance system, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the image processing method in the above-mentioned embodiments.
[0218] Among them, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor.
[0219] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.
[0220] Embodiment five:
[0221] Another embodiment of the present application relates to a computer-readable storage medium storing a computer program, which implements the above method embodiment when executed by a processor.
[0222] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as: ROM), random access memory (Random Access Memory, referred to as: RAM), disk or optical disk and other media that can store program codes.
[0223] Those skilled in the art will appreciate that the above embodiments are specific embodiments for implementing the present application, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present application.
Claims
1. An image processing method, characterized in that: include: Get the image to be processed; After performing grayscale transformation on the image to be processed, a grayscale histogram of the image to be processed is obtained; Using the Fibonacci sequence to divide the grayscale levels of the grayscale histogram to obtain a grayscale level division result; Based on the grayscale classification result, the grayscale histogram is adjusted using a preset kernel function to obtain a standardized histogram, and an adjusted image is generated based on the standardized histogram; The adjusted image is subjected to edge enhancement processing to obtain a processed target image.
2. The image processing method according to claim 1, characterized in that: The kernel function is a piecewise function, the number of the piecewise functions is consistent with the number of the grayscale levels, each grayscale level corresponds to a piecewise function for adjustment, each piecewise function corresponds to a weight coefficient, and the weight coefficient is calculated based on the Fibonacci sequence. The weight coefficient is used to adjust the contrast enhancement degree of the grayscale domain of different grayscale levels.
3. The image processing method according to claim 1, characterized in that: The grayscale histogram is divided into grayscale levels by using the Fibonacci sequence to obtain a grayscale level division result, including: The Nth term, the N+1th term, and the N+2th term in the Fibonacci sequence are summed to obtain a first calculated value; Calculating a first ratio of the value corresponding to the Nth item to the first calculated value, and obtaining a first grayscale domain segmentation threshold according to the product of the first ratio and a preset maximum grayscale value; Calculate a second ratio of the sum of the value corresponding to the Nth item and the value corresponding to the N+1th item to the first calculated value, and obtain a second grayscale domain segmentation threshold according to the product of the second ratio and the maximum value of the grayscale value; Based on the first grayscale domain segmentation threshold and the second grayscale domain segmentation threshold, combined with the grayscale mean of the grayscale histogram of the image to be processed, the grayscale levels of the grayscale histogram are divided into low grayscale levels, medium grayscale levels and high grayscale levels.
4. The image processing method according to claim 2, characterized in that: The kernel function is set as follows: The kernel function includes a first piecewise function, a second piecewise function and a third piecewise function, The first piecewise function is used to process the pixel value of the low gray level, and the weight coefficient of the first piecewise function is the ratio of the value corresponding to the N+2th item to the first calculated value; The second piecewise function is used to process the pixel value of the medium grayscale level, and the weight coefficient of the second piecewise function is the ratio of the value corresponding to the N+1th item to the first calculated value; The third piecewise function is used to process pixel values with high grayscale levels, and the weight coefficient of the third piecewise function is the ratio of the value corresponding to the Nth item to the first calculated value.
5. The image processing method according to claim 1, characterized in that: The step of adjusting the grayscale histogram by using a preset kernel function includes: Determine a grayscale transformation function with the goal of minimizing the difference between the cumulative histogram of the grayscale histogram of the image to be processed and the cumulative histogram of the normalized histogram after grayscale transformation using the kernel function; The grayscale transformation function is used to map the grayscale histogram of the image to be processed in the form of the kernel function to obtain the standardized histogram.
6. The image processing method according to claim 1, characterized in that: The step of performing edge enhancement processing on the adjusted image to obtain a processed target image includes: Converting the adjusted image into a pixel matrix; A Sobel operator is used to perform a convolution operation with the pixel matrix to perform edge enhancement processing on the adjusted image to obtain the target image.
7. The image processing method according to any one of claims 1 to 6, characterized in that: After performing grayscale transformation on the image to be processed, obtaining a grayscale histogram of the image to be processed includes: Performing grayscale transformation on the image to be processed to obtain a first image; Performing grayscale enhancement on the first image by using gamma transformation to obtain a second image; A grayscale histogram of the second image is obtained as the grayscale histogram of the image to be processed.
8. An image processing device, characterized in that: include: An acquisition module, used for acquiring an image to be processed; A grayscale histogram acquisition module, used to acquire a grayscale histogram of the image to be processed after performing grayscale transformation on the image to be processed; A grayscale classification module is used to classify the grayscale of the grayscale histogram using the Fibonacci sequence to obtain a grayscale classification result; A histogram regulation module, configured to adjust the grayscale histogram based on the grayscale classification result using a preset kernel function to obtain a regulated histogram, and generate an adjusted image based on the regulated histogram; The edge enhancement module is used to perform edge enhancement processing on the adjusted image to obtain a processed target image.
9. A driving assistance system, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the image processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 7 is implemented.