Image defogging method and device for visible light television and electronic equipment
By analyzing and adjusting the image histogram, segmenting and processing local images, the problem of poor image dehazing effect in the existing technology is solved, and a clearer and natural image dehazing effect is achieved.
Patent Information
- Application Number
- CN202410618667.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2024-09-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When existing image defogging technology improves image clarity and visibility, it can easily lead to over-enhancement of image areas, resulting in unnatural edges and artifacts, resulting in poor dehazing effects.
By analyzing the histogram of the target image, determine the limit threshold to balance the histogram distribution of the local image, segment the image, crop and fill the high grayscale parts in the histogram, map the grayscale level to limit the contrast enhancement range, and reduce noise enhancement .
It improves the effect of image defogging, enhances image clarity and visibility, reduces unnecessary noise enhancement, and ensures natural expression of contrast and details.
Smart Images

Figure CN118710539A
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and in particular relates to a method, device and electronic equipment for defogging an image of a visible light television. Background Art
[0002] Visible light television is a photoelectric sensor used to convert visible light signals into electronic signals. It can be used to obtain image information of the target to help users monitor and observe. Images taken in low-visibility environments such as fog, haze, rain, and snow will have reduced contrast and color saturation due to atmospheric scattering and reflection, resulting in loss of details. In order to improve the clarity and visibility of images obtained by visible light television, image defogging technology is usually used to process the images.
[0003] Image dehazing technology aims to eliminate or mitigate image degradation caused by atmospheric conditions and restore image clarity and color through image processing methods. Image enhancement-based dehazing methods are a commonly used image dehazing technology, which usually improves the visual effect of images by adjusting the contrast, brightness and color of the images.
[0004] When enhancing image contrast and details, some areas of the image may be over-enhanced, resulting in unnatural edges and artifacts, resulting in poor dehazing effect. Summary of the invention
[0005] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a method, device and electronic device for defogging an image of a visible light television to improve the effect of defogging an image, thereby improving the clarity and visibility of the image acquired by the visible light television.
[0006] In a first aspect, the present application provides a method for defogging an image of a visible light television, comprising:
[0007] Determining a limiting threshold value according to a first histogram corresponding to a target image captured by a visible light television, so that a ratio of an area of a portion of the first histogram exceeding the limiting threshold value to a total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each gray level;
[0008] Segmenting the target image to obtain a plurality of sub-images;
[0009] The portion of the second histogram corresponding to each sub-image that exceeds the limit threshold is cropped and filled to the portion that does not exceed the limit threshold, so as to obtain a third histogram corresponding to each sub-image;
[0010] Based on the third histogram, each grayscale level in each sub-image is mapped to a target grayscale level to obtain a defogged target image.
[0011] According to the image defogging method for a visible light television of the present application, a limiting threshold is determined based on a first histogram corresponding to a target image captured by the visible light television, so that the ratio of the area of the portion exceeding the limiting threshold in the first histogram to the total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each grayscale level; the target image is segmented to obtain a plurality of sub-images; the portion exceeding the limiting threshold in the second histogram corresponding to each sub-image is cropped and padded to the portion not exceeding the limiting threshold to obtain a third histogram corresponding to each sub-image; and each grayscale level in each sub-image is mapped to a target grayscale level based on the third histogram to obtain a defogged target image. The embodiment of the present application analyzes the histogram of the target image, finds the part of the target image with a relatively concentrated grayscale distribution according to the histogram, thereby determining a limiting threshold, and then segments the target image, processes each local image separately, limits the histogram height of the local image by limiting the threshold, and performs cropping and padding to balance the distribution of the histogram of each local image, thereby limiting the grayscale range of the local image being raised, limiting the contrast raising interval, reducing unnecessary noise enhancement in the process of image defogging, improving the image defogging effect, and thus improving the clarity and visibility of the image acquired by the visible light television.
[0012] According to an embodiment of the present application, determining the limiting threshold according to the first histogram corresponding to the target image captured by the visible light television so that the ratio of the area of the portion exceeding the limiting threshold in the first histogram to the total area of the first histogram is a preset value includes:
[0013] Performing statistical analysis on pixels of a target image to obtain a first histogram of the target image;
[0014] The ratio of the area of the portion above each ordinate value in the first histogram to the total area of the first histogram is traversed until the ratio reaches a preset value, and the current ordinate value is used as the limiting threshold.
[0015] This embodiment obtains a histogram by analyzing the pixels of the global image, and then based on the distribution of the histogram, finds the part of the target image where the grayscale distribution is relatively concentrated by the area of the histogram, thereby determining a limiting threshold to facilitate subsequent balancing of the distribution of the histograms of each local image.
[0016] According to an embodiment of the present application, the preset value is 20%-35%.
[0017] In this embodiment, if the limiting threshold is too high, the distribution balance of the histogram of each local image will be poor, and it will be difficult to achieve the effect of limiting the contrast increase interval. If the limiting threshold is too low, the distribution of the histogram of each local image will be over-balanced, making the contrast too low. Setting the limiting threshold to 20%-35% can achieve the distribution balance of the histogram of each local image without making the contrast too low, thereby improving the dehazing effect of the image.
[0018] According to an embodiment of the present application, the segmentation process of the target image to obtain a plurality of sub-images includes:
[0019] Dividing a portion of a preset range of a central area of the target image into a plurality of sub-images of a first size;
[0020] The portion outside the preset range of the central area of the target image is divided into a plurality of sub-images of a second size; wherein the first size is smaller than the second size.
[0021] In this embodiment, since the center of the image may contain the main or most important information, the image within the center range of the image is divided into images of smaller sizes, so that the granularity of the image enhancement within the center range is finer, so as to improve the defogging effect of the image within the center range, and the image outside the center range is divided into images of larger sizes, which is beneficial to improve the efficiency of image defogging.
[0022] According to an embodiment of the present application, the step of clipping the portion of the second histogram corresponding to each sub-image that exceeds the limit threshold and then padding it to the portion that does not exceed the limit threshold to obtain the third histogram corresponding to each sub-image includes:
[0023] Cutting the part exceeding the limit threshold in the second histogram corresponding to each sub-image;
[0024] The cropped parts are evenly filled into the parts of the second histogram that do not exceed the limit threshold according to the grayscale level, so as to obtain the third histogram corresponding to each sub-image.
[0025] In this embodiment, by cropping the histogram of each sub-image based on a limiting threshold, the grayscale range of each sub-image can be limited, the contrast increase interval can be limited, and unnecessary noise enhancement in the image dehazing process can be reduced. The cropped part is evenly filled according to the grayscale level to the part that does not exceed the limiting threshold, which can further balance the distribution of the histogram of each local image, thereby improving the image dehazing effect.
[0026] According to an embodiment of the present application, mapping each grayscale level in each sub-image to a target grayscale level based on the third histogram to obtain a defogged target image includes:
[0027] Normalizing the third histogram to obtain a normalized histogram corresponding to each sub-image; the normalized histogram represents the probability of occurrence of each gray level;
[0028] Obtaining a cumulative histogram representing the cumulative probability of each gray level based on the probability of each gray level appearing in the normalized histogram;
[0029] Performing linear mapping on each gray level of the cumulative histogram based on the cumulative probability to obtain a target gray level corresponding to each gray level;
[0030] The target grayscale level is used to replace each grayscale level in each sub-image to obtain a defogged target image.
[0031] In this embodiment, the cumulative probability distribution of each gray level is calculated based on the adjusted normalized histogram, so that when the gray levels of the cumulative histogram are linearly mapped, values with similar probabilities can be mapped to the same value, thereby allowing each sub-image to evolve into an image with a more uniform grayscale distribution, making the image contrast stronger and the details in the image clearer.
[0032] In a second aspect, the present application provides an image defogging device for a visible light television, comprising:
[0033] A determination module, configured to determine a limiting threshold value according to a first histogram corresponding to a target image captured by a visible light television, so that a ratio of an area of a portion of the first histogram exceeding the limiting threshold value to a total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each gray level;
[0034] A segmentation module, used for segmenting the target image to obtain multiple sub-images;
[0035] A cropping module, used for cropping the part of the second histogram corresponding to each sub-image that exceeds the limit threshold and then filling it to the part that does not exceed the limit threshold, so as to obtain a third histogram corresponding to each sub-image;
[0036] A mapping module is used to map each gray level in each sub-image to a target gray level based on the third histogram to obtain a defogged target image.
[0037] According to the image defogging device for a visible light television of the present application, a limiting threshold is determined based on a first histogram corresponding to a target image captured by the visible light television, so that the ratio of the area of the portion exceeding the limiting threshold in the first histogram to the total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each grayscale level; the target image is segmented to obtain a plurality of sub-images; the portion exceeding the limiting threshold in the second histogram corresponding to each sub-image is cropped and padded to the portion not exceeding the limiting threshold to obtain a third histogram corresponding to each sub-image; and each grayscale level in each sub-image is mapped to a target grayscale level based on the third histogram to obtain a defogged target image. The embodiment of the present application analyzes the histogram of the target image, finds the part of the target image with a relatively concentrated grayscale distribution according to the histogram, thereby determining a limiting threshold, and then segments the target image, processes each local image separately, limits the histogram height of the local image by limiting the threshold, and performs cropping and padding to balance the distribution of the histogram of each local image, thereby limiting the grayscale range of the local image being raised, limiting the contrast raising interval, reducing unnecessary noise enhancement in the process of image defogging, improving the image defogging effect, and thus improving the clarity and visibility of the image acquired by the visible light television.
[0038] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the image defogging method for a visible light television as described in the first aspect above is implemented.
[0039] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the image defogging method for a visible light television as described in the first aspect above is implemented.
[0040] In a fifth aspect, the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the image defogging method for a visible light television as described in the first aspect above.
[0041] In a sixth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the image defogging method for a visible light television as described in the first aspect above.
[0042] The above one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:
[0043] According to the image defogging method for a visible light television of the present application, a limiting threshold is determined based on a first histogram corresponding to a target image captured by the visible light television, so that the ratio of the area of the portion exceeding the limiting threshold in the first histogram to the total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each grayscale level; the target image is segmented to obtain a plurality of sub-images; the portion exceeding the limiting threshold in the second histogram corresponding to each sub-image is cropped and padded to the portion not exceeding the limiting threshold to obtain a third histogram corresponding to each sub-image; and each grayscale level in each sub-image is mapped to a target grayscale level based on the third histogram to obtain a defogged target image. The embodiment of the present application analyzes the histogram of the target image, finds the part of the target image with a relatively concentrated grayscale distribution according to the histogram, thereby determining a limiting threshold, and then segments the target image, processes each local image separately, limits the histogram height of the local image by limiting the threshold, and performs cropping and padding to balance the distribution of the histogram of each local image, thereby limiting the grayscale range of the local image being raised, limiting the contrast raising interval, reducing unnecessary noise enhancement in the process of image defogging, improving the image defogging effect, and thus improving the clarity and visibility of the image acquired by the visible light television.
[0044] Furthermore, in some embodiments, a histogram is obtained by analyzing the pixels of the global image, and then based on the distribution of the histogram, the area of the histogram is used to find the part of the target image where the grayscale distribution is more concentrated, thereby determining a limiting threshold to facilitate the subsequent balancing of the distribution of the histograms of each local image.
[0045] Furthermore, in some embodiments, if the limiting threshold is too high, the distribution balance of the histogram of each local image will be poor, and it will be difficult to achieve the effect of limiting the contrast increase interval. If the limiting threshold is too low, the distribution of the histogram of each local image will be over-balanced, making the contrast too low. Setting the limiting threshold to 20%-35% can achieve the distribution balance of the histogram of each local image without making the contrast too low, thereby improving the image dehazing effect.
[0046] Furthermore, in some embodiments, since the center of the image may contain the main or most important information, the image within the center range of the image is divided into images of smaller sizes, so that the granularity of image enhancement within the center range is finer, so as to improve the defogging effect of the image within the center range, and the image outside the center range is divided into images of larger sizes, which is beneficial to improving the efficiency of image defogging.
[0047] Furthermore, in some embodiments, by cropping the histogram of each sub-image based on a limiting threshold, the grayscale range of each sub-image can be limited, the contrast increase interval can be limited, and unnecessary noise enhancement in the image dehazing process can be reduced. The cropped part is evenly filled according to the grayscale level to the part that does not exceed the limiting threshold, which can further balance the distribution of the histogram of each local image, thereby improving the image dehazing effect.
[0048] Furthermore, in some embodiments, by calculating the cumulative probability distribution of each gray level based on the adjusted normalized histogram, when linear mapping is performed on the gray levels of the cumulative histogram, values with similar probabilities can be mapped to the same value, thereby allowing each sub-image to evolve into an image with a more uniform grayscale distribution, making the image contrast stronger and the details in the image clearer.
[0049] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0051] Figure 1 It is a flow chart of an image defogging method for a visible light television provided in an embodiment of the present application;
[0052] Figure 2 is a schematic diagram of cropping and filling a histogram according to an embodiment of the present application;
[0053] Figure 3 is the target image before image defogging in the embodiment of the present application;
[0054] Figure 4 is the target image after image defogging in the embodiment of the present application;
[0055] Figure 5 is a schematic diagram of the structure of an image defogging device for a visible light television provided in an embodiment of the present application;
[0056] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0058] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0059] Visible light television can capture images within the visible light range and convert them into electronic signals so that they can be displayed on a monitor or further processed. Visible light televisions are usually composed of optical lenses, photosensitive elements (such as photodiodes or phototransistors), signal processing circuits, etc.
[0060] Visible light television has a wide range of applications in many fields. For example, in the aerospace field, visible light television is used for navigation, target recognition, flight control, etc. In the industrial field, visible light television is used for detection and quality control, such as machine vision systems; in the medical field, visible light television can be used for medical imaging, surgical navigation and other applications; of course, visible light television is also widely used in the civilian field, such as cameras, monitoring systems, drones, smart phones and other devices.
[0061] In the process of observation and identification through visible light television, if you encounter low visibility environments such as fog, haze, rain, snow, etc., the contrast and color saturation of the images taken in such environments will be reduced due to atmospheric scattering and reflection, resulting in loss of details. In order to improve the clarity and visibility of images obtained by visible light television, image defogging technology is usually used to process the images.
[0062] Image dehazing technology can be divided into three categories: image enhancement-based, physical model dehazing and deep learning model dehazing.
[0063] Physical model dehazing is based on the atmospheric scattering model, which separates and restores clear images by estimating atmospheric transmittance and atmospheric light. This method requires a certain understanding of atmospheric conditions and relies on accurate estimation of physical parameters. Physical model dehazing can better restore image details, but parameter estimation may become difficult under complex or changing atmospheric conditions.
[0064] Deep learning methods learn the mapping relationship of dehazing by training neural networks. This method can handle complex image degradation situations, and the dehazing effect will gradually improve as the training data increases. However, deep learning models usually require a large amount of labeled data and computing resources, and the generalization ability and robustness of the model are still hot topics for research.
[0065] Dehazing methods based on image enhancement usually improve the visual effect of the image by adjusting the contrast, brightness and color of the image. For example, the overall contrast of the image can be enhanced, while local contrast enhancement can highlight specific areas in the image. This method is simple and easy to implement, but when enhancing the contrast and details of the image, it may cause over-enhancement in some areas of the image, resulting in unnatural edges and artifacts, resulting in poor dehazing effect.
[0066] The present application considers that if it is possible to find the part of the image where the grayscale is more concentrated, and then adjust the grayscale of the image separately, thereby limiting the grayscale range of the local image that is pulled up to achieve image dehazing, it is expected to solve the problem in the prior art that may cause over-enhancement in certain areas of the image.
[0067] In the following, in conjunction with the accompanying drawings, the image defogging method, device and electronic device for a visible light television provided in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.
[0068] Among them, the image defogging method for visible light television can be applied to a terminal, and can be specifically executed by hardware or software in the terminal.
[0069] The terminal includes, but is not limited to, a portable communication device such as a mobile phone or tablet computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad). It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad).
[0070] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse and a joystick.
[0071] The image defogging method for a visible light television provided in an embodiment of the present application may be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the image defogging method for a visible light television. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The image defogging method for a visible light television provided in an embodiment of the present application is described below using an electronic device as an example of an execution subject.
[0072] like Figure 1 As shown, the image defogging method for the visible light television includes: step 110, step 120, step 130 and step 140.
[0073] Step 110: determine a limiting threshold value based on a first histogram corresponding to a target image captured by a visible light television, so that a ratio of an area of a portion of the first histogram exceeding the limiting threshold value to a total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each gray level.
[0074] Visible light television can capture optical images of scenes through devices such as visible light cameras or cameras. These devices usually contain one or more image sensors (such as CCD or CMOS sensors) that can convert light signals into electrical signals. The analog-to-digital converter (ADC) inside the camera converts the analog image signals captured by the sensor into digital signals, which represent the pixel values of the image, usually stored in the form of grayscale values or color values.
[0075] The digital signal is then sent to the image processor for necessary processing, such as white balance adjustment, color correction, contrast and brightness adjustment, image enhancement, etc.
[0076] In an embodiment of the present application, a target image captured by a visible light television may be transmitted to an electronic device in the form of a digital signal, and the electronic device may perform corresponding processing on the target image captured by the visible light television.
[0077] In the embodiment of the present application, the histogram of an image is a statistical chart of the frequency of occurrence of pixel values in the image, which shows the number of each pixel value in the image. The histogram can help understand information such as image contrast, brightness distribution, and color distribution.
[0078] The limiting threshold may be a value used to limit the height of the histogram, that is, the limiting threshold may be used to perform corresponding processing on the pixels in the histogram that exceed the limiting threshold, so as to achieve defogging of the image. Specifically, the limiting threshold may be determined based on the distribution of the number of pixels at each gray level in the histogram. For example, a preset value may be set in advance. In the first histogram, the ratio of the area above the limiting threshold to the area below the limiting threshold is equal to the preset value, or is within a certain range near the ratio. Based on this setting, the limiting threshold may be determined.
[0079] Step 120: Segment the target image to obtain multiple sub-images.
[0080] In the embodiment of the present application, a segmentation strategy can be determined, that is, it is necessary to determine how to segment the target image. The segmentation strategy can be based on the content, structural features, or uniform distribution of the image. For example, you can choose to evenly divide the image into N×M small blocks, or perform non-uniform segmentation based on specific features in the image (such as edges, color distribution, etc.). M can be determined based on the resolution size, such as M=w / 10, N=h / 10, w and h represent the width and height of the image, respectively.
[0081] Secondly, the size of each sub-image can be determined, for example, it can be a fixed pixel size (such as 100x100 pixels), or it can be determined adaptively according to the image content. Then, according to the determined segmentation strategy and the size of the sub-image, the target image is divided into multiple sub-image blocks. When implementing programming, the functions provided by the image processing library (such as OpenCV, PIL, etc.) can be used to assist in the calculation of image coordinates and the interception of image data.
[0082] Furthermore, during the segmentation process, boundary problems may be encountered. That is, if the image cannot be divided by the size of the sub-image block, the sub-image block on the boundary may be smaller than other sub-image blocks. In this case, padding (such as zero padding, copying boundary pixels, etc.) or discarding boundary pixels can be used to deal with it.
[0083] Of course, the sub-images obtained by segmentation need to be stored and managed for subsequent processing and analysis. Each sub-image block can be saved as a separate file, or stored in a list or other data structure for subsequent access and operation.
[0084] Step 130 , cropping the portion of the second histogram corresponding to each sub-image that exceeds the limiting threshold and padding it to the portion that does not exceed the limiting threshold, so as to obtain a third histogram corresponding to each sub-image.
[0085] Contrast is an indicator of image distinguishability, and is calculated by the maximum grayscale value max and the minimum grayscale value min as C = (max-min) / (max+min). That is, if the maximum and minimum grayscale values of the image are both 128, the contrast is 0; if the maximum value is 255 and the minimum value is 0, the contrast is 1, so the contrast is a number between 0 and 1.
[0086] The horizontal axis of the histogram is the grayscale level, and the vertical axis is the number of occurrences of each grayscale level. The higher the height of the histogram, the greater the frequency of occurrence of the grayscale level. If the grayscale level is too concentrated, it will be stretched in the subsequent mapping process, resulting in enhanced contrast of the noise block. Especially for those pure noise blocks, the grayscale distribution is relatively concentrated, and stretching will greatly increase the contrast, resulting in excessive noise.
[0087] In an embodiment of the present application, a limiting threshold is first determined based on the histogram of the global image, so as to better determine where the grayscale distribution of the target image is relatively concentrated within the global range. Then, the histogram height of each sub-image (local image) is limited based on the limiting threshold, so as to better balance the distribution of the histograms of each local image.
[0088] Specifically, in the embodiment of the present application, the height of the second histogram can be limited by cropping the part of the second histogram corresponding to each sub-image that exceeds the limit threshold, thereby limiting the grayscale range of the local image being pulled up, thereby limiting the contrast pull-up interval. Furthermore, the cropped part can be added to the part that does not exceed the limit threshold, such as Figure 2 As shown, the clipped part can be filled into other parts of the histogram.
[0089] Step 140: Map each grayscale level in each sub-image to a target grayscale level based on the third histogram to obtain a defogged target image.
[0090] In an embodiment of the present application, after obtaining the third histogram corresponding to each sub-image, for each sub-image, each gray level in the third histogram can be mapped to a new gray level. After the mapping of each gray level of the sub-image is completed, all the mapped pixel values can be written into the new sub-image, thereby obtaining the defogged sub-image. All sub-images are traversed, and after the mapping of the third histogram corresponding to each sub-image is completed, the defogged sub-images are reassembled into a complete image, and the complete image is the target image after defogging. Specifically, it can be achieved by re-joining the sub-images according to the original cut order and position.
[0091] like Figure 3 and Figure 4 As shown, Figure 3is the target image before dehazing, Figure 4 The target image after being defogged by the image defogging method for a visible light television according to an embodiment of the present application can be seen. Figure 4 The visual effect is obviously better than Figure 3 of.
[0092] According to the image defogging method for a visible light television of the present application, a limiting threshold is determined based on a first histogram corresponding to a target image captured by the visible light television, so that the ratio of the area of the portion exceeding the limiting threshold in the first histogram to the total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each grayscale level; the target image is segmented to obtain a plurality of sub-images; the portion exceeding the limiting threshold in the second histogram corresponding to each sub-image is cropped and padded to the portion not exceeding the limiting threshold to obtain a third histogram corresponding to each sub-image; and each grayscale level in each sub-image is mapped to a target grayscale level based on the third histogram to obtain a defogged target image. The embodiment of the present application analyzes the histogram of the target image, finds the part of the target image with a relatively concentrated grayscale distribution according to the histogram, thereby determining a limiting threshold, and then segments the target image, processes each local image separately, limits the histogram height of the local image by limiting the threshold, and performs cropping and padding to balance the distribution of the histogram of each local image, thereby limiting the grayscale range of the local image being raised, limiting the contrast raising interval, reducing unnecessary noise enhancement in the process of image defogging, improving the image defogging effect, and thus improving the clarity and visibility of the image acquired by the visible light television.
[0093] In some embodiments, determining the limit threshold according to the first histogram corresponding to the target image captured by the visible light television so that the ratio of the area of the portion exceeding the limit threshold in the first histogram to the total area of the first histogram is a preset value includes:
[0094] Performing statistical analysis on pixels of a target image to obtain a first histogram of the target image;
[0095] The ratio of the area of the portion above each ordinate value in the first histogram to the total area of the first histogram is traversed until the ratio reaches a preset value, and the current ordinate value is used as the limiting threshold.
[0096] In this embodiment, if the target image is a grayscale image, each pixel in the image to be detected can be traversed, and the grayscale value 0-255 is set as one grayscale level according to every 5 values, or every 10 values, every 15 values, or any other grayscale value range as one grayscale level, and the number of pixels at each grayscale level is counted, and the grayscale level and the corresponding number are plotted into a histogram. The horizontal axis represents the grayscale level, and the vertical axis represents the corresponding number. Of course, the number of pixels of each grayscale value can also be directly counted, and the grayscale value and the corresponding number are plotted into a histogram. At this time, the obtained histogram represents the number of pixels of each grayscale value in the target image.
[0097] If the target image is a color image, you can first convert the color image into a grayscale image, then traverse each pixel in the grayscale image, count the number of pixels at each grayscale level, and plot the grayscale levels and corresponding numbers into a histogram.
[0098] In some embodiments, image processing software (such as OpenCV, Matplotlib library in Python) can be used to calculate and plot the histogram of the image.
[0099] After obtaining the first histogram, determine the limiting threshold value according to the first histogram. Specifically, the total area of the histogram can be calculated first. For a discrete histogram, this can be obtained by adding the area of each column (usually the height of the column multiplied by the width of the column, if the column width is fixed). For a continuous histogram, the area can be calculated by integration, or approximated using a numerical integration method (such as the trapezoidal rule). Then, starting from the lowest or highest point of the first histogram, traverse the area of the part of the first histogram above different ordinate values until the ratio reaches a preset value, stop traversing, and use the current ordinate value as the limiting threshold value.
[0100] This embodiment obtains a histogram by analyzing the pixels of the global image, and then based on the distribution of the histogram, finds the part of the target image where the grayscale distribution is relatively concentrated by the area of the histogram, thereby determining a limiting threshold to facilitate subsequent balancing of the distribution of the histograms of each local image.
[0101] In some embodiments, the preset value is 20%-35%.
[0102] In this embodiment, if the limiting threshold is too high, the distribution balance of the histogram of each local image will be poor, and it will be difficult to achieve the effect of limiting the contrast increase interval. If the limiting threshold is too low, the distribution of the histogram of each local image will be over-balanced, making the contrast too low. Setting the limiting threshold to 20%-35% can achieve the distribution balance of the histogram of each local image without making the contrast too low, thereby improving the dehazing effect of the image.
[0103] In some embodiments, the segmenting of the target image to obtain a plurality of sub-images includes:
[0104] Dividing a portion of a preset range of a central area of the target image into a plurality of sub-images of a first size;
[0105] The portion outside the preset range of the central area of the target image is divided into a plurality of sub-images of a second size; wherein the first size is smaller than the second size.
[0106] Considering that the human eye tends to naturally focus on the central area of an image when observing it, and in some cases, the center of the image may contain the main or most important information. For example, in portrait photography, the face of the person is usually located in the center of the image. In this case, more accurate dehazing of the central area can ensure the clarity and visibility of important content.
[0107] Based on this, in this embodiment, the part within the preset range of the central area of the target image can be divided into smaller sub-images, so as to more finely defog the image in the central part to improve the image defogging effect. Further, the part outside the preset range of the central area of the target image is divided into larger sub-images, which can reduce the number of sub-images, thereby reducing the amount of calculation, so as to improve the efficiency of image defogging.
[0108] In this embodiment, since the center of the image may contain the main or most important information, the image within the center range of the image is divided into images of smaller sizes, so that the granularity of the image enhancement within the center range is finer, so as to improve the defogging effect of the image within the center range, and the image outside the center range is divided into images of larger sizes, which is beneficial to improve the efficiency of image defogging.
[0109] In some embodiments, the step of clipping the portion of the second histogram corresponding to each sub-image that exceeds the limit threshold and then padding it to the portion that does not exceed the limit threshold to obtain the third histogram corresponding to each sub-image includes:
[0110] Cutting the part exceeding the limit threshold in the second histogram corresponding to each sub-image;
[0111] The cropped parts are evenly filled into the parts of the second histogram that do not exceed the limit threshold according to the grayscale level, so as to obtain the third histogram corresponding to each sub-image.
[0112] In this embodiment, after the second histogram is cropped, the cropped portion can be evenly filled into the portion of the second histogram that does not exceed the limit threshold according to the gray level, that is, the amount filled for each gray level is approximately the same.
[0113] In this embodiment, by cropping the histogram of each sub-image based on a limiting threshold, the grayscale range of each sub-image can be limited, the contrast increase interval can be limited, and unnecessary noise enhancement in the image dehazing process can be reduced. The cropped part is evenly filled according to the grayscale level to the part that does not exceed the limiting threshold, which can further balance the distribution of the histogram of each local image, thereby improving the image dehazing effect.
[0114] In some embodiments, mapping each grayscale level in each sub-image to a target grayscale level based on the third histogram to obtain a defogged target image includes:
[0115] Normalizing the third histogram to obtain a normalized histogram corresponding to each sub-image; the normalized histogram represents the probability of occurrence of each gray level;
[0116] Obtaining a cumulative histogram representing the cumulative probability of each gray level based on the probability of each gray level appearing in the normalized histogram;
[0117] Performing linear mapping on each gray level of the cumulative histogram based on the cumulative probability to obtain a target gray level corresponding to each gray level;
[0118] The target grayscale level is used to replace each grayscale level in each sub-image to obtain a defogged target image.
[0119] In this embodiment, the purpose of normalizing the third histogram is to convert the number of pixels at each gray level into a probability distribution, which can better reflect the distribution of different gray levels in the image and facilitate subsequent processing steps.
[0120] The number of pixels at each gray level can be divided by the total number of pixels to obtain the probability distribution of each gray level, so that the normalized histogram value range becomes [0, 1]. Specifically, it can be calculated according to the formula:
[0121] Normalization of each gray level = (histogram gray level range) / number of pixels * number of pixels at each gray level
[0122] Calculate the normalized histogram.
[0123] The cumulative histogram refers to the cumulative probability value of each gray level in the histogram, which represents the cumulative probability of each gray level. The steps for calculating the cumulative histogram are as follows: first, according to the normalized histogram, the probability distribution of each gray level is obtained; then, the cumulative sum of the probability distribution is calculated to obtain the cumulative probability of each gray level. For example, the gray levels of the adjusted normalized histogram include 0, 1, 2, 3, 4, 5, 6, and 7, and the corresponding probabilities are 0.18, 0.18, 0.12, 0.10, 0.12, 0.06, 0.06, and 0.16, respectively. In the calculated cumulative histogram, the cumulative probability corresponding to gray level 0 is 0.18, and the cumulative probability corresponding to gray level 1 is the cumulative probability corresponding to gray level 0 plus the probability corresponding to gray level 1, that is, 0.18 plus 0.18 equals 0.36, and the cumulative probability corresponding to gray level 2 is the cumulative probability corresponding to gray level 1 plus the probability corresponding to gray level 2, that is, 0.36 plus 0.12 equals 0.48, and so on, to calculate the cumulative probability of each gray level.
[0124] Then, linear mapping is performed on each gray level of the cumulative histogram according to the cumulative probability to obtain the target gray level corresponding to each gray level. Taking the above cumulative histogram as an example, in the above cumulative histogram, the cumulative probabilities corresponding to gray levels 0, 1, 2, 3, 4, 5, 6, and 7 are 0.18, 0.36, 0.48, 0.58, 0.70, 0.76, 0.82, and 0.98 respectively. Multiply the cumulative probability by the mapped grayscale number so that the obtained value is in the interval 0-255. For example, if the mapped grayscale number is 8, multiply the cumulative probability by the mapped grayscale number, round off to get the target grayscale level corresponding to each grayscale level is 1, 3, 4, 5, 6, 6, 7, 8, and then replace the target grayscale level with each grayscale level in the image to be detected to obtain the enhanced image, that is, the grayscale levels of the enhanced image are 1, 3, 4, 5, 6, 7, 8, and the corresponding probabilities are 0.18, 0.18, 0.12, 0.10, 0.12+0.06, 0.06, 0.16, respectively.
[0125] For another example, if the mapped grayscale number is 50, the cumulative probability is multiplied by the mapped grayscale number, and the target grayscale levels corresponding to each grayscale level are rounded off to 9, 18, 24, 29, 35, 38, 41, and 49. Then the target grayscale levels are used to replace the grayscale levels in the image to be detected to obtain the enhanced image, that is, the grayscale levels of the enhanced image are 1, 3, 4, 5, 6, 7, and 8, and the corresponding probabilities are 0.18, 0.18, 0.12, 0.10, 0.12+0.06, 0.06, and 0.16, respectively.
[0126] It can be seen that using different mapped grayscale levels can achieve different stretching effects on the original histogram, and can make values with similar probabilities be mapped to the same value. For example, in the above cumulative histogram, the grayscale levels are 5 and 6, and the corresponding target grayscale levels after mapping the values of the mapped grayscale level 8 are both 6; different mapped grayscale levels can be selected so that the grayscale value distribution after mapping has different degrees of uniformity. Of course, the mapped grayscale level can also be other values, but it is necessary to ensure that the cumulative probability is multiplied by the mapped grayscale level so that the obtained value is within the range of 0-255.
[0127] In this embodiment, the cumulative probability distribution of each gray level is calculated based on the adjusted normalized histogram, so that when the gray levels of the cumulative histogram are linearly mapped, values with similar probabilities can be mapped to the same value, thereby allowing each sub-image to evolve into an image with a more uniform grayscale distribution, making the image contrast stronger and the details in the image clearer.
[0128] The image defogging method for a visible light television provided in the embodiment of the present application can be performed by an image defogging device for a visible light television. In the embodiment of the present application, the image defogging device for a visible light television performing the image defogging method for a visible light television is used as an example to illustrate the image defogging device for a visible light television provided in the embodiment of the present application.
[0129] The embodiment of the present application also provides an image defogging device for a visible light television.
[0130] like Figure 5 As shown, the image defogging device of the visible light television includes:
[0131] A determination module 510 is used to determine a limit threshold according to a first histogram corresponding to a target image captured by a visible light television, so that the ratio of the area of the portion exceeding the limit threshold in the first histogram to the total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each gray level;
[0132] A segmentation module 520 is used to segment the target image to obtain multiple sub-images;
[0133] A cropping module 530 is used to crop the portion of the second histogram corresponding to each sub-image that exceeds the limit threshold and fill it to the portion that does not exceed the limit threshold, so as to obtain a third histogram corresponding to each sub-image;
[0134] The mapping module 540 is used to map each grayscale level in each sub-image to a target grayscale level based on the third histogram to obtain a defogged target image.
[0135] According to the image defogging device for a visible light television of the present application, a limiting threshold is determined based on a first histogram corresponding to a target image captured by the visible light television, so that the ratio of the area of the portion exceeding the limiting threshold in the first histogram to the total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each grayscale level; the target image is segmented to obtain a plurality of sub-images; the portion exceeding the limiting threshold in the second histogram corresponding to each sub-image is cropped and padded to the portion not exceeding the limiting threshold to obtain a third histogram corresponding to each sub-image; and each grayscale level in each sub-image is mapped to a target grayscale level based on the third histogram to obtain a defogged target image. The embodiment of the present application analyzes the histogram of the target image, finds the part of the target image with a relatively concentrated grayscale distribution according to the histogram, thereby determining a limiting threshold, and then segments the target image, processes each local image separately, limits the histogram height of the local image by limiting the threshold, and performs cropping and padding to balance the distribution of the histogram of each local image, thereby limiting the grayscale range of the local image being raised, limiting the contrast raising interval, reducing unnecessary noise enhancement in the process of image defogging, improving the image defogging effect, and thus improving the clarity and visibility of the image acquired by the visible light television.
[0136] In some embodiments, the determination module 510 is further configured to:
[0137] Performing statistical analysis on pixels of a target image to obtain a first histogram of the target image;
[0138] The ratio of the area of the portion above each ordinate value in the first histogram to the total area of the first histogram is traversed until the ratio reaches a preset value, and the current ordinate value is used as the limiting threshold.
[0139] In some embodiments, the segmentation module 520 is further configured to:
[0140] Dividing a portion of a preset range of a central area of the target image into a plurality of sub-images of a first size;
[0141] The portion outside the preset range of the central area of the target image is divided into a plurality of sub-images of a second size; wherein the first size is smaller than the second size.
[0142] In some embodiments, the cropping module 530 is further configured to:
[0143] Cutting the part exceeding the limit threshold in the second histogram corresponding to each sub-image;
[0144] The cropped parts are evenly filled into the parts of the second histogram that do not exceed the limit threshold according to the grayscale level, so as to obtain the third histogram corresponding to each sub-image.
[0145] In some embodiments, the mapping module 540 is further configured to:
[0146] Normalizing the third histogram to obtain a normalized histogram corresponding to each sub-image; the normalized histogram represents the probability of occurrence of each gray level;
[0147] Obtaining a cumulative histogram representing the cumulative probability of each gray level based on the probability of each gray level appearing in the normalized histogram;
[0148] Performing linear mapping on each gray level of the cumulative histogram based on the cumulative probability to obtain a target gray level corresponding to each gray level;
[0149] The target grayscale level is used to replace each grayscale level in each sub-image to obtain a defogged target image.
[0150] The image defogging device of the visible light television in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than the terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0151] The image defogging device for a visible light television in the embodiment of the present application may be a device having an operating system. The operating system may be a Microsoft (Windows) operating system, an Android (Android) operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0152] In some embodiments, Figure 6As shown, an embodiment of the present application also provides an electronic device 600, including a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601. When the program is executed by the processor 601, each process of the above-mentioned visible light television image defogging method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0153] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0154] An embodiment of the present application also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned visible light television image defogging method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0155] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0156] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned image defogging method for visible light television when executed by a processor.
[0157] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0158] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image defogging method embodiment based on visible light television, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0159] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0160] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0161] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0162] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0163] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0164] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. A method for defogging an image of a visible light television, characterized in that: include: Determining a limiting threshold value according to a first histogram corresponding to a target image captured by a visible light television, so that a ratio of an area of a portion of the first histogram exceeding the limiting threshold value to a total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each gray level; Segmenting the target image to obtain a plurality of sub-images; The portion of the second histogram corresponding to each sub-image that exceeds the limit threshold is cropped and filled to the portion that does not exceed the limit threshold, so as to obtain a third histogram corresponding to each sub-image; Based on the third histogram, each grayscale level in each sub-image is mapped to a target grayscale level to obtain a defogged target image.
2. The method according to claim 1, characterized in that The step of determining the limiting threshold according to the first histogram corresponding to the target image captured by the visible light television, so that the ratio of the area of the portion exceeding the limiting threshold in the first histogram to the total area of the first histogram is a preset value, includes: Performing statistical analysis on pixels of a target image to obtain a first histogram of the target image; The ratio of the area of the portion above each ordinate value in the first histogram to the total area of the first histogram is traversed until the ratio reaches a preset value, and the current ordinate value is used as the limiting threshold.
3. The method according to claim 1, characterized in that The preset value is 20%-35%.
4. The method according to claim 1, characterized in that: The target image is segmented to obtain a plurality of sub-images, including: Dividing a portion of a preset range of a central area of the target image into a plurality of sub-images of a first size; The portion outside the preset range of the central area of the target image is divided into a plurality of sub-images of a second size; wherein the first size is smaller than the second size.
5. The method according to claim 1, characterized in that The step of clipping the portion of the second histogram corresponding to each sub-image that exceeds the limit threshold and then filling it to the portion that does not exceed the limit threshold to obtain the third histogram corresponding to each sub-image includes: Cutting the part exceeding the limit threshold in the second histogram corresponding to each sub-image; The cropped parts are evenly filled into the parts of the second histogram that do not exceed the limit threshold according to the grayscale level, so as to obtain the third histogram corresponding to each sub-image.
6. The method according to claim 1, characterized in that Mapping each grayscale level in each sub-image to a target grayscale level based on the third histogram to obtain a defogged target image includes: Normalizing the third histogram to obtain a normalized histogram corresponding to each sub-image; the normalized histogram represents the probability of occurrence of each gray level; Obtaining a cumulative histogram representing the cumulative probability of each gray level based on the probability of each gray level appearing in the normalized histogram; Performing linear mapping on each gray level of the cumulative histogram based on the cumulative probability to obtain a target gray level corresponding to each gray level; The target grayscale level is used to replace each grayscale level in each sub-image to obtain a defogged target image.
7. An image defogging device for a visible light television, characterized in that: include: A determination module, configured to determine a limiting threshold value according to a first histogram corresponding to a target image captured by a visible light television, so that a ratio of an area of a portion of the first histogram exceeding the limiting threshold value to a total area of the first histogram is a preset value; wherein the histogram represents the number of pixels at each gray level; A segmentation module, used for segmenting the target image to obtain multiple sub-images; A cropping module, used for cropping the part of the second histogram corresponding to each sub-image that exceeds the limit threshold and then filling it to the part that does not exceed the limit threshold, so as to obtain a third histogram corresponding to each sub-image; A mapping module is used to map each gray level in each sub-image to a target gray level based on the third histogram to obtain a defogged target image.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Self-adaptive image enhancement method and device and electronic equipment
CN117745552A
