图像滤波处理:空间滤波器实现

该博客介绍了如何使用MATLAB实现多种空间滤波器,包括算数均值、几何均值、谐波均值、逆谐波均值(Q=1.5和-1.5)、中值、最大值、最小值和中点滤波。内容涵盖滤波器的代码实现和处理结果,适用于《数字图像处理》第三版的课后练习。
摘要由CSDN通过智能技术生成

课后作业,实现:均值、谐波均值、中值、中点等滤波器。对应《数字图像处理》第三版,5.1-5.9课后题。


代码基于Matlab实现。完整代码及处理结果见:GitHub

步骤

  1. 加载图像
  2. 向外拓展一个像素的大小
  3. 与滤波器做卷积操作
  4. 输出图像

5.1 算数均值滤波

代码实现

close all
clear all
image=imread('filtering.tif');

figure();
subplot(2,2,1);
imshow(image);
xlabel('Raw image');

image_mean_3 = arithmetic_mean_filter(image,3);
subplot(2,2,2);
imshow(image_mean_3)
xlabel('arithmetic mean filter/3');

image_mean_5 = arithmetic_mean_filter(image,5);
subplot(2,2,3);
imshow(image_mean_5)
xlabel('arithmetic mean filter/5');

image_mean_9 = arithmetic_mean_filter(image,9);
subplot(2,2,4);
imshow(image_mean_9)
xlabel('arithmetic mean/9');

%%
function [result_imag]= arithmetic_mean_filter(image,filter_size)
    Ex_image = extend_imag(image);
    result_imag = image;
    [M,N]=size(Ex_image);
    helf_size = (filter_size-1)/2;

    for x=1+helf_size:1:M-helf_size
        for y=1+helf_size:1:N-helf_size
            slid=Ex_image(x-helf_size:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值