数字图像处理--算术、几何、谐波、逆谐波均值滤波器Matlab
本文链接:https://blog.csdn.net/Dooonald/article/details/78545461
算术均值
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
resultImage(x,y)=sum(is(:))/numel(is);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3算术均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
resultImage(x,y)=sum(is(:))/numel(is);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5算术均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
resultImage(x,y)=sum(is(:))/numel(is);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9算术均值');
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
几何均值
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
resultImage(x,y)=prod(prod(is(:)))^(1/numel(is));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3几何均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
%遍历每个点的四周
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
resultImage(x,y)=prod(prod(is(:)))^(1/numel(is));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5几何均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
%遍历每个点的四周
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
resultImage(x,y)=prod(prod(is(:)))^(1/numel(is));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9几何均值');
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
谐波均值
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
is=1./is;
resultImage(x,y)=numel(is)/sum(is(:));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3谐波均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
%遍历每个点的四周
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
is=1./is;
resultImage(x,y)=numel(is)/sum(is(:));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5谐波均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
%遍历每个点的四周
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
is=1./is;
resultImage(x,y)=numel(is)/sum(is(:));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9谐波均值');
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
逆谐波
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
Q1 = 1.5;
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
resultImage(x,y) = sum(is(:).^(Q1+1))/sum(is(:).^(Q1));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3逆谐波均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
%遍历每个点的四周
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
resultImage(x,y) = sum(is(:).^(Q1+1))/sum(is(:).^(Q1));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5逆谐波均值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
%遍历每个点的四周
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
resultImage(x,y) = sum(is(:).^(Q1+1))/sum(is(:).^(Q1));
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9逆谐波均值');
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
中值
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
temp = sort(is(:));
resultImage(x,y)= temp((numel(temp)-1)/2);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3中值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
%遍历每个点的四周
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
temp = sort(is(:));
resultImage(x,y)= temp((numel(temp)-1)/2);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5中值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
%遍历每个点的四周
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
temp = sort(is(:));
resultImage(x,y)= temp((numel(temp)-1)/2);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9中值');
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
最大值
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
temp = is(:);
resultImage(x,y)= max(temp);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3最大值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
%遍历每个点的四周
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
temp = is(:);
resultImage(x,y)= max(temp);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5最大值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
%遍历每个点的四周
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
temp = is(:);
resultImage(x,y)= max(temp);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9最大值');
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
最小值
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
temp = is(:);
resultImage(x,y)= min(temp);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3最小值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
%遍历每个点的四周
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
temp = is(:);
resultImage(x,y)= min(temp);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5最小值');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
%遍历每个点的四周
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
temp = is(:);
resultImage(x,y)= min(temp);
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9最小值');
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
中点
close all
clear all
f=imread('D:/testData/filtering.tif');
[w,h]=size(f);
image= f(:,:);
fsize1=3;
fsize2=5;
fsize3=9;
fssize1=(fsize1-1)/2;
fssize2=(fsize2-1)/2;
fssize3=(fsize3-1)/2;
figure();
subplot(1,2,1);
imshow(image);
xlabel('原图像');
resultImage = image;
for x=1+fssize1:1:w-fssize1
for y=1+fssize1:1:w-fssize1
is=f(x-fssize1:1:x+fssize1,y-fssize1:1:y+fssize1);
temp = is(:);
resultImage(x,y)= (max(temp) + min(temp))/2;
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('3*3中点');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize2:1:w-fssize2
for y=1+fssize2:1:w-fssize2
%遍历每个点的四周
is=f(x-fssize2:1:x+fssize2,y-fssize2:1:y+fssize2);
temp = is(:);
resultImage(x,y)= (max(temp) + min(temp))/2;
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('5*5中点');
resultImage= f(:,:);
figure();
subplot(1,2,1);
imshow(f);
xlabel('原图像');
for x=1+fssize3:1:w-fssize3
for y=1+fssize3:1:w-fssize3
%遍历每个点的四周
is=f(x-fssize3:1:x+fssize3,y-fssize3:1:y+fssize3);
temp = is(:);
resultImage(x,y)= (max(temp) + min(temp))/2;
end
end
subplot(1,2,2);
imshow(resultImage);
xlabel('9*9中点');
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
数字图像处理--算术、几何、谐波、逆谐波均值滤波器Matlab的更多相关文章
- Win8 Metro(C#)数字图像处理--2.70修正后的阿尔法滤波器
原文:Win8 Metro(C#)数字图像处理--2.70修正后的阿尔法滤波器 /// <summary> /// Alpha filter. /// </summary> / ...
- python数字图像处理(1):环境安装与配置
一提到数字图像处理编程,可能大多数人就会想到matlab,但matlab也有自身的缺点: 1.不开源,价格贵 2.软件容量大.一般3G以上,高版本甚至达5G以上. 3.只能做研究,不易转化成软件. 因 ...
- 初始----python数字图像处理--:环境安装与配置
一提到数字图像处理编程,可能大多数人就会想到matlab,但matlab也有自身的缺点: 1.不开源,价格贵 2.软件容量大.一般3G以上,高版本甚至达5G以上. 3.只能做研究,不易转化成软件. 因 ...
- c语言数字图像处理(八):噪声模型及均值滤波器
图像退化/复原过程模型 高斯噪声 PDF(概率密度函数) 生成高斯随机数序列 算法可参考<http://www.doc.ic.ac.uk/~wl/papers/07/csur07dt.pdf&g ...
- Win8 Metro(C#)数字图像处理--3.1图像均值计算
原文:Win8 Metro(C#)数字图像处理--3.1图像均值计算 /// <summary> /// Mean value computing. /// </summary> ...
- Win8 Metro(C#)数字图像处理--2.52图像K均值聚类
原文:Win8 Metro(C#)数字图像处理--2.52图像K均值聚类 [函数名称] 图像KMeans聚类 KMeansCluster(WriteableBitmap src,i ...
- Win8Metro(C#)数字图像处理--2.9图像均值滤波
原文:Win8Metro(C#)数字图像处理--2.9图像均值滤波 [函数名称] 图像均值滤波函数MeanFilterProcess(WriteableBitmap src) [函数代码] ...
- python数字图像处理(五) 图像的退化和复原
import cv2 import numpy as np import matplotlib.pyplot as plt import scipy import scipy.stats %matpl ...
- paper 108:系统学习数字图像处理之图像复原与重建
首先,必须注意这里所限制的处理条件. 关于图像退化/复原模型 退化的图像是由成像系统的退化加上额外的噪声形成的. 1.只考虑噪声引起的退化 噪声模型,包含于空间不相关和相关两种,除了空间周期噪声,这里 ...
随机推荐
- 【OF框架】使用IDbContextTransaction在框架中对多个实体进行事务操作
准备 引用框架,按照规范建立数据库表及对应实体. 一.事务操作 关键代码 示例代码如下: //插入数据,使用数据库事务,不支持多连接. var dbContext = IoCHelper.Resolv ...
- 【pytorch报错解决】expected input to have 3 channels, but got 1 channels instead
遇到的问题 数据是png图像的时候,如果用PIL读取图像,获得的是单通道的,不是多通道的.虽然使用opencv读取图片可以获得三通道图像数据,如下: def __getitem__(self, idx ...
- You are what you say!
说话的方式表现了你的角色,所以说话的口吻在不同场合要贴合自己的身份和角色 尖锐的问题:如果要说一个比较尖锐的问题,那么可以把这个问题推理一下,从比较生活化的一点开始,或者将问题推给虚拟的第三方(但是注 ...
- 【新品发布】智能驾驶实车测试系统-VDAS
智能驾驶技术的迭代研发,需要多种传感器.海量数据.海量场景的支撑.而目前多种传感器Gbit/s级别的数据同步采集.海量数据的快速分析和评估.关键场景的切片和提取,是业界公认的棘手问题. 为了解决上述的 ...
- JVM元空间深度解析
回顾一下上一次对于这次做的实验的一个背景说明: 这里将借助cglib这个库来完成动态类的创建,为啥要使用它?因为使用简单,二是在程序运行期可以动态的生成类,动态生成类之后生成类的元数据就会落入到元空间 ...
- JDBC终章- 使用 DBUtils实现增删查改- C3P0Utils数据源/QueryRunner runner连接数据源并执行sql
JDBC终章- 使用 DBUtils实现增删查改 1.数据库结构 Create Table CREATE TABLE `user` ( `id` ) NOT NULL AUTO_INCREMENT, ...
- 【NOI2019集训题2】 序列 后缀树+splay+dfs序
题目大意:给你一个长度为$n$的序列$a_i$,还有一个数字$m$,有$q$次询问 每次给出一个$d$和$k$,问你对所有的$a_i$都在模$m$意义下加了$d$后,第$k$小的后缀的起点编号. 数据 ...
- 前端知识体系:JavaScript基础-作用域和闭包-this的原理以及几种使用场景
一.问题由来: var obj = { foo: function () { console.log(this.bar) }, bar: 1 }; var foo = obj.foo; var bar ...
- MOS管做开关之初理解
杰杰 物联网IoT开发 2017-10-12 大家好,我是杰杰. 今晚,设计电路搞了一晚上,终于从模电渣渣的我,把MOS管理解了那么一丢丢,如有写的不好的地方,请指出来.谢谢. ...
- celery指定任务执行时间
有业务线提出需求:要求对于其流量,只能在0点到7点扫描. 对此,celery发送任务到队列时可以指定执行的时间. 当worker收到任务后,判断还未到执行时间,会存储在worker中,在到达时候后再执 ...