It is a simple method to avoid the enhancement of the sky in the image defogging algorithm.

Source: Internet
Author: User

Among the classic anti-fog algorithms, such as he keming's dark channel de-fog, Tarel's median-based de-fog, and some other edge-preserving methods, there is a common problem: Due to poor processing of the sky part, the sky often has a large area of texture and block phenomenon. The main reason is that the sky is basically not in line with the pre-determined condition of dark channel defogging. Currently, I have found the following articles to solve this problem:

1. Improved Image defogging Algorithm Based on dark colors prior Author: Jiang Jianguo, Hou tianfeng, Qi meibin, Hefei University of Technology, 2011.

2. Single Image dehazing Algorithms Based on Sky region segmentation, 2013 Wang guangzhi Harbin Institute of Technology (this article seems to be available for download at school );

In the first article, a controllable parameter k is added to adjust the transmittance of each pixel:

 

 

When | I (x)-A | <K, the region may be the sky, and the transmittance (increased transmittance) is recalculated. | I (x)-A |> K, it is considered to be a region that conforms to the dark channel prior, and the transmittance remains unchanged.

If K is 0, it is equivalent to the original transmittance formula.

The above practice is more reasonable, because under normal circumstances, the value of a in the atmosphere should be very close to that in the sky, while those in the dark passage should be far away from the sky, about the effect of this algorithm, I wrote "Single Image haze removal using dark channel prior" about the principle, implementation, and effect of the image defogging algorithm (Real-time speed) the test program has been provided in the instance project in article.

The idea of the second article is to split the sky. After the split two parts are processed differently, the focus of this is the extraction of sky features. The author's original article is implemented through the following steps.

 

I made a rough comment on these steps.

The first step I think is the most valuable. It is not very easy to judge the sky directly from the raw data. The author observes that the sky is relatively smooth in general, that is, there is little change between adjacent pixels, therefore, it is easier to identify the image by using a gradient. The smaller the gradient value, the smoother the image.

In step 2, set a threshold value to preliminarily determine whether a certain part belongs to the sky. The author of this threshold value is 0.02, And the unsigned char range is basically 5.

Step 3: Expand the Initial Boundary in a small scale.

Step 4: calculate the average brightness of the original image in the corresponding position for each connected area of the split image. If the brightness is greater than the threshold value T, it is retained. t here, the author takes 0.81, the corresponding integer is about 205.

In step 5, take the largest connected area that meets the conditions in Step 4 as the sky area for recognition.

The sixth step is to prevent some missed Detection Points. Some pixels in the surrounding area of the sky are further identified, and those that meet the conditions are added to the sky area.

Step 7 is to add a number of cells that are completely contained in the sky that are not considered as the sky to the sky.

In my opinion, except step 1, step 2, and step 4 are necessary, others do not need to be handled in this way. In particular, the fifth step will cause missed detection in the sky. For example, if the source image of the following process is used, a small portion of the sky in the upper left corner will be completely lost. Another problem is that computing in the China Unicom region is time-consuming.

My approach is:

1. convert an image to a grayscale image. to retain more edge information, you can use a color reduction algorithm with the contrast or significance preserving function.

2. Calculate the gradient information of the gray image (in fact, it can be achieved by some common edge detection operators );

3. Perform proper denoising and filtering on the gradient information;

4. the gradient information is differentiated according to the set gradient threshold and brightness threshold;

5. Perform Gaussian feather processing on the differentiated graph (optional ).

The entire process is as follows:

Original grayscale image gradient information

Slightly de-noise preliminary sky recognition for feathers

For comparison, we are looking at the sky recognition effects of several images:

For those images that basically do not have a sky, the detection results are as follows:

The results are not affected.

After obtaining the sky area, the author of the original article unified the transmittance chart of the sky area into a fixed value. I think this is not good, but we should make appropriate corrections based on the specific value. In my operations above, the obtained "go to the sky" area is a mask image. A vertex does not necessarily belong to the sky or completely does not. Therefore, we can combine the values obtained from the dark channel with the values of alpha, as shown below:

Darkchannel [y] = (skypresrve * Sky [y] + darkchannel [y] * (255-sky [y])/255;

Among them, skypresrve is similar to the fixed transmittance value of the paper, which is specified by the user. In the above formula, if Sky [255], that is, completely belongs to the sky, the transmittance of the change point is a fixed value, if Sky [y] = 0, that is, it does not belong to the sky at all. The calculated value remains the same and does not affect normal defogging.

In addition, with regard to the calculation of atmospheric light value A, the paper puts forward that the average value of the pixels in the obtained sky is used as a, which is also very reasonable, but in actual processing, for some images with no sky at all, the detected area of the sky may be very small (obviously incorrect, but the program does not know). It is unreasonable to use this value as the atmospheric light. Therefore, my processing method first calculates the value calculated for the sky part, and then detects the proportion of the sky pixel to the entire image. If the proportion is less than 5%, it is still based on the Calculation Method of A by HE Kaiming.

Another step is mentioned in the paper, that is, the correction steps must be completed before the refine stage. Simply put, the correction steps must be performed before the guided filtering. In this way, the smoothing function of guided filtering can make up for the non-smooth phenomenon between the sky and non-sky boundaries to a certain extent );

In order to improve the speed, we can also use the method in the blog post on which I analyzed the paper to perform the subsample processing and then perform the subsample.

As a comparison, we will provide the comparison between the effects achieved by direct use and the results processed by the sky recognition method:

Result of the original image defogging in this article (skypresrve = 100)

It can be seen that when the sky is protected, the degree of defog in the place connecting to the sky is also relaxed.

At the end of the paper, the author also mentioned that the image for defogging is relatively dim. For this reason, I have done the following:

That is, in the HSV space, clahe is performed on the V component and then converted to the RGB space. This method does have obvious enhancement effects on some images, however, some images may increase noise. Therefore, we recommend that you handle them as needed.

The sample program will be provided later.

 

* *************************** Basically, I do not provide source code, however, I will try to use text to clearly describe the corresponding algorithm or provide the reference documentation ************************

* ************************************ Because it depends on your own the effort and the effect written in practice are exactly what they are, people must rely on their own *******************

* ************************** Laviewpbt time: 2014.8.12 contact QQ: 33184777 reprinted. Please keep the information of this bank **********************

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.