Abstract: 数字图像处理:第72天
Keywords: 拉普拉斯算子,Sobel算子,Robert算子
本文最初发表于csdn,于2018年2月17日迁移至此
彩色图像-图像增强 图像锐化
今天写的博客有点多,因为这里的理论只是在前面已经详细介绍过了,所以多写点,好有时间来学习模式分类和图像特征点部分,请大家多多指教。
#算法说明
彩色图像锐化用到的算法还是灰度图像中所用的算法,在彩色图像中的应用可以直接对RGB三通道分别锐化然后合并,也可以对HSI中的I分量进行锐化,然后再得到锐化图像。
具体算法知识:
1、拉普拉斯算子
2、Sobel算子
3、Robert算子
代码
废话不多说,直接上代码: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
68void SharpenRGB(RGB *src,RGB *dst,int width,int height,double c,int Sharpen_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 (Sharpen_type) {
case SHARPEN_LAPLACE:{
LaplaceSharpen(chanel_r, chanel_r_dst, width, height, c);
LaplaceSharpen(chanel_g, chanel_g_dst, width, height, c);
LaplaceSharpen(chanel_b, chanel_b_dst, width, height, c);
break;
}
case SHARPEN_SOBEL:{
SobelSharpen(chanel_r, chanel_r_dst, width, height, c);
SobelSharpen(chanel_g, chanel_g_dst, width, height, c);
SobelSharpen(chanel_b, chanel_b_dst, width, height, c);
break;
}
case SHARPEN_ROBERT:{
RobertSharpen(chanel_r, chanel_r_dst, width, height, c);
RobertSharpen(chanel_g, chanel_g_dst, width, height, c);
RobertSharpen(chanel_b, chanel_b_dst, width, height, c);
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 SharpenHSI(HSI *src,HSI *dst,int width,int height,double c,int Sharpen_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 (Sharpen_type) {
case SHARPEN_LAPLACE:{
LaplaceSharpen(chanel_i, chanel_i_dst, width, height, c);
break;
}
case SHARPEN_SOBEL:{
SobelSharpen(chanel_i, chanel_i_dst, width, height, c);
break;
}
case SHARPEN_ROBERT:{
RobertSharpen(chanel_i, chanel_i_dst, width, height, c);
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);
}
效果
原图:
RGB三通道Laplace:
RGB三通道Sobel:
RGB三通道Robert:
HSI中 I 通道Laplace:
HSI中 I 通道Sobel:
HSI中 I 通道Robert:
月球图像锐化:
RGB三通道Sobel锐化:
HSI I 通道图像锐化:
总结
彩色图像锐化如此,具体数学知识可以去查看以前的博文。
待续。。