CN113191990B - Image processing method, device, electronic equipment and medium - Google Patents
Image processing method, device, electronic equipment and medium Download PDFInfo
- Publication number
- CN113191990B CN113191990B CN202110590447.9A CN202110590447A CN113191990B CN 113191990 B CN113191990 B CN 113191990B CN 202110590447 A CN202110590447 A CN 202110590447A CN 113191990 B CN113191990 B CN 113191990B
- Authority
- CN
- China
- Prior art keywords
- histogram
- platform
- image
- threshold
- value
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/40—Image enhancement or restoration using histogram techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20024—Filtering details
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
- Facsimile Image Signal Circuits (AREA)
Abstract
本申请实施例公开了一种图像处理方法、装置、电子设备及介质。该方法包括:根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图以及细节直方图;根据第一参考阈值与细节累积直方图的统计值的关系,以及第二参考阈值与细节累积直方图的统计值的关系,确定第一平台阈值和第二平台阈值;根据第一平台阈值、第二平台阈值以及初始直方图,确定双平台直方图;根据双平台累积直方图确定灰度映射关系,并基于灰度映射关系对待处理图像进行处理得到目标图像。上述方案能够在确定双平台阈值时考虑到图像的细节,从而使确定的双平台阈值能够适用于对不同场景下的图像进行处理,提高图像处理方法的场景适应性。
The embodiment of the present application discloses an image processing method, device, electronic equipment and medium. The method includes: determining an initial histogram and a detail histogram according to the high-pass filtered image of the image to be processed and the image to be processed; according to the relationship between the first reference threshold and the statistical value of the detail cumulative histogram, and the second reference threshold and the detail Determine the relationship between the statistical values of the cumulative histogram, determine the first platform threshold and the second platform threshold; determine the dual platform histogram according to the first platform threshold, the second platform threshold and the initial histogram; determine the gray level according to the dual platform cumulative histogram mapping relationship, and process the image to be processed based on the grayscale mapping relationship to obtain the target image. The above solution can take into account the details of the image when determining the dual-platform threshold, so that the determined dual-platform threshold can be applied to image processing in different scenarios, improving the scene adaptability of the image processing method.
Description
技术领域technical field
本申请实施例涉及图像处理技术领域,尤其涉及一种图像处理方法、装置、电子设备及介质。The embodiments of the present application relate to the technical field of image processing, and in particular, to an image processing method, device, electronic device, and medium.
背景技术Background technique
图像处理是用计算机对图像进行分析,以达到所需结果的技术。图像处理包括图像变换、图像编码压缩、图像增强和复原、图像分割、图像描述和图像分类等。Image processing is the technique of analyzing an image with a computer to achieve a desired result. Image processing includes image transformation, image coding and compression, image enhancement and restoration, image segmentation, image description and image classification, etc.
图像增强技术常用于图像的预处理和提高图像的显示质量,在数字图像处理系统中有着广泛的应用,图像增强通常在空域或者频域进行处理,在空域中最为常用的方法是线性拉伸算法,直方图均衡处理、指数变换处理等。其中直方图均衡法因其算法简单、适应性强的特点得到广泛的应用。Image enhancement technology is often used in image preprocessing and image display quality improvement. It is widely used in digital image processing systems. Image enhancement is usually processed in the spatial domain or frequency domain. The most commonly used method in the spatial domain is the linear stretching algorithm. , histogram equalization processing, exponential transformation processing, etc. Among them, the histogram equalization method is widely used because of its simple algorithm and strong adaptability.
目前的直方图均衡算法没有对图像背景和目标进行区分导致部分场景经过增强后背景和噪声占据过多的灰度范围,反而使目标细节等信息占据较少的灰度范围导致最终的图像效果不佳。改进的直方图均衡化算法虽然在一定程度上可以缓解背景过度拉伸、图像细节损失等问题,但是针对不同场景,现有的改进直方图均衡算法难以自适应地确定增强参数,使图像增强的效果受限。The current histogram equalization algorithm does not distinguish between the image background and the target, which leads to the background and noise occupying too much gray scale range after some scenes are enhanced, but the target details and other information occupy less gray scale range, resulting in poor final image effect. good. Although the improved histogram equalization algorithm can alleviate the problems of background overstretching and image detail loss to a certain extent, it is difficult for the existing improved histogram equalization algorithm to adaptively determine the enhancement parameters for different scenarios, so that the image enhancement Effect is limited.
发明内容Contents of the invention
本申请实施例提供一种图像处理方法、装置、电子设备及介质,以提高对不同场景下图像的处理效果。Embodiments of the present application provide an image processing method, device, electronic equipment, and medium, so as to improve image processing effects in different scenarios.
在一个实施例中,本申请实施例提供了一种图像处理方法,该方法包括:In one embodiment, the embodiment of the present application provides an image processing method, the method comprising:
根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图;determining an initial histogram according to the high-pass filtered image of the image to be processed and the image to be processed, and determining a detail histogram of the image to be processed according to the initial histogram;
根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值;其中,所述第一参考阈值和所述第二参考阈值根据所述细节累积直方图的最大统计值确定,所述细节累积直方图为所述细节直方图的累积直方图;According to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, determine the first value from the statistical value of the detailed cumulative histogram. A platform threshold and a second platform threshold; wherein, the first reference threshold and the second reference threshold are determined according to the maximum statistical value of the detail cumulative histogram, and the detail cumulative histogram is the accumulation of the detail histogram histogram;
根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图;determining a dual platform histogram according to the first platform threshold, the second platform threshold and the initial histogram;
根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像;其中,所述双平台累积直方图为所述双平台直方图的累积直方图。Determine the grayscale mapping relationship according to the dual-platform cumulative histogram, and process the image to be processed based on the grayscale mapping relationship to obtain a target image; wherein, the dual-platform cumulative histogram is the dual-platform histogram The cumulative histogram of .
在另一个实施例中,本申请实施例还提供了一种图像处理装置,该装置包括:In another embodiment, the embodiment of the present application also provides an image processing device, which includes:
细节直方图确定模块,用于根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图,所述细节累积直方图为所述细节直方图的累积直方图;A detail histogram determining module, configured to determine an initial histogram according to the high-pass filtered image of the image to be processed and the image to be processed, and determine a detail histogram of the image to be processed according to the initial histogram, the detail cumulative histogram The figure is a cumulative histogram of the detail histogram;
阈值确定模块,用于根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值;其中,所述第一参考阈值和所述第二参考阈值根据所述细节累积直方图的最大统计值确定;Threshold determination module, for according to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, from the detailed cumulative histogram A first platform threshold and a second platform threshold are determined in the statistical value; wherein, the first reference threshold and the second reference threshold are determined according to the maximum statistical value of the detailed cumulative histogram;
双平台直方图确定模块,用于根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图;A dual-platform histogram determination module, configured to determine a dual-platform histogram according to the first platform threshold, the second platform threshold, and the initial histogram;
处理模块,用于根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像;其中,所述双平台累积直方图为所述双平台直方图的累积直方图。A processing module, configured to determine a grayscale mapping relationship according to the dual-platform cumulative histogram, and process the image to be processed based on the grayscale mapping relationship to obtain a target image; wherein, the dual-platform cumulative histogram is the Cumulative histogram of the two-platform histogram described above.
在又一个实施例中,本申请实施例还提供了一种电子设备,包括:一个或多个处理器;In yet another embodiment, the embodiment of the present application also provides an electronic device, including: one or more processors;
存储器,用于存储一个或多个程序;memory for storing one or more programs;
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现本申请实施例任一项所述的图像处理方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method described in any one of the embodiments of the present application.
在一个实施例中,本申请实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如本申请实施例中任一项所述的图像处理方法。In one embodiment, the embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the image processing as described in any one of the embodiments of the present application is realized. method.
本申请实施例中,根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图,从而统计待处理图像的高频分量,确定待处理图像的细节部分,根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值,从而使第一平台阈值和第二平台阈值的确定过程中考虑到了细节部分,以适用于当前场景下的待处理图像,根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图;根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像,从而提高对待处理图像的处理效果。In the embodiment of the present application, the initial histogram is determined according to the high-pass filtered image of the image to be processed and the image to be processed, and the detail histogram of the image to be processed is determined according to the initial histogram, so as to count the high Frequency component, determine the detail part of the image to be processed, according to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, from the Determining the first platform threshold and the second platform threshold in the statistical value of the detail cumulative histogram, so that the details are taken into account in the determination process of the first platform threshold and the second platform threshold, so as to be suitable for the image to be processed in the current scene, According to the first platform threshold, the second platform threshold and the initial histogram, determine a dual-platform histogram; determine the grayscale mapping relationship according to the dual-platform cumulative histogram, and determine the grayscale mapping relationship based on the grayscale mapping relationship The image to be processed is processed to obtain a target image, thereby improving the processing effect of the image to be processed.
附图说明Description of drawings
图1为本申请一种实施例提供的图像处理方法的流程图;FIG. 1 is a flowchart of an image processing method provided by an embodiment of the present application;
图2为本申请另一实施例提供的图像处理方法的流程图;FIG. 2 is a flowchart of an image processing method provided by another embodiment of the present application;
图3为本申请又一实施例提供的图像处理方法的流程图;FIG. 3 is a flowchart of an image processing method provided in another embodiment of the present application;
图4为本申请一种实施例提供的图像处理装置的结构示意图;FIG. 4 is a schematic structural diagram of an image processing device provided by an embodiment of the present application;
图5为本申请一种实施例提供的电子设备的结构示意图。Fig. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释本申请,而非对本申请的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本申请相关的部分而非全部结构。The application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the convenience of description, only some structures related to the present application are shown in the drawings but not all structures.
图1为本申请一种实施例提供的图像处理方法的流程图。本申请实施例提供的图像处理方法可适用于对图像进行处理的情况。典型的,本申请实施例适用于基于双平台直方图对待处理图像进行增强的情况。该方法具体可以由图像处理装置执行,该装置可以由软件和/或硬件的方式实现,该装置可以集成在能够实现图像处理方法的电子设备中,电子设备可以为智能图像采集器的处理器、独立于图像采集器之外的本地处理器或者云端处理器等。参见图1,本申请实施例的方法具体包括:FIG. 1 is a flowchart of an image processing method provided by an embodiment of the present application. The image processing method provided in the embodiment of the present application is applicable to the case of processing an image. Typically, this embodiment of the present application is applicable to the situation where the image to be processed is enhanced based on the dual-platform histogram. The method can specifically be executed by an image processing device, which can be implemented by software and/or hardware, and which can be integrated into an electronic device capable of implementing the image processing method, and the electronic device can be a processor of an intelligent image collector, A local processor or a cloud processor independent of the image collector. Referring to Figure 1, the method of the embodiment of the present application specifically includes:
S110、根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图。S110. Determine an initial histogram according to the high-pass filtered image of the image to be processed and the image to be processed, and determine a detail histogram of the image to be processed according to the initial histogram.
其中,待处理图像可以为图像采集器采集的图像,也可以是从本地或互联网获取的图像,待处理图像的格式和位宽不做具体限定,可以是任何格式和位宽的待处理图像,都可以采用本申请实施例中的方法进行处理。对高通滤波算法不做限定,例如可以为非锐化掩膜滤波、Sobel算子滤波、DOG算子滤波、LOG算子滤波、Laplacian算子滤波等。本申请实施例对滤波核的大小也不作限定,例如可以为3*3、或5*5、或7*7等,滤波核的形式可以为在采用滤波核对待处理图像进行处理前,先根据滤波核的大小,对待处理图像进行扩边处理,以使边缘的像素点能够位于滤波核的中心进行卷积处理。Wherein, the image to be processed can be an image collected by an image collector, or an image obtained locally or from the Internet. The format and bit width of the image to be processed are not specifically limited, and can be an image to be processed in any format and bit width. All can be processed by using the method in the embodiment of the present application. The high-pass filter algorithm is not limited, for example, it may be an unsharp mask filter, a Sobel operator filter, a DOG operator filter, a LOG operator filter, a Laplacian operator filter, and the like. The embodiment of the present application does not limit the size of the filter kernel, for example, it can be 3*3, or 5*5, or 7*7, etc., and the form of the filter kernel can be Before using the filter kernel to process the image to be processed, the image to be processed is first expanded according to the size of the filter kernel, so that the pixels on the edge can be located in the center of the filter kernel for convolution processing.
初始直方图为根据待处理图像的高通滤波图像和待处理图像直接确定的,初始直方图的横坐标值可以为待处理图像中的灰度级,初始直方图的纵坐标值可以为灰度级对应像素点在高通滤波图像中的细节数据的累加值。进一步对初始直方图进行处理,得到细节直方图。对初始直方图进行处理,例如可以为,对初始直方图中的部分数据进行滤除、对初始直方图中数据的顺序进行调整等,可以根据实际的需求进行处理。The initial histogram is directly determined according to the high-pass filtered image of the image to be processed and the image to be processed. The abscissa value of the initial histogram can be the gray level in the image to be processed, and the ordinate value of the initial histogram can be the gray level The cumulative value of the detail data corresponding to the pixel in the high-pass filtered image. The initial histogram is further processed to obtain the detail histogram. Processing the initial histogram may be, for example, filtering out some data in the initial histogram, adjusting the sequence of data in the initial histogram, etc., and may be processed according to actual requirements.
S120、根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值;其中,所述第一参考阈值和所述第二参考阈值根据所述细节累积直方图的最大统计值确定。其中,所述细节累积直方图为所述细节直方图的累积直方图;S120. According to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, determine from the statistical value of the detailed cumulative histogram A first platform threshold and a second platform threshold; wherein, the first reference threshold and the second reference threshold are determined according to the maximum statistical value of the detailed cumulative histogram. Wherein, the detail cumulative histogram is a cumulative histogram of the detail histogram;
其中,细节累积直方图的统计值可以为对细节直方图的细节数据的和进行累加得到的统计值。第一参考阈值和第二参考阈值可以根据细节累积直方图的最大统计值确定,例如,可以根据如下公式计算第一参考阈值和第二参考阈值:Wherein, the statistical value of the detail cumulative histogram may be a statistical value obtained by accumulating the sum of the detail data of the detail histogram. The first reference threshold and the second reference threshold can be determined according to the maximum statistical value of the detail cumulative histogram, for example, the first reference threshold and the second reference threshold can be calculated according to the following formula:
histSumUp=histSum*thistSumUp=histSum*t
histSumDown=histSum*(1-t)histSumDown=histSum*(1-t)
其中,histSumDown可以为第一参考阈值,histSumUp可以为第二参考阈值,histSum可以为细节累积直方图的最大统计值,0<t<1,t可以根据实际情况进行选取,例如可以选为0.85。在不同的场景中,t可以取不同的值。Wherein, histSumDown can be the first reference threshold, histSumUp can be the second reference threshold, histSum can be the maximum statistical value of the detail accumulation histogram, 0<t<1, t can be selected according to the actual situation, for example, it can be selected as 0.85. In different scenarios, t can take different values.
细节累积直方图计算公式为:The calculation formula of detail cumulative histogram is:
accSortHist(g)=accSortHist(g-1)+sortHist(g)accSortHist(g)=accSortHist(g-1)+sortHist(g)
其中,accSortHist(g)为细节累积直方图,sortHist(g)为细节直方图,g为灰度级。Among them, accSortHist(g) is the detail cumulative histogram, sortHist(g) is the detail histogram, and g is the gray level.
示例性的,以第一参考阈值和第二参考阈值作为参考,在细节累积直方图的统计值中确定第一平台阈值和第二平台阈值。例如,可以将细节累积直方图的统计值中,与第一参考阈值最接近且大于第一参考阈值的统计值作为第一平台阈值,将与第二参考阈值最接近且大于第二参考阈值的统计值作为第二平台阈值,或者将细节累积直方图中,与第一参考阈值最接近且小于第一参考阈值的统计值作为第一平台阈值,将与第二参考阈值最接近且小于第二参考阈值的统计值作为第二平台阈值,或者,将细节累积直方图的统计值中,与第一参考阈值最接近且大于第一参考阈值的统计值作为第一平台阈值,将与第二参考阈值最接近且小于第二参考阈值的统计值作为第二平台阈值,或者将细节累积直方图中,与第一参考阈值最接近且小于第一参考阈值的统计值作为第一平台阈值,将与第二参考阈值最接近且大于第二参考阈值的统计值作为第二平台阈值。Exemplarily, with the first reference threshold and the second reference threshold as references, the first platform threshold and the second platform threshold are determined from the statistical values of the detail cumulative histogram. For example, among the statistical values of the detail cumulative histogram, the statistical value closest to and greater than the first reference threshold can be used as the first platform threshold, and the statistical value closest to the second reference threshold and greater than the second reference threshold can be used as the first platform threshold. The statistical value is used as the second platform threshold, or the statistical value in the detail cumulative histogram that is closest to the first reference threshold and smaller than the first reference threshold is used as the first platform threshold, which is the closest to the second reference threshold and smaller than the second The statistical value of the reference threshold is used as the second platform threshold, or, among the statistical values of the detail cumulative histogram, the statistical value that is closest to the first reference threshold and greater than the first reference threshold is used as the first platform threshold, which will be compared with the second reference threshold. The statistical value closest to the threshold and smaller than the second reference threshold is used as the second platform threshold, or the statistical value closest to the first reference threshold and smaller than the first reference threshold in the detail cumulative histogram is used as the first platform threshold, which will be compared with A statistical value that is closest to the second reference threshold and greater than the second reference threshold is used as the second platform threshold.
上述方案的有益效果在于,由于细节累积直方图中包括待处理图像的细节信息,根据细节累积直方图确定第一平台阈值和第二平台阈值,从而使第一平台阈值和第二平台阈值适用于对当前场景下待处理图像的处理,提高图像处理效果。The beneficial effect of the above scheme is that, since the detail accumulation histogram includes the detail information of the image to be processed, the first platform threshold and the second platform threshold are determined according to the detail accumulation histogram, so that the first platform threshold and the second platform threshold are suitable for Improve the image processing effect by processing the image to be processed in the current scene.
S130、根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图。S130. Determine a dual-platform histogram according to the first platform threshold, the second platform threshold, and the initial histogram.
示例性的,根据第一平台阈值与初始直方图的统计值之间的关系,以及第二平台阈值与初始直方图的统计值之间的关系,构造双平台直方图。具体的,例如,如果第一平台阈值小于第二平台阈值,判断初始直方图的统计值与第一平台阈值、第二平台阈值的关系。如果初始直方图的统计值小于第一平台阈值,则将第一平台阈值替换初始直方图的统计值,如果初始直方图的统计值大于第二平台阈值,则将第二平台阈值替换初始直方图的统计值,如果初始直方图的统计值大于或等于第一平台阈值,小于或等于第二平台阈值,则保留初始直方图的统计值,从而形成双平台直方图。Exemplarily, a dual-platform histogram is constructed according to the relationship between the first platform threshold and the statistical value of the initial histogram, and the relationship between the second platform threshold and the statistical value of the initial histogram. Specifically, for example, if the first platform threshold is smaller than the second platform threshold, determine the relationship between the statistical value of the initial histogram and the first platform threshold and the second platform threshold. If the statistical value of the initial histogram is less than the first platform threshold, replace the statistical value of the initial histogram with the first platform threshold, and if the statistical value of the initial histogram is greater than the second platform threshold, replace the initial histogram with the second platform threshold If the statistical value of the initial histogram is greater than or equal to the threshold of the first platform and less than or equal to the threshold of the second platform, the statistical value of the initial histogram is retained to form a dual platform histogram.
S140、根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像。其中,所述双平台累积直方图为所述双平台直方图的累积直方图。S140. Determine a grayscale mapping relationship according to the dual-platform cumulative histogram, and process the image to be processed based on the grayscale mapping relationship to obtain a target image. Wherein, the dual-platform cumulative histogram is a cumulative histogram of the dual-platform histogram.
示例性的,根据双平台累积直方图确定灰度映射关系,从而确定每一灰度级所对应的数值,再根据待处理图像中各像素点的灰度级,确定该像素点对应的数值,赋予该像素点,得到目标图像。Exemplarily, the grayscale mapping relationship is determined according to the dual-platform cumulative histogram, thereby determining the value corresponding to each grayscale level, and then determining the value corresponding to the pixel point according to the grayscale level of each pixel in the image to be processed, Assign this pixel to get the target image.
其中,灰度映射关系可以根据实际情况确定,例如根据双平台累积直方图中各灰度级对应的统计值、最大灰度级对应的统计值以及灰度映射范围值,确定灰度映射关系。The grayscale mapping relationship can be determined according to the actual situation, for example, the grayscale mapping relationship can be determined according to the statistical value corresponding to each grayscale level in the dual-platform cumulative histogram, the statistical value corresponding to the maximum grayscale level, and the grayscale mapping range value.
本申请实施例中,根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图,从而统计待处理图像的高频分量,确定待处理图像的细节部分,根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值,从而使第一平台阈值和第二平台阈值的确定过程中考虑到了细节部分,以适用于当前场景下的待处理图像,根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图;根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像,从而提高对待处理图像的处理效果。In the embodiment of the present application, the initial histogram is determined according to the high-pass filtered image of the image to be processed and the image to be processed, and the detail histogram of the image to be processed is determined according to the initial histogram, so as to count the high Frequency component, determine the detail part of the image to be processed, according to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, from the Determining the first platform threshold and the second platform threshold in the statistical value of the detail cumulative histogram, so that the details are taken into account in the determination process of the first platform threshold and the second platform threshold, so as to be suitable for the image to be processed in the current scene, According to the first platform threshold, the second platform threshold and the initial histogram, determine a dual-platform histogram; determine the grayscale mapping relationship according to the dual-platform cumulative histogram, and determine the grayscale mapping relationship based on the grayscale mapping relationship The image to be processed is processed to obtain a target image, thereby improving the processing effect of the image to be processed.
图2为本申请另一实施例提供的图像处理方法的流程图。本申请实施例为对上述实施例的进一步优化,将S110细化为S210-S240。未在本申请实施例中详细描述的细节详见上述实施例。参见图2,本申请实施例提供的图像处理方法可以包括:FIG. 2 is a flowchart of an image processing method provided by another embodiment of the present application. In this embodiment of the present application, to further optimize the foregoing embodiments, S110 is subdivided into S210-S240. Details that are not described in detail in the embodiments of the present application can be found in the above-mentioned embodiments. Referring to Figure 2, the image processing method provided by the embodiment of the present application may include:
S210、遍历所述待处理图像的像素点,将具有同一灰度级的所述待处理图像的像素点作为目标像素点。S210. Traverse the pixels of the image to be processed, and use the pixels of the image to be processed with the same gray level as target pixels.
示例性的,从待处理图像的左上角第一个像素点开始进行遍历,确定各像素点的灰度级。将具有同一个像素级的像素点作为目标像素点。对于目标像素点不为零的灰度级,每一个灰度级对应一组目标像素点,一组像素点的数量为至少一个。Exemplarily, it traverses from the first pixel in the upper left corner of the image to be processed to determine the gray level of each pixel. Take the pixels with the same pixel level as the target pixels. For gray levels where the target pixel is not zero, each gray level corresponds to a group of target pixels, and the number of a group of pixels is at least one.
S220、根据高通滤波图像中所述目标像素点对应的细节数据的和,以及对应的灰度级,确定所述初始直方图。S220. Determine the initial histogram according to the sum of the detail data corresponding to the target pixel in the high-pass filtered image and the corresponding gray level.
示例性的,针对每一个灰度级,确定对应的目标像素点在高通滤波图像中所对应的细节数据,将每一个灰度级对应的一组目标像素点在高通滤波图像中所对应的细节数据的和,作为该灰度级对应的细节数据统计值,将灰度级作为横坐标值,灰度级对应的细节数据统计值作为纵坐标值,确定初始直方图。在本申请实施例中,待处理图像的灰度级为从0开始的,如果希望直方图中的灰度级从1开始,则可以将每一个灰度级均加一,对应的细节数据统计值不变,从而使横坐标值从1开始。Exemplarily, for each gray level, the detail data corresponding to the corresponding target pixel in the high-pass filtered image is determined, and the details corresponding to a group of target pixels corresponding to each gray level in the high-pass filtered image The sum of the data is used as the statistical value of the detailed data corresponding to the gray level, and the gray level is used as the abscissa value, and the statistical value of the detailed data corresponding to the gray level is used as the vertical coordinate value to determine the initial histogram. In the embodiment of this application, the gray level of the image to be processed starts from 0. If you want the gray level in the histogram to start from 1, you can add one to each gray level, and the corresponding detailed data statistics The value is unchanged so that the abscissa values start at 1.
其中,细节数据可以为imgHpss(i,j)α,imgHpss(i,j)为高通滤波图像中像素点(i,j)对应的值,α为细节程度,可以根据实际情况进行选取,如果希望强调细节,增加细节的影响,则可以将α设置为较大的值,如果不希望强调细节,减少细节的影响,则可以将将α设置为较小的值,α≥0。Among them, the detail data can be imgHpss(i,j) α , imgHpss(i,j) is the value corresponding to the pixel point (i,j) in the high-pass filter image, and α is the degree of detail, which can be selected according to the actual situation. If you want To emphasize details and increase the influence of details, you can set α to a larger value. If you do not want to emphasize details and reduce the influence of details, you can set α to a smaller value, α≥0.
S230、去除所述初始直方图中纵坐标值为零的项,并对所述初始直方图的横坐标值进行压缩,得到过滤直方图。S230. Remove items whose ordinate values are zero in the initial histogram, and compress the abscissa values of the initial histogram to obtain a filtered histogram.
在本申请实施例中,根据高通滤波图像中所述目标像素点对应的细节数据的和,以及对应的灰度级,确定所述初始直方图,默认情况是将目标像素点的细节数据的和作为纵坐标,对应的灰度级作为横坐标,进而执行S230-S240中对横坐标和纵坐标的操作。示例性的,如果初始直方图中纵坐标值为零,则说明该灰度级对应的像素点范围并不包括细节信息,则可以将该灰度级对应的纵坐标值去除,以简化初始直方图。将纵坐标值去除,并将对应的横坐标值去除,因此横坐标值减少,为了使横坐标值等间隔分布,可以压缩横坐标值,使其仍为等间隔的点。例如,初始直方图的横坐标值为1-256共256个值,间隔为1,如果去掉10个纵坐标值为零的项,对应的横坐标值也去除,横坐标值剩余246个值,则压缩横坐标值到1-246,从而使横坐标值等间隔分布。由压缩后的横坐标值与去除纵坐标值为零的项后剩余的纵坐标值构成过滤直方图,横坐标值与纵坐标值按照顺序一一对应。In this embodiment of the application, the initial histogram is determined according to the sum of the detail data corresponding to the target pixel in the high-pass filtered image and the corresponding gray level. The default is to use the sum of the detail data of the target pixel As the ordinate, the corresponding gray level is used as the abscissa, and then the operations on the abscissa and ordinate in S230-S240 are performed. Exemplarily, if the ordinate value in the initial histogram is zero, it means that the pixel point range corresponding to the gray level does not include detailed information, and the ordinate value corresponding to the gray level can be removed to simplify the initial histogram picture. The ordinate values are removed, and the corresponding abscissa values are removed, so the abscissa values are reduced. In order to make the abscissa values equally spaced, the abscissa values can be compressed so that they are still equally spaced points. For example, the abscissa value of the initial histogram has a total of 256 values from 1 to 256, and the interval is 1. If 10 items with a ordinate value of zero are removed, the corresponding abscissa value is also removed, leaving 246 values in the abscissa value. Then compress the abscissa values to 1-246, so that the abscissa values are equally spaced. The filtered histogram is formed by the compressed abscissa value and the remaining ordinate value after removing the item whose ordinate value is zero, and the abscissa value and the ordinate value correspond to each other in order.
示例性的,根据高通滤波图像中所述目标像素点对应的细节数据的和,以及对应的灰度级,确定所述初始直方图,实际情况也可以是将目标像素点对应的细节数据的和作为横坐标,将对应的灰度级作为纵坐标,则在后续执行S230-S240的操作时,将针对纵坐标的操作修改为针对横坐标的操作,将针对横坐标的操作修改为针对纵坐标的操作,也就是“去除所述初始直方图中横坐标值为零的项,并对所述初始直方图的纵坐标值进行压缩,得到过滤直方图。将所述过滤直方图的横坐标值按照大小顺序进行排列,得到细节直方图”。Exemplarily, the initial histogram is determined according to the sum of the detail data corresponding to the target pixel in the high-pass filtered image and the corresponding gray level. In actual situations, the sum of the detail data corresponding to the target pixel can also be As the abscissa, the corresponding gray level is used as the ordinate, then when the operations of S230-S240 are subsequently performed, the operation for the ordinate is modified to the operation for the abscissa, and the operation for the abscissa is modified to be for the ordinate The operation, that is, "remove the item whose abscissa value is zero in the initial histogram, and compress the ordinate value of the initial histogram to obtain a filtered histogram. The abscissa value of the filtered histogram Arrange in order of size to get a detail histogram".
S240、将所述过滤直方图的纵坐标值按照大小顺序进行排列,得到细节直方图。S240. Arrange the ordinate values of the filtering histogram in order of size to obtain a detail histogram.
示例性的,对于过滤直方图,横坐标值不变,将纵坐标值按照大小顺序排列,得到细节直方图。排序后的细节直方图能够更加直观地展示纵坐标值的变化情况,便于后续直观快速地根据细节直方图确定第一平台阈值和第二平台阈值。Exemplarily, for the filtering histogram, the abscissa values remain unchanged, and the ordinate values are arranged in order of size to obtain a detail histogram. The sorted detail histogram can more intuitively display the change of the ordinate value, which is convenient for subsequent intuitive and quick determination of the first platform threshold and the second platform threshold according to the detail histogram.
S250、根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值;其中,所述第一参考阈值和所述第二参考阈值根据所述细节累积直方图的最大统计值确定。S250. According to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, determine from the statistical value of the detailed cumulative histogram A first platform threshold and a second platform threshold; wherein, the first reference threshold and the second reference threshold are determined according to the maximum statistical value of the detailed cumulative histogram.
S260、根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图。S260. Determine a dual-platform histogram according to the first platform threshold, the second platform threshold, and the initial histogram.
S270、根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像。S270. Determine a grayscale mapping relationship according to the dual-platform cumulative histogram, and process the image to be processed based on the grayscale mapping relationship to obtain a target image.
本申请实施例中,通过根据高通滤波图像中所述目标像素点对应的细节数据的和,以及对应的灰度级,确定所述初始直方图,去除所述初始直方图中纵坐标值为零的项,并对所述初始直方图的横坐标值进行压缩,得到过滤直方图,将所述过滤直方图的纵坐标值按照大小顺序进行排列,得到细节直方图,从而实现对待处理图像中的高频细节信息进行统计,以便于后续根据细节信息确定双平台阈值,提高图像处理方法的场景适用性。In the embodiment of the present application, the initial histogram is determined according to the sum of the detail data corresponding to the target pixel in the high-pass filtered image and the corresponding gray level, and the ordinate value in the initial histogram is removed to be zero , and compress the abscissa values of the initial histogram to obtain a filtered histogram, and arrange the ordinate values of the filtered histogram in order of size to obtain a detail histogram, thereby realizing the The high-frequency detail information is counted to facilitate subsequent determination of the dual-platform threshold based on the detail information and improve the scene applicability of the image processing method.
图3为本申请又一实施例提供的图像处理方法的流程图。本申请实施例为对上述实施例的进一步优化,将S120细化为S320,将S140细化为S350-S370.需要说明的时,对S120的细化和S140的细化可以不同时进行,互不影响依赖,可以只对一个步骤进行细化,也可以对S120和S140都细化,在本申请实施例中详细描述的细节详见上述实施例。参见图3,本申请实施例提供的图像处理方法可以包括:FIG. 3 is a flow chart of an image processing method provided in another embodiment of the present application. In order to further optimize the above-mentioned embodiment, the embodiment of the present application refines S120 into S320, and refines S140 into S350-S370. When it needs to be explained, the refinement of S120 and the refinement of S140 may not be performed at the same time. Without affecting the dependence, only one step can be refined, and both S120 and S140 can be refined. For the details described in the embodiment of this application, refer to the above embodiment for details. Referring to Fig. 3, the image processing method provided by the embodiment of the present application may include:
S310、根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图。S310. Determine an initial histogram according to the high-pass filtered image of the image to be processed and the image to be processed, and determine a detail histogram of the image to be processed according to the initial histogram.
S320、将大于所述第一参考阈值,且与所述第一参考阈值的差值最小的细节累积直方图的统计值,作为第一平台阈值;以及,将大于所述第二参考阈值,且与所述第二参考阈值的差值最小的细节累积直方图的统计值,作为第二平台阈值。S320, taking the statistical value of the detail cumulative histogram that is greater than the first reference threshold and having the smallest difference with the first reference threshold as the first platform threshold; and, setting it greater than the second reference threshold, and The statistical value of the detail cumulative histogram with the smallest difference from the second reference threshold is used as the second platform threshold.
示例性的,在细节累积直方图中,如果存在细节累积直方图的统计值大于第一参考阈值,且与第一参考阈值的差值最小,则将细节累积直方图的该统计值作为第一平台阈值,如果存在细节累积直方图的统计值大于第二参考阈值,且与第二参考阈值的差值最小,则将该统计值作为第二平台阈值。Exemplarily, in the detailed cumulative histogram, if there is a statistical value of the detailed cumulative histogram greater than the first reference threshold, and the difference with the first reference threshold is the smallest, then the statistical value of the detailed cumulative histogram is taken as the first Platform threshold, if the statistical value of the detail accumulation histogram is greater than the second reference threshold and the difference with the second reference threshold is the smallest, then this statistical value is used as the second platform threshold.
S330、确定在细节累积直方图中所述第一平台阈值对应的第一灰度级,以及所述第二平台阈值对应的第二灰度级。S330. Determine the first gray level corresponding to the first platform threshold and the second gray level corresponding to the second platform threshold in the detail cumulative histogram.
示例性的,记录在细节累积直方图中第一平台阈值对应的第一灰度级,以及第二平台阈值对应的第二灰度级。如果第一平台阈值小于第二平台阈值,则第一灰度级小于第二灰度级。Exemplarily, the first gray level corresponding to the first platform threshold and the second gray level corresponding to the second platform threshold in the detail accumulation histogram are recorded. If the first plateau threshold is less than the second plateau threshold, the first gray scale is less than the second gray scale.
S340、根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图。S340. Determine a dual-platform histogram according to the first platform threshold, the second platform threshold, and the initial histogram.
在本申请实施例中,所述第一平台阈值小于所述第二平台阈值;相应地,根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图,包括:若所述初始直方图的统计值小于所述第一平台阈值,则将所述第一平台阈值替换所述初始直方图的统计值;若所述初始直方图的统计值大于所述第二平台阈值,则将所述第二平台阈值替换所述初始直方图的统计值;若所述初始直方图的统计值大于或等于所述第一平台阈值,且小于或等于所述第二平台阈值,则保留所述初始直方图的统计值。In the embodiment of the present application, the first platform threshold is smaller than the second platform threshold; correspondingly, according to the first platform threshold, the second platform threshold and the initial histogram, a dual-platform histogram is determined , including: if the statistical value of the initial histogram is smaller than the first platform threshold, then replacing the statistical value of the initial histogram with the first platform threshold; if the statistical value of the initial histogram is greater than the second platform threshold, then replace the statistical value of the initial histogram with the second platform threshold; if the statistical value of the initial histogram is greater than or equal to the first platform threshold and less than or equal to the second platform threshold, the statistical value of the initial histogram is retained.
示例性的,若t>0.5,则第一参考阈值小于第二参考阈值,第一平台阈值小于第二平台阈值,进而第一灰度级小于第二灰度级。再根据第一平台阈值、第二平台阈值以及初始直方图,确定双平台直方图,示例性的,可以根据如下公式确定双平台直方图:Exemplarily, if t>0.5, the first reference threshold is smaller than the second reference threshold, the first platform threshold is smaller than the second platform threshold, and thus the first gray level is smaller than the second gray level. Then, according to the first platform threshold, the second platform threshold and the initial histogram, determine the dual-platform histogram. Exemplarily, the dual-platform histogram can be determined according to the following formula:
其中,DPHist(g)为双平台直方图的统计值,Hist(g)为初始直方图的统计值,TDown为第一平台阈值,TUp为第二平台阈值,g为灰度级。Among them, DPHist(g) is the statistical value of the dual-platform histogram, Hist(g) is the statistical value of the initial histogram, TDown is the threshold of the first platform, TUp is the threshold of the second platform, and g is the gray level.
S350、根据各灰度级对应双平台累积直方图的统计值,与最大灰度级对应的所述双平台累积直方图的统计值,确定统计值比例。S350. Determine the statistical value ratio according to the statistical value of the dual-platform cumulative histogram corresponding to each gray level and the statistical value of the dual-platform cumulative histogram corresponding to the maximum gray level.
示例性的,根据双平台累积直方图确定双平台累积直方图,可以根据如下公式确定:Exemplarily, the dual-platform cumulative histogram is determined according to the dual-platform cumulative histogram, which can be determined according to the following formula:
accDPHist(g)=accDPHist(g-1)+DPHist(g)accDPHist(g)=accDPHist(g-1)+DPHist(g)
其中,accDPHist(g)为双平台累积直方图的统计值,DPHist(g)为双平台直方图的统计值。Among them, accDPHist(g) is the statistical value of the dual-platform cumulative histogram, and DPHist(g) is the statistical value of the dual-platform histogram.
示例性的,可以根据如下公式确定统计值比例:Exemplarily, the statistical value ratio can be determined according to the following formula:
其中,P为统计值比例,accDPHist(g)为双平台累积直方图的统计值,accDPHist(m)为最大灰度级对应的双平台累积直方图的统计值,m为双平台累积直方图中的最大灰度级。Among them, P is the statistical value ratio, accDPHist(g) is the statistical value of the dual-platform cumulative histogram, accDPHist(m) is the statistical value of the dual-platform cumulative histogram corresponding to the maximum gray level, and m is the dual-platform cumulative histogram maximum gray level.
S360、根据所述统计值比例与灰度映射范围值的乘积,确定所述灰度映射关系。S360. Determine the grayscale mapping relationship according to the product of the statistical value ratio and the grayscale mapping range value.
示例性的,灰度映射关系可以表示为:Exemplarily, the grayscale mapping relationship can be expressed as:
HistB(g)=P*RHistB(g)=P*R
其中,HistB(g)为灰度映射关系,R为灰度映射范围值,P为统计值比例。Among them, HistB(g) is the grayscale mapping relationship, R is the grayscale mapping range value, and P is the statistical value ratio.
在本申请实施例中,所述灰度映射范围值的确定过程包括:根据目标图像的预设位宽,确定目标图像的最大灰度级;若所述第一灰度级与所述第二灰度级之差的绝对值小于或等于所述最大灰度级,则所述灰度映射范围值为所述第一灰度级与所述第二灰度级之差的绝对值;若所述第一灰度级与所述第二灰度级之差的绝对值大于所述最大灰度级,则所述灰度映射范围值为最大灰度级。In the embodiment of the present application, the process of determining the grayscale mapping range value includes: determining the maximum grayscale level of the target image according to the preset bit width of the target image; If the absolute value of the difference between the gray levels is less than or equal to the maximum gray level, then the gray scale mapping range value is the absolute value of the difference between the first gray level and the second gray level; if the If the absolute value of the difference between the first gray level and the second gray level is greater than the maximum gray level, then the gray scale mapping range value is the maximum gray level.
示例性的,根据如下公式确定灰度映射范围值:Exemplarily, the grayscale mapping range value is determined according to the following formula:
其中,R为灰度映射范围值,rangeDown为第一灰度级,rangeUp为第二灰度级,n为根据目标图像的预设位宽确定的最大灰度级。Wherein, R is the grayscale mapping range value, rangeDown is the first grayscale level, rangeUp is the second grayscale level, and n is the maximum grayscale level determined according to the preset bit width of the target image.
S370、基于所述灰度映射关系对所述待处理图像进行处理得到目标图像。示例性的,基于如下公式对待处理图像进行处理:S370: Process the image to be processed based on the grayscale mapping relationship to obtain a target image. Exemplarily, the image to be processed is processed based on the following formula:
imgOut(i,j)=HistB(imgIn(i,j)+1)imgOut(i,j)=HistB(imgIn(i,j)+1)
其中,imgOut(i,j)为目标图像,HistB(imgIn(i,j)+1)为灰度映射关系,imgIn(i,j)为待处理图像的像素点(i,j)对应的灰度级,由于本申请实施例中直方图的灰度级为从1开始统计的,因此,在待处理图像的灰度级基础上加一,从而与直方图中的灰度级对应。Among them, imgOut(i,j) is the target image, HistB(imgIn(i,j)+1) is the grayscale mapping relationship, imgIn(i,j) is the grayscale corresponding to the pixel (i,j) of the image to be processed Since the gray level of the histogram in the embodiment of the present application is counted from 1, one is added to the gray level of the image to be processed, so as to correspond to the gray level in the histogram.
本申请实施例中,通过基于待处理图像的细节信息,确定第一平台阈值和第二平台阈值,进而确定双平台直方图,对待处理图像进行处理,从而提高了对不同场景下待处理图像的处理效果,本申请实施例的图像处理方法对于不同场景下的图像处理具有较好的场景适应性。In the embodiment of the present application, based on the detailed information of the image to be processed, the first platform threshold and the second platform threshold are determined, and then the dual platform histogram is determined to process the image to be processed, thereby improving the accuracy of the image to be processed in different scenarios. In terms of processing effect, the image processing method in the embodiment of the present application has better scene adaptability for image processing in different scenes.
图4为本申请一种实施例提供的图像处理装置的结构示意图。该装置可适用于对图像进行处理的情况。典型的,本申请实施例适用于基于双平台直方图对待处理图像进行增强的情况。该装置可以由软件和/或硬件的方式实现,该装置可以集成在电子设备中。参见图4,该装置具体包括:Fig. 4 is a schematic structural diagram of an image processing device provided by an embodiment of the present application. The device is suitable for processing images. Typically, this embodiment of the present application is applicable to the situation where the image to be processed is enhanced based on the dual-platform histogram. The device can be realized by software and/or hardware, and the device can be integrated in electronic equipment. Referring to Figure 4, the device specifically includes:
细节直方图确定模块410,用于根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图;A detail
阈值确定模块420,用于根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值;其中,所述第一参考阈值和所述第二参考阈值根据所述细节累积直方图的最大统计值确定,所述细节累积直方图为所述细节直方图的累积直方图;
双平台直方图确定模块430,用于根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图;A dual-platform
处理模块440,用于根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像;其中,所述双平台累积直方图为所述双平台直方图的累积直方图。The
在本申请实施例中,细节直方图确定模块410,包括:In the embodiment of the present application, the detail
目标像素点确定单元,用于遍历所述待处理图像的像素点,将具有同一灰度级的所述待处理图像的像素点作为目标像素点;a target pixel determination unit, configured to traverse the pixels of the image to be processed, and use the pixels of the image to be processed with the same gray level as the target pixel;
初始直方图确定单元,用于根据高通滤波图像中所述目标像素点对应的细节数据的和,以及对应的灰度级,确定所述初始直方图。The initial histogram determining unit is configured to determine the initial histogram according to the sum of the detail data corresponding to the target pixel in the high-pass filtered image and the corresponding gray level.
在本申请实施例中,细节直方图确定模块410,包括:In the embodiment of the present application, the detail
过滤直方图确定单元,用于去除所述初始直方图中纵坐标值为零的项,并对所述初始直方图的横坐标值进行压缩,得到过滤直方图;A filter histogram determination unit, configured to remove items whose ordinate values are zero in the initial histogram, and compress the abscissa values of the initial histogram to obtain a filter histogram;
排序单元,用于将所述过滤直方图的纵坐标值按照大小顺序进行排列,得到细节直方图。The sorting unit is configured to sort the ordinate values of the filtered histogram in order of size to obtain a detail histogram.
在本申请实施例中,阈值确定模块420,包括:In the embodiment of this application, the
第一平台阈值确定单元,用于将大于所述第一参考阈值,且与所述第一参考阈值的差值最小的细节累积直方图的统计值,作为第一平台阈值;以及,The first platform threshold determination unit is configured to use the statistical value of the detail accumulation histogram that is greater than the first reference threshold and has the smallest difference with the first reference threshold as the first platform threshold; and,
第二平台阈值确定单元,用于将大于所述第二参考阈值,且与所述第二参考阈值的差值最小的细节累积直方图的统计值,作为第二平台阈值;The second platform threshold determination unit is configured to use the statistical value of the detail accumulation histogram that is greater than the second reference threshold and has the smallest difference with the second reference threshold as the second platform threshold;
相应地,所述装置还包括:Correspondingly, the device also includes:
灰度级确定单元,用于确定在细节累积直方图中所述第一平台阈值对应的第一灰度级,以及所述第二平台阈值对应的第二灰度级。A gray level determining unit, configured to determine a first gray level corresponding to the first platform threshold and a second gray level corresponding to the second platform threshold in the detail cumulative histogram.
在本申请实施例中,所述第一平台阈值小于所述第二平台阈值;In this embodiment of the application, the first platform threshold is smaller than the second platform threshold;
相应地,双平台直方图确定模块430,包括:Correspondingly, the dual-platform
第一比较单元,用于若所述初始直方图的统计值小于所述第一平台阈值,则将所述第一平台阈值替换所述初始直方图的统计值;A first comparison unit, configured to replace the statistical value of the initial histogram with the first platform threshold if the statistical value of the initial histogram is smaller than the first platform threshold;
第二比较单元,用于若所述初始直方图的统计值大于所述第二平台阈值,则将所述第二平台阈值替换所述初始直方图的统计值;A second comparison unit, configured to replace the statistical value of the initial histogram with the second platform threshold if the statistical value of the initial histogram is greater than the second platform threshold;
第三比较单元,用于若所述初始直方图的统计值大于或等于所述第一平台阈值,且小于或等于所述第二平台阈值,则保留所述初始直方图的统计值。A third comparing unit, configured to retain the statistical value of the initial histogram if the statistical value of the initial histogram is greater than or equal to the first platform threshold and less than or equal to the second platform threshold.
在本申请实施例中,处理模块440,包括:In the embodiment of this application, the
统计比例值确定单元,用于根据各灰度级对应双平台累积直方图的统计值,与最大灰度级对应的所述双平台累积直方图的统计值,确定统计值比例;A statistical ratio value determining unit, configured to determine the statistical value ratio according to the statistical value of the dual-platform cumulative histogram corresponding to each gray level and the statistical value of the dual-platform cumulative histogram corresponding to the maximum gray level;
灰度映射关系确定单元,用于根据所述统计值比例与灰度映射范围值的乘积,确定所述灰度映射关系。The gray-scale mapping relationship determination unit is configured to determine the gray-scale mapping relationship according to the product of the statistical value ratio and the gray-scale mapping range value.
在本申请实施例中,所述装置还包括:In the embodiment of the present application, the device further includes:
最大灰度级确定模块,用于根据目标图像的预设位宽,确定目标图像的最大灰度级;The maximum gray level determination module is used to determine the maximum gray level of the target image according to the preset bit width of the target image;
第一范围值确定模块,用于若所述第一灰度级与所述第二灰度级之差的绝对值小于或等于所述最大灰度级,则所述灰度映射范围值为所述第一灰度级与所述第二灰度级之差的绝对值;The first range value determination module is configured to: if the absolute value of the difference between the first gray level and the second gray level is less than or equal to the maximum gray level, then the gray mapping range value is the absolute value of the difference between the first gray level and the second gray level;
第二范围值确定模块,用于若所述第一灰度级与所述第二灰度级之差的绝对值大于所述最大灰度级,则所述灰度映射范围值为最大灰度级。A second range value determination module, configured to determine the grayscale mapping range value as a maximum grayscale if the absolute value of the difference between the first grayscale level and the second grayscale level is greater than the maximum grayscale level class.
本申请实施例所提供的图像处理装置可执行本申请任意实施例所提供的图像处理方法,具备执行方法相应的功能模块和有益效果。The image processing device provided in the embodiment of the present application can execute the image processing method provided in any embodiment of the present application, and has corresponding functional modules and beneficial effects for executing the method.
图5为本申请一种实施例提供的电子设备的结构示意图。图5示出了适于用来实现本申请实施例的示例性电子设备512的框图。图5显示的电子设备512仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。Fig. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. FIG. 5 shows a block diagram of an exemplary
如图5所示,电子设备512可以包括:一个或多个处理器516;存储器528,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器516执行,使得所述一个或多个处理器516实现本申请实施例所提供的图像处理方法,包括:As shown in FIG. 5 , the
根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图;determining an initial histogram according to the high-pass filtered image of the image to be processed and the image to be processed, and determining a detail histogram of the image to be processed according to the initial histogram;
根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值;其中,所述第一参考阈值和所述第二参考阈值根据所述细节累积直方图的最大统计值确定,所述细节累积直方图为所述细节直方图的累积直方图;According to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, determine the first value from the statistical value of the detailed cumulative histogram. A platform threshold and a second platform threshold; wherein, the first reference threshold and the second reference threshold are determined according to the maximum statistical value of the detail cumulative histogram, and the detail cumulative histogram is the accumulation of the detail histogram histogram;
根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图;determining a dual platform histogram according to the first platform threshold, the second platform threshold and the initial histogram;
根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像;其中,所述双平台累积直方图为所述双平台直方图的累积直方图。Determine the grayscale mapping relationship according to the dual-platform cumulative histogram, and process the image to be processed based on the grayscale mapping relationship to obtain a target image; wherein, the dual-platform cumulative histogram is the dual-platform histogram The cumulative histogram of .
电子设备512的组件可以包括但不限于:一个或者多个处理器或者处理器516,存储器528,连接不同设备组件(包括存储器528和处理器516)的总线518。Components of
总线518表示几类总线结构中的一种或多种,包括存储器总线或者存储器控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(ISA)总线,微通道体系结构(MAC)总线,处理型ISA总线、视频电子标准协会(VESA)局域总线以及外围组件互连(PCI)总线。
电子设备512典型地包括多种计算机设备可读存储介质。这些存储介质可以是任何能够被电子设备512访问的可用存储介质,包括易失性和非易失性存储介质,可移动的和不可移动的存储介质。
存储器528可以包括易失性存储器形式的计算机设备可读存储介质,例如随机存取存储器(RAM)530和/或高速缓存存储器532。电子设备512可以进一步包括其它可移动/不可移动的、易失性/非易失性计算机设备存储介质。仅作为举例,存储系统534可以用于读写不可移动的、非易失性磁存储介质(图5未显示,通常称为“硬盘驱动器”)。尽管图5中未示出,可以提供用于对可移动非易失性磁盘(例如“软盘”)读写的磁盘驱动器,以及对可移动非易失性光盘(例如CD-ROM,DVD-ROM或者其它光存储介质)读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据存储介质接口与总线518相连。存储器528可以包括至少一个程序产品,该程序产品具有一组(例如至少一个)程序模块,这些程序模块被配置以执行本申请各实施例的功能。
具有一组(至少一个)程序模块542的程序/实用工具540,可以存储在例如存储器528中,这样的程序模块542包括但不限于操作设备、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。程序模块542通常执行本申请所描述的实施例中的功能和/或方法。A program/
电子设备512也可以与一个或多个外部设备514(例如键盘、指向设备、显示器524等)通信,还可与一个或者多个使得用户能与该电子设备512交互的设备通信,和/或与使得该电子设备512能与一个或多个其它计算设备进行通信的任何设备(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口522进行。并且,电子设备512还可以通过网络适配器520与一个或者多个网络(例如局域网(LAN),广域网(WAN)和/或公共网络,例如因特网)通信。如图5所示,网络适配器520通过总线518与电子设备512的其它模块通信。应当明白,尽管图5中未示出,可以结合电子设备512使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RAID设备、磁带驱动器以及数据备份存储设备等。The
处理器516通过运行存储在存储器528中的多个程序中其他程序的至少一个,从而执行各种功能应用以及数据处理,例如实现本申请实施例所提供的一种图像处理方法。The
本申请一种实施例提供了一种包含计算机可执行指令的存储介质,所述计算机可执行指令在由计算机处理器执行时用于执行图像处理方法,包括:An embodiment of the present application provides a storage medium containing computer-executable instructions, the computer-executable instructions are used to execute an image processing method when executed by a computer processor, including:
根据待处理图像的高通滤波图像以及所述待处理图像确定初始直方图,并根据所述初始直方图确定所述待处理图像的细节直方图;determining an initial histogram according to the high-pass filtered image of the image to be processed and the image to be processed, and determining a detail histogram of the image to be processed according to the initial histogram;
根据第一参考阈值与所述细节累积直方图的统计值的关系,以及第二参考阈值与所述细节累积直方图的统计值的关系,从所述细节累积直方图的统计值中确定第一平台阈值和第二平台阈值;其中,所述第一参考阈值和所述第二参考阈值根据所述细节累积直方图的最大统计值确定,所述细节累积直方图为所述细节直方图的累积直方图;According to the relationship between the first reference threshold and the statistical value of the detailed cumulative histogram, and the relationship between the second reference threshold and the statistical value of the detailed cumulative histogram, determine the first value from the statistical value of the detailed cumulative histogram. A platform threshold and a second platform threshold; wherein, the first reference threshold and the second reference threshold are determined according to the maximum statistical value of the detail cumulative histogram, and the detail cumulative histogram is the accumulation of the detail histogram histogram;
根据所述第一平台阈值、所述第二平台阈值以及所述初始直方图,确定双平台直方图;determining a dual platform histogram according to the first platform threshold, the second platform threshold and the initial histogram;
根据所述双平台累积直方图确定灰度映射关系,并基于所述灰度映射关系对所述待处理图像进行处理得到目标图像;其中,所述双平台累积直方图为所述双平台直方图的累积直方图。Determine the grayscale mapping relationship according to the dual-platform cumulative histogram, and process the image to be processed based on the grayscale mapping relationship to obtain a target image; wherein, the dual-platform cumulative histogram is the dual-platform histogram The cumulative histogram of .
本申请实施例的计算机存储介质,可以采用一个或多个计算机可读的存储介质的任意组合。计算机可读存储介质可以是计算机可读信号存储介质或者计算机可读存储介质。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的设备、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请实施例中,计算机可读存储介质可以是任何包含或存储程序的有形存储介质,该程序可以被指令执行设备、装置或者器件使用或者与其结合使用。The computer storage medium in the embodiments of the present application may use any combination of one or more computer-readable storage media. The computer readable storage medium may be a computer readable signal storage medium or a computer readable storage medium. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor device, device, or device, or any combination thereof. More specific examples (non-exhaustive list) of computer readable storage media include: electrical connections with one or more leads, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), Erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the embodiments of the present application, a computer-readable storage medium may be any tangible storage medium containing or storing a program, and the program may be used by or in combination with an instruction execution device, device, or device.
计算机可读的信号存储介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号存储介质还可以是计算机可读存储介质以外的任何计算机可读存储介质,该计算机可读存储介质可以发送、传播或者传输用于由指令执行设备、装置或者器件使用或者与其结合使用的程序。A computer readable signal storage medium may include a data signal carrying computer readable program code in baseband or as part of a carrier wave traveling as a data signal. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal storage medium may also be any computer-readable storage medium other than a computer-readable storage medium that can be sent, propagated, or transmitted for use by or in conjunction with an instruction execution device, apparatus, or device the program used.
计算机可读存储介质上包含的程序代码可以用任何适当的存储介质传输,包括——但不限于无线、电线、光缆、RF等等,或者上述的任意合适的组合。Program code embodied on a computer readable storage medium may be transmitted using any appropriate storage medium, including - but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
可以以一种或多种程序设计语言或其组合来编写用于执行本申请操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或设备上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for performing the operations of the present application may be written in one or more programming languages or combinations thereof, including object-oriented programming languages—such as Java, Smalltalk, C++, and conventional Procedural Programming Language - such as "C" or a similar programming language. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or device. In cases involving a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as through an Internet service provider). Internet connection).
注意,上述仅为本申请的较佳实施例及所运用技术原理。本领域技术人员会理解,本申请不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种明显的变化、重新调整和替代而不会脱离本申请的保护范围。因此,虽然通过以上实施例对本申请进行了较为详细的说明,但是本申请不仅仅限于以上实施例,在不脱离本申请构思的情况下,还可以包括更多其他等效实施例,而本申请的范围由所附的权利要求范围决定。Note that the above are only preferred embodiments and technical principles used in this application. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present application. Therefore, although the present application has been described in detail through the above embodiments, the present application is not limited to the above embodiments, and can also include more other equivalent embodiments without departing from the concept of the present application, and the present application The scope is determined by the scope of the appended claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110590447.9A CN113191990B (en) | 2021-05-28 | 2021-05-28 | Image processing method, device, electronic equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110590447.9A CN113191990B (en) | 2021-05-28 | 2021-05-28 | Image processing method, device, electronic equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113191990A CN113191990A (en) | 2021-07-30 |
CN113191990B true CN113191990B (en) | 2023-05-23 |
Family
ID=76985936
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110590447.9A Active CN113191990B (en) | 2021-05-28 | 2021-05-28 | Image processing method, device, electronic equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113191990B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115660997B (en) * | 2022-11-08 | 2023-06-02 | 杭州微影软件有限公司 | Image data processing method and device and electronic equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102521813A (en) * | 2011-11-21 | 2012-06-27 | 华中科技大学 | Infrared image adaptive enhancement method based on dual-platform histogram |
CN109377464A (en) * | 2018-10-08 | 2019-02-22 | 嘉应学院 | A dual-platform histogram equalization method for infrared images and its application system |
Family Cites Families (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102456224A (en) * | 2010-10-19 | 2012-05-16 | 高森 | Real-time digital image enhancement method based on field programmable gate array (FPGA) |
CN103778900B (en) * | 2012-10-23 | 2016-04-20 | 浙江大华技术股份有限公司 | A kind of image processing method and system |
CN103353349B (en) * | 2013-06-18 | 2016-08-10 | 南京理工大学 | Infrared-thermometerself-adaption self-adaption three platform histogram equalization system and method thereof |
CN106097286B (en) * | 2016-06-21 | 2019-02-12 | 浙江大华技术股份有限公司 | A kind of method and device of image procossing |
WO2018218478A1 (en) * | 2017-05-31 | 2018-12-06 | 上海联影医疗科技有限公司 | Method and system for image processing |
CN107292856A (en) * | 2017-06-12 | 2017-10-24 | 北京理工大学 | A kind of method of infrared focal plane detector image enhaucament |
US20190392311A1 (en) * | 2018-06-21 | 2019-12-26 | Deep Force Ltd. | Method for quantizing a histogram of an image, method for training a neural network and neural network training system |
US11276152B2 (en) * | 2019-05-28 | 2022-03-15 | Seek Thermal, Inc. | Adaptive gain adjustment for histogram equalization in an imaging system |
CN111784609B (en) * | 2020-07-02 | 2023-11-07 | 烟台艾睿光电科技有限公司 | Image dynamic range compression method, device and computer readable storage medium |
CN112348763B (en) * | 2020-11-09 | 2024-05-14 | 西安宇视信息科技有限公司 | Image enhancement method, device, electronic equipment and medium |
-
2021
- 2021-05-28 CN CN202110590447.9A patent/CN113191990B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102521813A (en) * | 2011-11-21 | 2012-06-27 | 华中科技大学 | Infrared image adaptive enhancement method based on dual-platform histogram |
CN109377464A (en) * | 2018-10-08 | 2019-02-22 | 嘉应学院 | A dual-platform histogram equalization method for infrared images and its application system |
Non-Patent Citations (2)
Title |
---|
基于双平台直方图的红外图像增强算法;宋岩峰,等;红外与激光工程(第02期);125-128 * |
基于改进型平台直方图的红外均衡化算法;毛义伟,等;光学与光电技术(第05期);66-69 * |
Also Published As
Publication number | Publication date |
---|---|
CN113191990A (en) | 2021-07-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019134504A1 (en) | Method and device for blurring image background, storage medium, and electronic apparatus | |
WO2020108018A1 (en) | Game scene processing method and apparatus, electronic device, and storage medium | |
US20210281718A1 (en) | Video Processing Method, Electronic Device and Storage Medium | |
WO2020233178A1 (en) | Image processing method and apparatus, and electronic device | |
US10964028B2 (en) | Electronic device and method for segmenting image | |
CN116310875A (en) | Target detection method and device for satellite remote sensing images | |
CN105894464A (en) | Median filtering image processing method and apparatus | |
CN110335216A (en) | Image processing method, image processing apparatus, terminal device and readable storage medium | |
CN113163123A (en) | Automatic focusing method and device, electronic equipment and storage medium | |
CN110708568A (en) | Video content mutation detection method and device | |
CN115660976A (en) | Image processing method, device, device and computer-readable storage medium | |
CN113191990B (en) | Image processing method, device, electronic equipment and medium | |
CN110728692A (en) | Image edge detection method based on Scharr operator improvement | |
CN115293993B (en) | A sampling method and system for filtering salt and pepper noise | |
CN114758268A (en) | Gesture recognition method and device and intelligent equipment | |
CN115564694A (en) | Image processing method and device, computer-readable storage medium, and electronic device | |
CN103516959A (en) | Image processing method and device | |
CN115689906A (en) | An image processing method and device | |
CN114596210A (en) | Noise estimation method, device, terminal equipment and computer readable storage medium | |
CN110807300A (en) | Image processing method and device, electronic equipment and medium | |
CN113573137A (en) | Video canvas boundary detection method, system, terminal equipment and storage medium | |
CN111833262A (en) | Image noise reduction method, device and electronic device | |
CN115984127A (en) | A real-time image noise reduction method based on GPU | |
CN115862044A (en) | Method, apparatus, and medium for extracting target document part from image | |
CN112911186B (en) | Image storage method and device, electronic equipment and 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |