[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN116402729A - An image enhancement method and system based on double histogram equalization - Google Patents

An image enhancement method and system based on double histogram equalization Download PDF

Info

Publication number
CN116402729A
CN116402729A CN202310379084.3A CN202310379084A CN116402729A CN 116402729 A CN116402729 A CN 116402729A CN 202310379084 A CN202310379084 A CN 202310379084A CN 116402729 A CN116402729 A CN 116402729A
Authority
CN
China
Prior art keywords
image
histogram
grayscale
gray
original
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310379084.3A
Other languages
Chinese (zh)
Inventor
李冰
叶博文
徐武彬
张登
颜帅禹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangxi University of Science and Technology
Original Assignee
Guangxi University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangxi University of Science and Technology filed Critical Guangxi University of Science and Technology
Priority to CN202310379084.3A priority Critical patent/CN116402729A/en
Publication of CN116402729A publication Critical patent/CN116402729A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/40Image enhancement or restoration using histogram techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • G06T5/94Dynamic range modification of images or parts thereof based on local image properties, e.g. for local contrast enhancement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

本发明公开了一种基于双直方图均衡化的图像增强方法及系统,涉及图像处理技术领域,首先对待处理图像进行灰度处理,并统计得到灰度直方图;采用改进Otsu算法确定最佳分割点,得到目标区域A和背景区域B;确定目标区域A的分割阈值TA以及背景区域B的分割阈值TB;对灰度子直方图进行独立均衡;使用分割阈值TA和TB对所述均衡后的灰度直方图进行过增强抑制,并进行局部灰度修正,得到增强后的图像。本发明可以在保护平均亮度的同时使图像对比度与细节信息都得以增强,同时还能尽量避免噪声的放大,鲁棒性高、稳定性强、适用性广,显著提高图像质量。

Figure 202310379084

The invention discloses an image enhancement method and system based on double histogram equalization, and relates to the technical field of image processing. Firstly, grayscale processing is performed on the image to be processed, and the grayscale histogram is obtained by statistics; the optimal segmentation is determined by an improved Otsu algorithm points to get the target area A and background area B; determine the segmentation threshold T A of the target area A and the segmentation threshold T B of the background area B ; independently equalize the gray sub-histogram; use the segmentation threshold T A and T B to The above equalized gray histogram is over-enhanced and suppressed, and local gray correction is performed to obtain the enhanced image. The invention can enhance the image contrast and detail information while protecting the average brightness, avoid noise amplification as much as possible, has high robustness, strong stability, wide applicability, and significantly improves image quality.

Figure 202310379084

Description

一种基于双直方图均衡化的图像增强方法及系统An image enhancement method and system based on double histogram equalization

技术领域technical field

本发明涉及图像处理技术领域,更具体的说是涉及一种基于双直方图均衡化的图像增强方法及系统。The present invention relates to the technical field of image processing, and more specifically relates to an image enhancement method and system based on double histogram equalization.

背景技术Background technique

我国工业制造业正向着电动化、网联化、智能化转变,基于机器视觉自动化测量既可以缩短测量时间,又可以节省人工成本,是在保证质量的前提下提高效率的重要途径。但是这也对测量系统的精度、速度和自动化水平提出了更高的要求。要不断地提升、优化检测技术,以适应如今正在快速发展的科学技术,探索更快速、精确、高效率又能节省成本的检测方法。my country's industrial manufacturing industry is transforming towards electrification, networking, and intelligence. Automatic measurement based on machine vision can not only shorten the measurement time, but also save labor costs. It is an important way to improve efficiency while ensuring quality. But this also places higher demands on the accuracy, speed and automation level of the measurement system. It is necessary to continuously improve and optimize the detection technology to adapt to the rapid development of science and technology, and explore faster, more accurate, more efficient and cost-effective detection methods.

在工业领域,可以通过机器视觉系统快速实现对目标的测量,然而实际工作中,会由于环境问题(雨、雾、烟尘等)、成像设备问题以及光照问题等导致获得的图像质量低下、对比度较低,不利于后续图像处理。In the industrial field, the measurement of the target can be quickly realized through the machine vision system. However, in actual work, due to environmental problems (rain, fog, smoke, etc.), imaging equipment problems, and lighting problems, the image quality obtained is low and the contrast is low. Low, not conducive to subsequent image processing.

南京理工大学发明了一种基于分块统计的直方图均衡方法(CN 110223241A)。首先对输入图像进行平均分块,切分成M*N块子图像;然后对每块子图像分别进行直方图统计,统计时设定判断条件,对均匀场景和丰富场景进行不同的直方图统计,得到直方图映射函数;再将原图像的像素按照所在位置与邻近块的直方图映射函数值进行双线性插值得到最终映射值。具体流程如图1所示。然而该方法对图像进行全局直方图均衡,容易发生亮度偏移,进行图像增强之后,无法在提高对比度的同时保证增强图像细节。Nanjing University of Science and Technology invented a histogram equalization method based on block statistics (CN 110223241A). First, the input image is divided into blocks on average, and divided into M*N sub-images; then the histogram statistics are performed on each sub-image, and the judgment conditions are set during the statistics, and different histogram statistics are performed on the uniform scene and the rich scene. Obtain the histogram mapping function; then perform bilinear interpolation on the pixels of the original image according to the position and the value of the histogram mapping function of the adjacent block to obtain the final mapping value. The specific process is shown in Figure 1. However, this method performs global histogram equalization on the image, which is prone to brightness shift. After image enhancement, it cannot ensure the enhancement of image details while improving the contrast.

华侨大学发明了一种自适应阈值的全局直方图均衡方法(CN 109801246A)。统计并缩放直方图数据,使其直方图均值为1,进行预处理后经过计算自适应的最佳截断阈值,根据最佳截断阈值对直方图进行截断处理与后处理,计算映射表;对图像进行查表操作,最终得到灰度增强图像。具体流程如图2所示。该方法对输入图像进行平均分块处理,虽然可以有效避免图像细节丢失的问题,但容易产生噪声以及“块效应”,导致处理的图像产生局部失真,处理效果不理想。Huaqiao University invented a global histogram equalization method with adaptive threshold (CN 109801246A). Statistically and scale the histogram data so that the mean value of the histogram is 1. After preprocessing, calculate the adaptive optimal truncation threshold, perform truncation and post-processing on the histogram according to the optimal truncation threshold, and calculate the mapping table; The table lookup operation is performed to finally obtain a gray scale enhanced image. The specific process is shown in Figure 2. This method averagely divides the input image into blocks. Although it can effectively avoid the loss of image details, it is prone to noise and "block effect", which leads to local distortion of the processed image, and the processing effect is not ideal.

在专利一种基于FPGA的低缓存改进型直方图均衡方法及系统(CN 110148101B)中,通过时分复用模块产生时分复用控制信号,缓存控制模块产生三个直方图统计支路缓存的时序控制信号,解决传统图像增强方法中噪声放大、图像失真及细节丢失等问题,但是该方法针对性较强,只适用于应用在可见光和红外图像增强处理中,实时性较差。In the patented FPGA-based low-caching improved histogram equalization method and system (CN 110148101B), the time-division multiplexing control signal is generated by the time-division multiplexing module, and the buffer control module generates three histograms. Statistical branch buffer timing control Signal, to solve the problems of noise amplification, image distortion and loss of details in traditional image enhancement methods, but this method is highly targeted and only applicable to visible light and infrared image enhancement processing, and its real-time performance is poor.

因此,基于现有技术中图像增强处理所存在的技术缺陷,如何提供一种可以在保护平均亮度的同时使图像对比度与细节信息都得以增强、显著提高图像质量的图像增强方法,是本领域技术人员亟需解决的问题。Therefore, based on the technical defects in the image enhancement processing in the prior art, how to provide an image enhancement method that can enhance the image contrast and detail information while protecting the average brightness, and significantly improve the image quality is a technology in the art. Problems that people need to solve urgently.

发明内容Contents of the invention

有鉴于此,本发明提供了一种基于双直方图均衡化的图像增强方法及系统。In view of this, the present invention provides an image enhancement method and system based on double histogram equalization.

为了实现上述目的,本发明提供如下技术方案:In order to achieve the above object, the present invention provides the following technical solutions:

一种基于双直方图均衡化的图像增强方法,包括以下步骤:An image enhancement method based on double histogram equalization, comprising the following steps:

步骤1、获取待处理图像;Step 1, obtain the image to be processed;

步骤2、对所述待处理图像进行灰度处理,得到原始灰度图像F,并对原始灰度图像进行灰度统计得到灰度直方图;Step 2, performing grayscale processing on the image to be processed to obtain an original grayscale image F, and performing grayscale statistics on the original grayscale image to obtain a grayscale histogram;

步骤3、确定原始灰度图像F的最佳分割点Kout,并基于所述最佳分割点Kout将原始灰度图像F按照灰度级分为目标区域A和背景区域B;Step 3. Determine the optimal segmentation point K out of the original grayscale image F, and divide the original grayscale image F into the target area A and the background area B according to the gray level based on the optimal segmentation point K out ;

步骤4、基于所述最佳分割点Kout确定目标区域A的灰度子直方图的分割阈值TA,以及背景区域B的灰度子直方图的分割阈值TBStep 4. Determine the segmentation threshold T A of the grayscale sub-histogram of the target area A and the segmentation threshold T B of the grayscale sub-histogram of the background area B based on the optimal segmentation point K out ;

步骤5、对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡,得到均衡后的灰度直方图PSStep 5. Independently equalize the gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B to obtain the equalized gray level histogram P S ;

步骤6、基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制,得到图像PTStep 6. Based on the segmentation threshold TA and the segmentation threshold TB , perform over-enhancement suppression on the equalized gray histogram PS to obtain an image PT ;

步骤7、对所述图像PT进行局部灰度修正,得到增强后的图像。Step 7. Perform local grayscale correction on the image PT to obtain an enhanced image.

可选的,所述步骤3中,采用改进Otsu算法确定原始灰度图像F的最佳分割点Kout,具体方法如下:Optionally, in the step 3, an improved Otsu algorithm is used to determine the optimal segmentation point K out of the original grayscale image F, and the specific method is as follows:

Kout=argt max G(t);K out = arg t max G(t);

Figure BDA0004171456500000031
Figure BDA0004171456500000031

其中,qA(t)表示阈值t为分割点时,目标区域A所占比例;qB(t)表示阈值t为分割点时,背景区域B所占比例;μA(t)表示阈值t为分割点时,目标区域A的概率;μB(t)表示阈值t为分割点时,背景区域B的概率;

Figure BDA0004171456500000032
表示目标区域A平均方差;/>
Figure BDA0004171456500000033
表示背景区域B平均方差。Among them, q A (t) indicates the proportion of the target area A when the threshold t is the segmentation point; q B (t) indicates the proportion of the background area B when the threshold t is the segmentation point; μ A (t) indicates the threshold t When is the segmentation point, the probability of the target area A; μ B (t) represents the probability of the background area B when the threshold t is the segmentation point;
Figure BDA0004171456500000032
Indicates the average variance of the target area A; />
Figure BDA0004171456500000033
Indicates the mean variance of the background region B.

可选的,所述步骤3中,目标区域A由灰度值在[MIN,Kout]区间的像素组成,背景区域B由灰度值在[Kout+1,MAX]区间内的像素组成,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Optionally, in the step 3, the target area A is composed of pixels whose gray values are in the interval [MIN, K out ], and the background area B is composed of pixels whose gray values are in the interval [K out +1, MAX] , MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the maximum pixel value in the original grayscale image F.

可选的,所述步骤4中,确定分割阈值TA和分割阈值TB的方法为:Optionally, in step 4, the method for determining the segmentation threshold TA and the segmentation threshold TB is:

Figure BDA0004171456500000034
Figure BDA0004171456500000034

其中,TMA表示目标区域A的灰度子直方图的峰值,TMB表示背景区域B的灰度子直方图的峰值,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Among them, TMA represents the peak value of the grayscale sub-histogram of the target area A, TMB represents the peak value of the grayscale sub-histogram of the background area B, MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the original grayscale The maximum pixel value in image F.

可选的,所述步骤5中,对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡的方法为:Optionally, in step 5, the method for independently equalizing the grayscale sub-histogram of the target area A and the grayscale sub-histogram of the background area B is:

Figure BDA0004171456500000041
Figure BDA0004171456500000041

其中,ni表示原始灰度图像F中灰度级i的像素总数,n表示原始灰度图像F中的所有像素总数,PS(i)表示灰度级为i时均衡后的灰度直方图,NA表示目标区域A灰度级总数,NB表示背景区域B的灰度级总数,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Among them, n i represents the total number of pixels of gray level i in the original gray scale image F, n represents the total number of all pixels in the original gray scale image F, P S (i) represents the gray level histogram after equalization when the gray level is i In the figure, NA represents the total number of gray levels in the target area A, NB represents the total number of gray levels in the background area B, MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the maximum pixel value in the original grayscale image F.

可选的,所述步骤6中,基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制的方法为:Optionally, in the step 6, based on the segmentation threshold T A and the segmentation threshold T B , the method of suppressing the over-enhancement of the equalized grayscale histogram PS is as follows:

Figure BDA0004171456500000042
Figure BDA0004171456500000042

其中,PT(i)表示灰度级为i时裁剪后的灰度直方图。Among them, P T (i) represents the gray histogram after clipping when the gray level is i.

可选的,所述步骤7中,对所述图像PT进行局部灰度修正的方法为:Optionally, in step 7, the method for performing local grayscale correction on the image PT is:

对图像PT的中心像素灰度值进行修正,具体的,Correct the gray value of the center pixel of the image PT , specifically,

Figure BDA0004171456500000043
Figure BDA0004171456500000043

其中,xout(i,j)表示修正后图像PT的中心像素灰度值,xin(i,j)表示原始灰度图像F中心像素灰度值,xHE(i,j)表示图像PT的中心像素灰度值,xmain(i,j)为原始灰度图像F中以(i,j)为中心的5×5窗口内像素的灰度平均值,

Figure BDA0004171456500000044
表示步骤5独立均衡后的灰度图像中以(i,j)为中心的5×5窗口内像素的灰度平均值,Din表示原始灰度图像F的梯度矩阵,DHE表示步骤5独立均衡后的灰度图像的梯度矩阵。Among them, x out (i, j) represents the gray value of the central pixel of the corrected image PT , x in (i, j) represents the gray value of the central pixel of the original gray image F, and x HE (i, j) represents the gray value of the image The gray value of the central pixel of P T , x main (i, j) is the average gray value of the pixels in the 5×5 window centered on (i, j) in the original gray image F,
Figure BDA0004171456500000044
Indicates the gray average value of the pixels in the 5×5 window centered on (i, j) in the gray image after step 5 independent equalization, D in represents the gradient matrix of the original gray image F, D HE represents the independent The gradient matrix of the equalized grayscale image.

可选的,使用sobel算子对原始灰度图像F进行梯度矩阵卷积,得到梯度矩阵DinOptionally, use the sobel operator to perform gradient matrix convolution on the original grayscale image F to obtain the gradient matrix D in :

Figure BDA0004171456500000051
Figure BDA0004171456500000051

使用sobel算子对独立均衡后的灰度图像进行梯度矩阵卷积,得到梯度矩阵DHEUse the sobel operator to perform gradient matrix convolution on the independently equalized grayscale image to obtain the gradient matrix D HE :

Figure BDA0004171456500000052
Figure BDA0004171456500000052

Figure BDA0004171456500000053
Figure BDA0004171456500000053

Figure BDA0004171456500000054
Figure BDA0004171456500000054

其中,D、D180°、D45°、D135°分别表示0°、180°、45°、135°方向的sobel算子。Among them, D , D 180° , D 45° , and D 135° represent the sobel operators in the directions of 0°, 180°, 45°, and 135°, respectively.

可选的,在步骤4确定分割阈值TA、分割阈值TB以及步骤5进行独立均衡之前,还需要对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行一维中值滤波,具体方法为:Optionally, before determining the segmentation threshold T A and T B in step 4 and performing independent equalization in step 5, it is also necessary to perform one-dimensional Median filtering, the specific method is:

分别获取目标区域A的灰度子直方图和背景区域B的灰度子直方图中非零单元的集合FA、FBObtain the sets F A and F B of non-zero units in the gray sub-histogram of the target area A and the gray sub-histogram of the background area B respectively:

Figure BDA0004171456500000055
Figure BDA0004171456500000055

其中,i表示像素灰度级;Among them, i represents the pixel gray level;

对集合FA、FB进行3×3的一维中值滤波。A 3×3 one-dimensional median filter is performed on the sets F A and F B .

本发明还公开一种基于双直方图均衡化的图像增强系统,包括:The invention also discloses an image enhancement system based on double histogram equalization, including:

图像获取模块,用于获取待处理图像;An image acquisition module, configured to acquire images to be processed;

灰度处理模块,用于对所述待处理图像进行灰度处理,得到原始灰度图像F,并对原始灰度图像进行灰度统计得到灰度直方图;A grayscale processing module, configured to perform grayscale processing on the image to be processed to obtain an original grayscale image F, and perform grayscale statistics on the original grayscale image to obtain a grayscale histogram;

图像划分模块,用于确定原始灰度图像F的最佳分割点Kout,并基于所述最佳分割点Kout将原始灰度图像F按照灰度级分为目标区域A和背景区域B;The image division module is used to determine the optimal segmentation point K out of the original grayscale image F, and divide the original grayscale image F into the target area A and the background area B according to the gray level based on the optimal segmentation point K out ;

分割阈值确定模块,用于基于所述最佳分割点Kout确定目标区域A的灰度子直方图的分割阈值TA,以及背景区域B的灰度子直方图的分割阈值TBA segmentation threshold determination module, configured to determine the segmentation threshold T A of the grayscale sub-histogram of the target area A based on the optimal segmentation point K out , and the segmentation threshold T B of the grayscale sub-histogram of the background area B ;

独立均衡处理模块,用于对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡,得到均衡后的灰度直方图PSAn independent equalization processing module, which is used to independently equalize the gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B to obtain the equalized gray level histogram P S ;

过增强抑制模块,用于基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制,得到图像PTAn over-enhancement suppression module, configured to perform over-enhancement suppression on the equalized grayscale histogram PS based on the segmentation threshold TA and the segmentation threshold TB to obtain an image PT ;

局部灰度修正模块,用于对所述图像PT进行局部灰度修正,得到增强后的图像。The local grayscale correction module is configured to perform local grayscale correction on the image PT to obtain an enhanced image.

经由上述的技术方案可知,本发明提供了一种基于双直方图均衡化的图像增强方法及系统,与现有技术相比,具有以下有益效果:It can be seen from the above technical solutions that the present invention provides an image enhancement method and system based on double histogram equalization, which has the following beneficial effects compared with the prior art:

(1)全局直方图均衡算法在图像均衡过程中会发生亮度偏移,造成图像细节信息的丢失。因此,本发明采用改进的Otsu算法将图像分割为目标和背景两个子直方图并进行独立均衡,保护输入图像的平均亮度,避免了增强后图像亮度偏移的问题。(1) The global histogram equalization algorithm will have a brightness shift during the image equalization process, resulting in the loss of image detail information. Therefore, the present invention uses the improved Otsu algorithm to divide the image into two sub-histograms of the target and the background and perform independent equalization to protect the average brightness of the input image and avoid the problem of image brightness shift after enhancement.

(2)相比于传统的Otsu法,本发明经过改进的Otsu算法分割的图像可以展现更多图像细节,达到了更好的分割效果。(2) Compared with the traditional Otsu method, the image segmented by the improved Otsu algorithm of the present invention can show more image details and achieve a better segmentation effect.

(3)传统的直方图均衡算法由于过度拉伸会出现图像的过度增强现象,导致增强后的图像不自然。因此,本发明自适应地获取阈值对灰度级进行抑制以避免图像过度增强现象,改进后的算法对图像边缘细节有保护效果,图像质量得到显著提高。(3) The traditional histogram equalization algorithm will over-enhance the image due to over-stretching, resulting in an unnatural enhanced image. Therefore, the present invention adaptively obtains the threshold value to suppress the gray level to avoid excessive enhancement of the image, and the improved algorithm has a protective effect on the edge details of the image, and the image quality is significantly improved.

(4)利用局部灰度修正算法进行灰度校正,有效避免了灰度级合并问题,保护了图像细节信息,图像对比度与边缘细节信息都得到了合理的增强,图像细节更加清晰,具有更好的视觉效果,可以有效提高低照度环境下机器视觉测量的精确度。(4) Using the local gray-scale correction algorithm for gray-scale correction, effectively avoiding the problem of gray-scale merging, protecting image detail information, image contrast and edge detail information have been reasonably enhanced, image details are clearer, and have better The visual effect can effectively improve the accuracy of machine vision measurement in low-light environment.

综上所述,本发明可以在保护平均亮度的同时使图像对比度与细节信息都得以增强,同时还能尽量避免噪声的放大,鲁棒性高、稳定性强、适用性广,显著提高图像质量。In summary, the present invention can enhance the image contrast and detail information while protecting the average brightness, and at the same time avoid the amplification of noise as much as possible, with high robustness, strong stability, wide applicability, and significantly improved image quality .

本发明尤其适用于在工厂、矿井等低照度环境下的低照度图像增强,以便测量出更精确的工业数据,推进企业工程项目的实施,提高生产效率。The invention is especially suitable for low-illuminance image enhancement in low-illuminance environments such as factories and mines, so as to measure more accurate industrial data, promote the implementation of enterprise engineering projects, and improve production efficiency.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only It is an embodiment of the present invention, and those skilled in the art can also obtain other drawings according to the provided drawings without creative work.

图1为已公开专利一种基于分块统计的直方图均衡方法(CN 110223241 A)的方法流程示意图;Fig. 1 is a method schematic diagram of a histogram equalization method (CN 110223241 A) based on block statistics of a disclosed patent;

图2为已公开专利一种自适应阈值的全局直方图均衡方法(CN 109801246A)的方法流程示意图;Fig. 2 is a method flow diagram of a global histogram equalization method (CN 109801246A) of a published patent with adaptive threshold;

图3为本发明提供的一种基于双直方图均衡化的图像增强方法的流程图;Fig. 3 is a flow chart of an image enhancement method based on double histogram equalization provided by the present invention;

图4为本发明提供的一种基于双直方图均衡化的图像增强系统模块示意图;Fig. 4 is a schematic diagram of an image enhancement system module based on double histogram equalization provided by the present invention;

图5(a)为场景1原图像;Figure 5(a) is the original image of scene 1;

图5(b)为场景1原图像采用传统Otsu算法处理后的效果图;Figure 5(b) is the rendering of the original image of scene 1 processed by the traditional Otsu algorithm;

图5(c)为场景1原图像采用改进Otsu算法处理后的效果图;Figure 5(c) is the rendering of the original image of scene 1 processed by the improved Otsu algorithm;

图5(d)为场景2原图像;Figure 5(d) is the original image of scene 2;

图5(e)为场景2原图像采用传统Otsu算法处理后的效果图;Fig. 5 (e) is the effect diagram after the original image of scene 2 is processed by the traditional Otsu algorithm;

图5(f)为场景2原图像采用改进Otsu算法处理后的效果图;Fig. 5(f) is the effect diagram after the original image of scene 2 is processed by the improved Otsu algorithm;

图6(a)为本发明实施例中原始灰度图像;Fig. 6 (a) is the original gray scale image in the embodiment of the present invention;

图6(b)为本发明实施例中原始灰度图像的灰度直方图;Fig. 6 (b) is the grayscale histogram of original grayscale image in the embodiment of the present invention;

图7(a)为本发明实施例中图像增强后的图像;Fig. 7 (a) is the image after image enhancement in the embodiment of the present invention;

图7(b)为本发明实施例中图像增强后的图像灰度直方图。Fig. 7(b) is a histogram of image grayscale after image enhancement in the embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.

本发明实施例公开了一种基于双直方图均衡化的图像增强方法,可应用于工业领域低照度环境下对包含检测目标的图像进行图像增强,实现低照度环境下的工业测量,提高工业生产效率。参见图3,具体包括以下步骤:The embodiment of the present invention discloses an image enhancement method based on dual histogram equalization, which can be applied to image enhancement of images containing detection targets in low-illuminance environments in the industrial field, so as to realize industrial measurement in low-illuminance environments and improve industrial production. efficiency. Referring to Figure 3, it specifically includes the following steps:

步骤1、获取待处理图像。Step 1. Obtain the image to be processed.

通过工业相机拍摄得到待检测目标在低照度环境下的图像数据。The image data of the target to be detected in a low-light environment is obtained by shooting with an industrial camera.

步骤2、对所述待处理图像进行灰度处理,得到原始灰度图像F,并对原始灰度图像进行灰度统计得到灰度直方图。Step 2. Perform grayscale processing on the image to be processed to obtain an original grayscale image F, and perform grayscale statistics on the original grayscale image to obtain a grayscale histogram.

步骤3、采用改进Otsu算法确定原始灰度图像F的最佳分割点Kout,并基于所述最佳分割点Kout将原始灰度图像F按照灰度级分为目标区域A和背景区域B。Step 3. Use the improved Otsu algorithm to determine the optimal segmentation point K out of the original grayscale image F, and divide the original grayscale image F into the target area A and the background area B according to the gray level based on the optimal segmentation point K out .

其中,采用改进Otsu算法确定原始灰度图像F的最佳分割点Kout的具体过程为:Among them, the specific process of using the improved Otsu algorithm to determine the best segmentation point Kout of the original grayscale image F is:

设置阈值t为分割点,将图像按照灰度级分为目标区域A和背景区域B,目标区域A由灰度值在[MIN,t]区间的像素组成,背景区域B由灰度值在[t+1,MAX]区间内的像素组成。则类A与类B的比例qA(t)、qB(t)为:Set the threshold t as the segmentation point, and divide the image into the target area A and the background area B according to the gray level. The target area A is composed of pixels with gray values in the interval [MIN,t], and the background area B is composed of pixels with gray values in [ t+1,MAX] pixels in the interval. Then the ratio q A (t) and q B (t) of class A to class B is:

Figure BDA0004171456500000081
Figure BDA0004171456500000081

其中L为灰度级个数,P(i)表示灰度值为i时的概率,根据类A与类B的概率可以由μA(t)、μB(t)表示:Among them, L is the number of gray levels, and P(i) represents the probability when the gray value is i. According to the probability of class A and class B, it can be expressed by μ A (t) and μ B (t):

Figure BDA0004171456500000091
Figure BDA0004171456500000091

进而求出输入图像的平均灰度μ:Then find the average gray value μ of the input image:

μ=qA(t)μA(t)+qB(t)μB(t);μ= qA (t) μA (t)+ qB (t) μB (t);

则类间方差

Figure BDA0004171456500000092
定义为:between-class variance
Figure BDA0004171456500000092
defined as:

Figure BDA0004171456500000093
Figure BDA0004171456500000093

为度量像素内聚性的好坏,假设一个距离度量,即:To measure the quality of pixel cohesion, assume a distance metric, namely:

d2(t)=(μA(t)-μB(t))2d 2 (t) = (μ A (t) - μ B (t)) 2 ;

引入目标区域与背景区域平均方差

Figure BDA0004171456500000094
Introduce the average variance of the target area and the background area
Figure BDA0004171456500000094

Figure BDA0004171456500000095
Figure BDA0004171456500000095

Figure BDA0004171456500000096
Figure BDA0004171456500000096

得到新的阈值求取公式:Get the new threshold calculation formula:

Figure BDA0004171456500000097
Figure BDA0004171456500000097

当G(t)取最大值时对应的t值即为最佳分割点。因此,最佳分割点Kout的求取公式如下:When G(t) takes the maximum value, the corresponding t value is the best segmentation point. Therefore, the formula for calculating the optimal segmentation point K out is as follows:

Kout=argt max G(t)。K out = arg t max G(t).

基于所述最佳分割点Kout将原始灰度图像F按照灰度级分为目标区域A和背景区域B,目标区域A由灰度值在[MIN,Kout]区间的像素组成,背景区域B由灰度值在[Kout+1,MAX]区间内的像素组成,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Based on the optimal segmentation point K out , the original grayscale image F is divided into a target area A and a background area B according to the gray level, the target area A is composed of pixels whose gray values are in the interval [MIN, K out ], and the background area B is composed of pixels whose grayscale value is in the interval [K out +1, MAX], MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the maximum pixel value in the original grayscale image F.

参见图5(a)-图5(c)为场景1采用传统Otsu算法和本发明改进Otsu算法处理后的效果对比图,参见图5(d)-图5(f)为场景2采用传统Otsu算法和本发明改进Otsu算法处理后的效果对比图,可见本发明提出的改进Otsu算法可以展现更多的图像细节,实现更好的分割效果。Referring to Fig. 5(a)-Fig. 5(c) is a comparison diagram of the effect after scene 1 adopts traditional Otsu algorithm and the improved Otsu algorithm of the present invention, and Fig. 5(d)-Fig. 5(f) is scene 2 adopting traditional Otsu The comparison chart of the algorithm and the improved Otsu algorithm of the present invention after processing shows that the improved Otsu algorithm proposed by the present invention can display more image details and achieve a better segmentation effect.

在具体应用过程中,还需要对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行一维中值滤波,方便下一步处理,具体方法为:In the specific application process, it is also necessary to perform one-dimensional median filtering on the gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B to facilitate the next step of processing. The specific method is as follows:

分别获取目标区域A的灰度子直方图和背景区域B的灰度子直方图中非零单元的集合FA、FBObtain the sets F A and F B of non-zero units in the gray sub-histogram of the target area A and the gray sub-histogram of the background area B respectively:

Figure BDA0004171456500000101
Figure BDA0004171456500000101

其中,i表示像素灰度级;Among them, i represents the pixel gray level;

对集合FA、FB进行3×3的一维中值滤波。A 3×3 one-dimensional median filter is performed on the sets F A and F B .

步骤4、基于所述最佳分割点Kout确定目标区域A的灰度子直方图的分割阈值TA,以及背景区域B的灰度子直方图的分割阈值TBStep 4. Determine the segmentation threshold T A of the grayscale sub-histogram of the target area A and the segmentation threshold T B of the grayscale sub-histogram of the background area B based on the optimal segmentation point K out :

Figure BDA0004171456500000102
Figure BDA0004171456500000102

其中,TMA表示目标区域A的灰度子直方图的峰值,TMB表示背景区域B的灰度子直方图的峰值,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Among them, TMA represents the peak value of the grayscale sub-histogram of the target area A, TMB represents the peak value of the grayscale sub-histogram of the background area B, MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the original grayscale The maximum pixel value in image F.

步骤5、对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡,并统计均衡后的图像灰度,得到均衡后的灰度直方图PS,均衡公式为:Step 5. Independently equalize the gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B, and count the equalized image gray level to obtain the equalized gray level histogram P S . The equalization formula is :

Figure BDA0004171456500000103
Figure BDA0004171456500000103

其中,ni表示原始灰度图像F中灰度级i的像素总数,n表示原始灰度图像F中的所有像素总数,PS(i)表示灰度级为i时均衡后的灰度直方图,NA表示目标区域A灰度级总数,NB表示背景区域B的灰度级总数,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Among them, n i represents the total number of pixels of gray level i in the original gray scale image F, n represents the total number of all pixels in the original gray scale image F, P S (i) represents the gray level histogram after equalization when the gray level is i In the figure, NA represents the total number of gray levels in the target area A, NB represents the total number of gray levels in the background area B, MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the maximum pixel value in the original grayscale image F.

步骤6、基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制,即在目标区域A中,大于分割阈值TA的值变为TA,在背景区域B中,大于分割阈值TB的值变为TB,其余数值不变,得到图像PTStep 6. Based on the segmentation threshold T A and the segmentation threshold T B , perform over-enhancement suppression on the equalized grayscale histogram PS , that is, in the target area A, values greater than the segmentation threshold T A become is T A , in the background area B, the value greater than the segmentation threshold T B becomes T B , and the rest of the values remain unchanged, and the image P T is obtained:

Figure BDA0004171456500000111
Figure BDA0004171456500000111

其中,PT(i)表示灰度级为i时裁剪后的灰度直方图。Among them, P T (i) represents the gray histogram after clipping when the gray level is i.

步骤7、对所述图像PT进行局部灰度修正,得到增强后的图像:Step 7. Perform local gray scale correction on the image PT to obtain an enhanced image:

Figure BDA0004171456500000112
Figure BDA0004171456500000112

其中,xout(i,j)表示修正后图像PT的中心像素灰度值,xin(i,j)表示原始灰度图像F中心像素灰度值,xHE(i,j)表示图像PT的中心像素灰度值,xmain(i,j)为原始灰度图像F中以(i,j)为中心的5×5窗口内像素的灰度平均值,

Figure BDA0004171456500000113
表示步骤5独立均衡后的灰度图像中以(i,j)为中心的5×5窗口内像素的灰度平均值,Din表示原始灰度图像F的梯度矩阵,DHE表示步骤5独立均衡后的灰度图像的梯度矩阵。Among them, x out (i, j) represents the gray value of the central pixel of the corrected image PT , x in (i, j) represents the gray value of the central pixel of the original gray image F, and x HE (i, j) represents the gray value of the image The gray value of the central pixel of P T , x main (i, j) is the average gray value of the pixels in the 5×5 window centered on (i, j) in the original gray image F,
Figure BDA0004171456500000113
Indicates the gray average value of the pixels in the 5×5 window centered on (i, j) in the gray image after step 5 independent equalization, D in represents the gradient matrix of the original gray image F, D HE represents the independent The gradient matrix of the equalized grayscale image.

使用sobel算子对原始灰度图像F进行梯度矩阵卷积,得到梯度矩阵DinUse the sobel operator to perform gradient matrix convolution on the original grayscale image F to obtain the gradient matrix D in :

Figure BDA0004171456500000114
Figure BDA0004171456500000114

使用sobel算子对独立均衡后的灰度图像进行梯度矩阵卷积,得到梯度矩阵DHEUse the sobel operator to perform gradient matrix convolution on the independently equalized grayscale image to obtain the gradient matrix D HE :

Figure BDA0004171456500000115
Figure BDA0004171456500000115

Figure BDA0004171456500000121
Figure BDA0004171456500000121

Figure BDA0004171456500000122
Figure BDA0004171456500000122

其中,D、D180°、D45°、D135°分别表示0°、180°、45°、135°方向的sobel算子。Among them, D , D 180° , D 45° , and D 135° represent the sobel operators in the directions of 0°, 180°, 45°, and 135°, respectively.

本发明另一实施例还公开一种基于双直方图均衡化的图像增强系统,参见图4,包括:Another embodiment of the present invention also discloses an image enhancement system based on double histogram equalization, see Figure 4, including:

图像获取模块,用于获取待处理图像;An image acquisition module, configured to acquire images to be processed;

灰度处理模块,用于对所述待处理图像进行灰度处理,得到原始灰度图像F,并对原始灰度图像进行灰度统计得到灰度直方图;A grayscale processing module, configured to perform grayscale processing on the image to be processed to obtain an original grayscale image F, and perform grayscale statistics on the original grayscale image to obtain a grayscale histogram;

图像划分模块,用于确定原始灰度图像F的最佳分割点Kout,并基于所述最佳分割点Kout将原始灰度图像F按照灰度级分为目标区域A和背景区域B;The image division module is used to determine the optimal segmentation point K out of the original grayscale image F, and divide the original grayscale image F into the target area A and the background area B according to the gray level based on the optimal segmentation point K out ;

分割阈值确定模块,用于基于所述最佳分割点Kout确定目标区域A的灰度子直方图的分割阈值TA,以及背景区域B的灰度子直方图的分割阈值TBA segmentation threshold determination module, configured to determine the segmentation threshold T A of the grayscale sub-histogram of the target area A based on the optimal segmentation point K out , and the segmentation threshold T B of the grayscale sub-histogram of the background area B ;

独立均衡处理模块,用于对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡,得到均衡后的灰度直方图PSAn independent equalization processing module, which is used to independently equalize the gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B to obtain the equalized gray level histogram P S ;

过增强抑制模块,用于基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制,得到图像PTAn over-enhancement suppression module, configured to perform over-enhancement suppression on the equalized grayscale histogram PS based on the segmentation threshold TA and the segmentation threshold TB to obtain an image PT ;

局部灰度修正模块,用于对所述图像PT进行局部灰度修正,得到增强后的图像。The local grayscale correction module is configured to perform local grayscale correction on the image PT to obtain an enhanced image.

在工业领域,可以通过机器视觉系统快速实现对目标的测量,然而实际工作中,会由于环境问题(雨、雾、烟尘等)、成像设备问题以及光照问题等导致获得的图像质量低下、对比度较低,不利于后续图像处理,因此可通过本发明的图像增强技术,提高图像对比度,以便最终得到更加精确的工业数据,并提高自动检测系统的鲁棒性。In the industrial field, the measurement of the target can be quickly realized through the machine vision system. However, in actual work, due to environmental problems (rain, fog, smoke, etc.), imaging equipment problems, and lighting problems, the image quality obtained is low and the contrast is low. Low, it is not conducive to subsequent image processing, so the image contrast can be improved by the image enhancement technology of the present invention, so as to finally obtain more accurate industrial data and improve the robustness of the automatic detection system.

类似的,本发明技术方案除了应用于上述工业领域之外,还可应用于其他需要进行图像增强的场景中。例如,本发明技术方案还可应用于可见光和红外图像增强处理中,红外成像技术在国防、安防、无损检测、毒气探测等领域应用十分广泛。例如故障原件的自动视觉检测系统,故障元件通常会产生过多的热量,在装配中,从热能的分布产生红外图像,通过对红外图像的增强处理,在装配中精确地识别出故障元件。改善图像质量、提升图像细节,提高检测系统的鲁棒性。Similarly, in addition to the above-mentioned industrial fields, the technical solution of the present invention can also be applied to other scenarios requiring image enhancement. For example, the technical solution of the present invention can also be applied to visible light and infrared image enhancement processing, and infrared imaging technology is widely used in the fields of national defense, security, non-destructive testing, and poisonous gas detection. For example, in the automatic visual inspection system of faulty components, faulty components usually generate too much heat. In assembly, infrared images are generated from the distribution of heat energy. By enhancing the processing of infrared images, faulty components can be accurately identified in assembly. Improve image quality, enhance image details, and improve the robustness of the detection system.

进一步的,本发明还可应用于肺病识别、心脏病识别以及数字乳腺X光片等,实现生物医学中的图像增强。由于成像设备获得的原始图像受到设备本身硬件性能的制约和获取条件等多种因素的影响,直接从医学仪器所得到的医学图像可能出现图像质量的退化,比如对比度较低、图像不清晰等,通过本发明能够提高医学图像的对比度,进而辅助医生进行自动诊断,提高工作的效率。Further, the present invention can also be applied to lung disease identification, heart disease identification, digital mammogram, etc., to realize image enhancement in biomedicine. Since the original image obtained by the imaging device is affected by various factors such as the hardware performance of the device itself and the acquisition conditions, the medical image obtained directly from the medical instrument may have image quality degradation, such as low contrast, unclear image, etc. Through the present invention, the contrast of medical images can be improved, thereby assisting doctors in automatic diagnosis and improving work efficiency.

参见图6(a)、图6(b)为一张低照度图像的原始灰度图像及其灰度直方图,图7(a)和图7(b)为所述低照度图像采用本发明方案进行图像增强后的图像及其灰度直方图,可见,本发明可以在保护平均亮度的同时使图像对比度与细节信息都得以增强,同时能尽量避免噪声的放大,提高图像质量。Referring to Fig. 6 (a), Fig. 6 (b) is the original grayscale image of a low-illuminance image and its grayscale histogram, Fig. 7 (a) and Fig. 7 (b) adopt the present invention for described low-illuminance image The image and its grayscale histogram after image enhancement by the scheme, it can be seen that the present invention can enhance the image contrast and detail information while protecting the average brightness, and at the same time avoid the amplification of noise as much as possible and improve the image quality.

本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other. As for the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and for relevant details, please refer to the description of the method part.

对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本发明。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1.一种基于双直方图均衡化的图像增强方法,其特征在于,包括以下步骤:1. an image enhancement method based on double histogram equalization, is characterized in that, comprises the following steps: 步骤1、获取待处理图像;Step 1, obtain the image to be processed; 步骤2、对所述待处理图像进行灰度处理,得到原始灰度图像F,并对原始灰度图像进行灰度统计得到灰度直方图;Step 2, performing grayscale processing on the image to be processed to obtain an original grayscale image F, and performing grayscale statistics on the original grayscale image to obtain a grayscale histogram; 步骤3、确定原始灰度图像F的最佳分割点Kout,并基于所述最佳分割点Kout将原始灰度图像F按照灰度级分为目标区域A和背景区域B;Step 3. Determine the optimal segmentation point K out of the original grayscale image F, and divide the original grayscale image F into the target area A and the background area B according to the gray level based on the optimal segmentation point K out ; 步骤4、基于所述最佳分割点Kout确定目标区域A的灰度子直方图的分割阈值TA,以及背景区域B的灰度子直方图的分割阈值TBStep 4. Determine the segmentation threshold T A of the grayscale sub-histogram of the target area A and the segmentation threshold T B of the grayscale sub-histogram of the background area B based on the optimal segmentation point K out ; 步骤5、对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡,得到均衡后的灰度直方图PSStep 5. Independently equalize the gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B to obtain the equalized gray level histogram P S ; 步骤6、基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制,得到图像PTStep 6. Based on the segmentation threshold TA and the segmentation threshold TB , perform over-enhancement suppression on the equalized gray histogram PS to obtain an image PT ; 步骤7、对所述图像PT进行局部灰度修正,得到增强后的图像。Step 7. Perform local grayscale correction on the image PT to obtain an enhanced image. 2.根据权利要求1所述的一种基于双直方图均衡化的图像增强方法,其特征在于,所述步骤3中,采用改进Otsu算法确定原始灰度图像F的最佳分割点Kout,具体方法如下:2. a kind of image enhancement method based on double histogram equalization according to claim 1, is characterized in that, in described step 3, adopts improved Otsu algorithm to determine the optimal segmentation point K out of original grayscale image F, The specific method is as follows: Kout=argt maxG(t);K out = arg t maxG(t);
Figure FDA0004171456490000011
Figure FDA0004171456490000011
其中,qA(t)表示阈值t为分割点时,目标区域A所占比例;qB(t)表示阈值t为分割点时,背景区域B所占比例;μA(t)表示阈值t为分割点时,目标区域A的概率;μB(t)表示阈值t为分割点时,背景区域B的概率;
Figure FDA0004171456490000012
表示目标区域A平均方差;/>
Figure FDA0004171456490000013
表示背景区域B平均方差。
Among them, q A (t) indicates the proportion of the target area A when the threshold t is the segmentation point; q B (t) indicates the proportion of the background area B when the threshold t is the segmentation point; μ A (t) indicates the threshold t When is the segmentation point, the probability of the target area A; μ B (t) represents the probability of the background area B when the threshold t is the segmentation point;
Figure FDA0004171456490000012
Indicates the average variance of the target area A; />
Figure FDA0004171456490000013
Indicates the mean variance of the background region B.
3.根据权利要求1所述的一种基于双直方图均衡化的图像增强方法,其特征在于,所述步骤3中,目标区域A由灰度值在[MIN,Kout]区间的像素组成,背景区域B由灰度值在[Kout+1,MAX]区间内的像素组成,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。3. a kind of image enhancement method based on double histogram equalization according to claim 1, is characterized in that, in described step 3, target area A is made up of the pixel of grayscale value in [MIN, K out ] interval , the background area B is composed of pixels whose grayscale values are in the interval [K out +1, MAX], MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the maximum pixel value in the original grayscale image F. 4.根据权利要求1所述的一种基于双直方图均衡化的图像增强方法,其特征在于,所述步骤4中,确定分割阈值TA和分割阈值TB的方法为:4. a kind of image enhancement method based on double histogram equalization according to claim 1, is characterized in that, in described step 4, the method for determining segmentation threshold TA and segmentation threshold TB is:
Figure FDA0004171456490000021
Figure FDA0004171456490000021
其中,TMA表示目标区域A的灰度子直方图的峰值,TMB表示背景区域B的灰度子直方图的峰值,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Among them, TMA represents the peak value of the grayscale sub-histogram of the target area A, TMB represents the peak value of the grayscale sub-histogram of the background area B, MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the original grayscale The maximum pixel value in image F.
5.根据权利要求1所述的一种基于双直方图均衡化的图像增强方法,其特征在于,所述步骤5中,对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡的方法为:5. A kind of image enhancement method based on double histogram equalization according to claim 1, characterized in that, in the step 5, the grayscale sub-histogram of the target area A and the grayscale sub-histogram of the background area B The method for independent equalization of the histogram is:
Figure FDA0004171456490000022
Figure FDA0004171456490000022
其中,ni表示原始灰度图像F中灰度级i的像素总数,n表示原始灰度图像F中的所有像素总数,PS(i)表示灰度级为i时均衡后的灰度直方图,NA表示目标区域A灰度级总数,NB表示背景区域B的灰度级总数,MIN表示原始灰度图像F中的最小像素值,MAX表示原始灰度图像F中的最大像素值。Among them, n i represents the total number of pixels of gray level i in the original gray scale image F, n represents the total number of all pixels in the original gray scale image F, P S (i) represents the gray level histogram after equalization when the gray level is i In the figure, NA represents the total number of gray levels in the target area A, NB represents the total number of gray levels in the background area B, MIN represents the minimum pixel value in the original grayscale image F, and MAX represents the maximum pixel value in the original grayscale image F.
6.根据权利要求5所述的一种基于双直方图均衡化的图像增强方法,其特征在于,所述步骤6中,基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制的方法为:6. A kind of image enhancement method based on dual histogram equalization according to claim 5, characterized in that, in the step 6, based on the segmentation threshold TA and the segmentation threshold TB , the The method of over-enhanced suppression of the equalized gray histogram PS is:
Figure FDA0004171456490000031
Figure FDA0004171456490000031
其中,PT(i)表示灰度级为i时裁剪后的灰度直方图。Among them, P T (i) represents the gray histogram after clipping when the gray level is i.
7.根据权利要求1所述的一种基于双直方图均衡化的图像增强方法,其特征在于,所述步骤7中,对所述图像PT进行局部灰度修正的方法为:7. a kind of image enhancement method based on double histogram equalization according to claim 1, is characterized in that, in described step 7, the method that described image PT is carried out local grayscale correction is: 对图像PT的中心像素灰度值进行修正,具体的,Correct the gray value of the center pixel of the image PT , specifically,
Figure FDA0004171456490000032
Figure FDA0004171456490000032
其中,xout(i,j)表示修正后图像PT的中心像素灰度值,xin(i,j)表示原始灰度图像F中心像素灰度值,xHE(i,j)表示图像PT的中心像素灰度值,xmain(i,j)为原始灰度图像F中以(i,j)为中心的5×5窗口内像素的灰度平均值,
Figure FDA0004171456490000033
表示步骤5独立均衡后的灰度图像中以(i,j)为中心的5×5窗口内像素的灰度平均值,Din表示原始灰度图像F的梯度矩阵,DHE表示步骤5独立均衡后的灰度图像的梯度矩阵。
Among them, x out (i, j) represents the gray value of the central pixel of the corrected image PT , x in (i, j) represents the gray value of the central pixel of the original gray image F, and x HE (i, j) represents the gray value of the image The gray value of the central pixel of P T , x main (i, j) is the average gray value of the pixels in the 5×5 window centered on (i, j) in the original gray image F,
Figure FDA0004171456490000033
Indicates the gray average value of the pixels in the 5×5 window centered on (i, j) in the gray image after step 5 independent equalization, D in represents the gradient matrix of the original gray image F, D HE represents the independent The gradient matrix of the equalized grayscale image.
8.根据权利要求7所述的一种基于双直方图均衡化的图像增强方法,其特征在于,使用sobel算子对原始灰度图像F进行梯度矩阵卷积,得到梯度矩阵Din8. a kind of image enhancement method based on double histogram equalization according to claim 7, is characterized in that, uses sobel operator to carry out gradient matrix convolution to original grayscale image F, obtains gradient matrix D in :
Figure FDA0004171456490000034
Figure FDA0004171456490000034
使用sobel算子对独立均衡后的灰度图像进行梯度矩阵卷积,得到梯度矩阵DHEUse the sobel operator to perform gradient matrix convolution on the independently equalized grayscale image to obtain the gradient matrix D HE :
Figure FDA0004171456490000035
Figure FDA0004171456490000035
Figure FDA0004171456490000041
Figure FDA0004171456490000041
Figure FDA0004171456490000042
Figure FDA0004171456490000042
其中,D、D180°、D45°、D135°分别表示0°、180°、45°、135°方向的sobel算子。Among them, D , D 180° , D 45° , and D 135° represent the sobel operators in the directions of 0°, 180°, 45°, and 135°, respectively.
9.根据权利要求1所述的一种基于双直方图均衡化的图像增强方法,其特征在于,在步骤4确定分割阈值TA、分割阈值TB以及步骤5进行独立均衡之前,还需要对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行一维中值滤波,具体方法为:9. A kind of image enhancement method based on double histogram equalization according to claim 1, it is characterized in that, before step 4 determines segmentation threshold TA , segmentation threshold TB and step 5 carries out independent equalization, also need to The gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B are subjected to one-dimensional median filtering, and the specific method is as follows: 分别获取目标区域A的灰度子直方图和背景区域B的灰度子直方图中非零单元的集合FA、FBObtain the sets F A and F B of non-zero units in the gray sub-histogram of the target area A and the gray sub-histogram of the background area B respectively:
Figure FDA0004171456490000043
Figure FDA0004171456490000043
其中,i表示像素灰度级;Among them, i represents the pixel gray level; 对集合FA、FB进行3×3的一维中值滤波。A 3×3 one-dimensional median filter is performed on the sets F A and F B .
10.一种基于双直方图均衡化的图像增强系统,其特征在于,包括:10. An image enhancement system based on double histogram equalization, characterized in that, comprising: 图像获取模块,用于获取待处理图像;An image acquisition module, configured to acquire images to be processed; 灰度处理模块,用于对所述待处理图像进行灰度处理,得到原始灰度图像F,并对原始灰度图像进行灰度统计得到灰度直方图;A grayscale processing module, configured to perform grayscale processing on the image to be processed to obtain an original grayscale image F, and perform grayscale statistics on the original grayscale image to obtain a grayscale histogram; 图像划分模块,用于确定原始灰度图像F的最佳分割点Kout,并基于所述最佳分割点Kout将原始灰度图像F按照灰度级分为目标区域A和背景区域B;The image division module is used to determine the optimal segmentation point K out of the original grayscale image F, and divide the original grayscale image F into the target area A and the background area B according to the gray level based on the optimal segmentation point K out ; 分割阈值确定模块,用于基于所述最佳分割点Kout确定目标区域A的灰度子直方图的分割阈值TA,以及背景区域B的灰度子直方图的分割阈值TBA segmentation threshold determination module, configured to determine the segmentation threshold T A of the grayscale sub-histogram of the target area A based on the optimal segmentation point K out , and the segmentation threshold T B of the grayscale sub-histogram of the background area B ; 独立均衡处理模块,用于对目标区域A的灰度子直方图和背景区域B的灰度子直方图进行独立均衡,得到均衡后的灰度直方图PSAn independent equalization processing module, which is used to independently equalize the gray level sub-histogram of the target area A and the gray level sub-histogram of the background area B to obtain the equalized gray level histogram P S ; 过增强抑制模块,用于基于所述分割阈值TA和所述分割阈值TB,对所述均衡后的灰度直方图PS进行过增强抑制,得到图像PTAn over-enhancement suppression module, configured to perform over-enhancement suppression on the equalized grayscale histogram PS based on the segmentation threshold TA and the segmentation threshold TB to obtain an image PT ; 局部灰度修正模块,用于对所述图像PT进行局部灰度修正,得到增强后的图像。The local grayscale correction module is configured to perform local grayscale correction on the image PT to obtain an enhanced image.
CN202310379084.3A 2023-04-11 2023-04-11 An image enhancement method and system based on double histogram equalization Pending CN116402729A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310379084.3A CN116402729A (en) 2023-04-11 2023-04-11 An image enhancement method and system based on double histogram equalization

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310379084.3A CN116402729A (en) 2023-04-11 2023-04-11 An image enhancement method and system based on double histogram equalization

Publications (1)

Publication Number Publication Date
CN116402729A true CN116402729A (en) 2023-07-07

Family

ID=87007109

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310379084.3A Pending CN116402729A (en) 2023-04-11 2023-04-11 An image enhancement method and system based on double histogram equalization

Country Status (1)

Country Link
CN (1) CN116402729A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116843581A (en) * 2023-08-30 2023-10-03 山东捷瑞数字科技股份有限公司 Image enhancement method, system, device and storage medium for multi-scene graph
CN117078568A (en) * 2023-10-12 2023-11-17 成都智明达电子股份有限公司 Infrared image enhancement method
CN117115034A (en) * 2023-09-04 2023-11-24 长春奥普光电技术股份有限公司 Image enhancement method and device for deep sea camera with edge enhancement and region segmentation
CN117173158A (en) * 2023-10-25 2023-12-05 深圳市德海威实业有限公司 Intelligent detection method and system for quality of precise connector
CN117611459A (en) * 2024-01-23 2024-02-27 广东省农业科学院农业生物基因研究中心 A method and system for enhancing microstructure of inflammatory bowel disease
CN117934350A (en) * 2024-01-22 2024-04-26 北京富邦智达自动化科技有限公司 Image processing method for intelligent inspection robot of chemical plant

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116843581A (en) * 2023-08-30 2023-10-03 山东捷瑞数字科技股份有限公司 Image enhancement method, system, device and storage medium for multi-scene graph
CN116843581B (en) * 2023-08-30 2023-12-01 山东捷瑞数字科技股份有限公司 Image enhancement method, system, device and storage medium for multi-scene graph
CN117115034A (en) * 2023-09-04 2023-11-24 长春奥普光电技术股份有限公司 Image enhancement method and device for deep sea camera with edge enhancement and region segmentation
CN117078568A (en) * 2023-10-12 2023-11-17 成都智明达电子股份有限公司 Infrared image enhancement method
CN117078568B (en) * 2023-10-12 2024-02-23 成都智明达电子股份有限公司 Infrared image enhancement method
CN117173158A (en) * 2023-10-25 2023-12-05 深圳市德海威实业有限公司 Intelligent detection method and system for quality of precise connector
CN117173158B (en) * 2023-10-25 2024-01-30 深圳市德海威实业有限公司 Intelligent detection method and system for quality of precise connector
CN117934350A (en) * 2024-01-22 2024-04-26 北京富邦智达自动化科技有限公司 Image processing method for intelligent inspection robot of chemical plant
CN117611459A (en) * 2024-01-23 2024-02-27 广东省农业科学院农业生物基因研究中心 A method and system for enhancing microstructure of inflammatory bowel disease
CN117611459B (en) * 2024-01-23 2024-03-26 广东省农业科学院农业生物基因研究中心 A method and system for enhancing microstructure of inflammatory bowel disease

Similar Documents

Publication Publication Date Title
CN116402729A (en) An image enhancement method and system based on double histogram equalization
CN107767354B (en) An Image Dehazing Algorithm Based on Dark Primitive Color Prior
CN109919879B (en) An image defogging method based on dark channel prior and bright channel prior
CN110570360B (en) A robust and comprehensive low-quality illumination image enhancement method based on Retinex
CN108765342A (en) A kind of underwater image restoration method based on improvement dark
US9147235B2 (en) Method for processing highlights and saturated regions in a digital image
CN109447912B (en) Fluorescent image self-adaptive enhancement and noise reduction method of fluorescent navigation endoscope system
CN104637064A (en) Defocus blurred image definition detection method based on edge intensity weight
CN110047055B (en) An infrared image detail enhancement and denoising method
CN111861896A (en) A UUV-Oriented Color Compensation and Restoration Method for Underwater Images
CN107403414B (en) A kind of image area selecting method and system being conducive to fuzzy kernel estimates
CN115631116B (en) Aircraft power inspection system based on binocular vision
CN111444555B (en) Temperature measurement information display method and device and terminal equipment
CN107292830A (en) Low-light (level) image enhaucament and evaluation method
CN115578297A (en) A Generalized Attenuation Image Enhancement Method with Adaptive Color Compensation and Detail Optimization
CN115004227A (en) Image processing method, device and equipment
CN109087254A (en) Unmanned plane image haze sky and white area adaptive processing method
CN114004850A (en) Sky segmentation method, image defogging method, electronic device and storage medium
CN112053298B (en) An image dehazing method
CN110298796A (en) Based on the enhancement method of low-illumination image for improving Retinex and Logarithmic image processing
CN113393394B (en) Low-illumination gray level image enhancement method and device based on gamma conversion and storage medium
CN118297837B (en) Infrared simulator virtual image enhancement system based on image processing
CN110349113A (en) Self-adaptive image defogging method based on dark channel prior improvement
CN113379631A (en) Image defogging method and device
CN115965537A (en) Video image denoising method and device and computer storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination