Color image--Image enhancement Image Smoothing

Source: Internet
Author: User

Study Dip 71st Day
Reprint please indicate the source of this article:Http://blog.csdn.net/tonyshengtan , out of respect for the work of the author, reprint please indicate the source! Article code is hosted, Welcome to co-development:Https://github.com/Tony-Tan/DIPpro

The opening crap.

Recently, the number of blogs has become more and more visits, although the purpose is not to how many visits, but look at the accumulation of knowledge a little, and some people agree that the mood is quite good.

Algorithm principle

To smooth the grayscale image of the article:
1, mean value, Gaussian smoothing
2. Bilateral filtering
3. Median filter

There are two kinds of algorithms used in color image, one is processing the RGB all components separately, then merging the processed components to get the color image. The other is the I component of HSI processing, the same can be smoothed, the color image smoothing here is just the simplest introduction, if you want to write a beautiful 美图秀秀, need to find a few papers to learn.

Code
/********************************************************************************************************** ***********/voidSmoothrgb (RGB *src,rgb *dst,intWidthintHeightintM_width,intM_height,DoublePARAM1,DoubleParam2,intSmooth_type) {Double*chanel_r= (Double*) malloc (sizeof (Double) *width*height);Double*chanel_g= (Double*) malloc (sizeof (Double) *width*height);Double*chanel_b= (Double*) malloc (sizeof (Double) *width*height);Double*chanel_r_dst= (Double*) malloc (sizeof (Double) *width*height);Double*chanel_g_dst= (Double*) malloc (sizeof (Double) *width*height);Double*chanel_b_dst= (Double*) malloc (sizeof (Double) *width*height); Split (SRC, chanel_r, Chanel_g, chanel_b, width, height);Switch(Smooth_type) { Casesmooth_gaussian:{Gaussianfilter (Chanel_r, chanel_r_dst, width, height, m_width, m_height, param1);            Gaussianfilter (Chanel_g, chanel_g_dst, width, height, m_width, m_height, param1); Gaussianfilter (Chanel_b, chanel_b_dst, width, height, m_width, m_height, param1); Break; } Casesmooth_median:{Medianfilter (Chanel_r, chanel_r_dst, width, height, m_width, m_height);            Medianfilter (Chanel_g, chanel_g_dst, width, height, m_width, m_height); Medianfilter (Chanel_b, chanel_b_dst, width, height, m_width, m_height); Break; } Casesmooth_bilateral:{Bilateralfilter (Chanel_r, chanel_r_dst, width, height, m_width, m_height, param1, param2);            Bilateralfilter (Chanel_g, chanel_g_dst, width, height, m_width, m_height, param1, param2); Bilateralfilter (Chanel_b, chanel_b_dst, width, height, m_width, m_height, param1, param2); Break; } Casesmooth_mean:{Meanfilter (Chanel_r, chanel_r_dst, width, height, m_width, m_height);            Meanfilter (Chanel_g, chanel_g_dst, width, height, m_width, m_height); Meanfilter (Chanel_b, chanel_b_dst, width, height, m_width, m_height); Break; }default: Break;    } Merge (Chanel_r_dst, CHANEL_G_DST, CHANEL_B_DST, DST, width, height);    Free (chanel_r);    Free (CHANEL_G);    Free (chanel_b);    Free (CHANEL_R_DST);    Free (CHANEL_G_DST); Free (CHANEL_B_DST);}/********************************************************************************************************** ***********/voidSMOOTHHSI (HSI *src,hsi *dst,intWidthintHeightintM_width,intM_height,DoublePARAM1,DoubleParam2,intSmooth_type) {Double*chanel_i= (Double*) malloc (sizeof (Double) *width*height);Double*chanel_i_dst= (Double*) malloc (sizeof (Double) *width*height); Split (SRC, null, NULL, chanel_i, width, height);Switch(Smooth_type) { Casesmooth_gaussian:{Gaussianfilter (chanel_i, chanel_i_dst, width, height, m_width, m_height, param1); Break; } Casesmooth_median:{Medianfilter (chanel_i, chanel_i_dst, width, height, m_width, m_height); Break; } Casesmooth_bilateral:{Bilateralfilter (chanel_i, chanel_i_dst, width, height, m_width, m_height, param1, param2); Break; } Casesmooth_mean:{Meanfilter (chanel_i, chanel_i_dst, width, height, m_width, m_height); Break; }default: Break; } for(intI=0; i<width*height;i++) {dst[i].c1=src[i].c1;        DST[I].C2=SRC[I].C2;    Dst[i].c3=chanel_i_dst[i];    } free (chanel_i); Free (CHANEL_I_DST);}/********************************************************************************************************** ***********/
Processing effect

Original:

RGB Tri-Channel 5x5 mean filter:

RGB three-channel 5x5 Gaussian filter:

RGB Tri-Channel 5x5 bilateral filtering:

RGB Tri-Channel 5x5 median filter:

HSI color space I-channel 5x5 mean filter:

HSI color space I-Channel 5x5 Gaussian filter:

HSI Color Space I channel 5x5 bilateral filtering:

HSI Color space I Channel 5x5 median filter:

Summarize

Because it is the algorithm from the grayscale image transplant, so the specific principle of no nonsense.
Cond..

Color image--Image enhancement Image Smoothing

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.