1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| void SmoothRGB(RGB *src,RGB *dst,int width,int height,int m_width,int m_height,double param1,double param2,int Smooth_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) { case SMOOTH_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; } case SMOOTH_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; } case SMOOTH_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; } case SMOOTH_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); }
void SmoothHSI(HSI *src,HSI *dst,int width,int height,int m_width,int m_height,double param1,double param2,int Smooth_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) { case SMOOTH_GAUSSIAN:{ GaussianFilter(chanel_i, chanel_i_dst, width, height, m_width, m_height, param1); break; } case SMOOTH_MEDIAN:{ MedianFilter(chanel_i, chanel_i_dst, width, height, m_width, m_height); break; } case SMOOTH_BILATERAL:{ BilateralFilter(chanel_i, chanel_i_dst, width, height, m_width, m_height, param1, param2); break; } case SMOOTH_MEAN:{ MeanFilter(chanel_i, chanel_i_dst, width, height, m_width, m_height); break; } default: break; } for(int i=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); }
|