Some image enhancement algorithms that are thought by Photoshop High Contrast retention algorithm

Source: Internet
Author: User
Tags expression range

About the use of high contrast reservations, from Baidu copied a paragraph of text, I think the writing is very good:

High contrast retention is to retain the high contrast part of the image, and then really white, is to retain the image on the pixel and the surrounding contrast of the larger part of the other parts have become gray. Take a photo of a person to illustrate the contrast between the larger part of someone's eyes, mouth, and body contour. If you perform the contrast reservation, the information will remain (in stark contrast to the gray). Its main function is to strengthen the image of the High Contrast section. Also take the character photo as an example, generally in order to make the character skin beautiful, usually need to perform fuzzy, the implementation of fuzzy characters after the line is also blurred. Copy the two copies of the image before performing the Blur, one of which is ambiguous, the other performs high contrast retention, the high contrast retained layer is placed above the blur layer, and then the soft light blending mode is performed, so that the character's lines are clearer.

So the high contrast retention algorithm itself is how the implementation process, the simple expression is:

High Contrast retention = original image-Gaussian blur image + 127

The goal of adding 127 is to not allow too many pixels to lose information because they are not in a valid range and cause the image to be too dark.

The simple code is as follows:

unsigned char *pointer, *CLONEP;
unsigned char * Clone = (unsigned char *) malloc (Height * Stride);
memcpy (Clone, Scan0, Height * Stride);    copy a layer
Guassblur (Clone, Width, Height, Stride, Radius);      The    layer is Gaussian-fuzzy for
(Y = 0; Y < Height; y++)
{
    pointer = Scan0 + Y * Stride;
    CLONEP = Clone + Y * Stride;
    for (X = 0; X < Width; x + +)
    {
        Valueb = *pointer-*CLONEP + 127;    mixed
        *pointer = clamp (VALUEB);
        pointer++;
        clonep++
    }
}
Free (Clone);

Gaussian Blur is a low pass filter, after implementation, the image of the more flat place changes little, and the edge is blurred, if the original-Gaussian blur is to be enhanced edge value, high contrast in the PS of the English version of the corresponding Word is highpass, that is, Qualcomm, that is the meaning.

I'm not here to emphasize the function of high contrast retention, although the algorithm has a wide range of applications. I am here to enhance the image by using a process similar to the original-Gaussian blur.

Many images need to be enhanced, especially some medical images, due to the hardware or the shooting of the occasion is not ideal, the image is often the details are hidden, therefore, the details of the enhancement is particularly important, and the original image-Gaussian blur is exactly the details of the images of the information of an expression, therefore, If you add this detail on the basis of the fuzzy graph, the noise is reduced, and the edges and other details (both edge and noise are high frequency parts) can effectively enhance the image information.

So, if you get a picture in this way:

Enhanced image = Blur image + Amount * (original image-Gaussian blur image)

Among them, the degree of amount control enhancement, can play a certain enhancement function.

Original Amount = 3 Amount = 6

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.