数字图像处理之5.1 图像退化复原过程的模型

与图像增强相似, 图像复原的目的也是改善给定的图像.
但图像增强主要是一个主观的过程, 而图像复原是一个客观的过程.

在这里插入图片描述

  • 图像恢复: 根据g(x, y), 获取关于原图像的近似估计f'(x, y)

  • 恢复的方法: 如果我们所知道的退化函数H和噪声n的信息愈多, 我们就能尽可能准确地估计原始输入图像.

  • 如果退化函数H是线性、空间位移不变性系统

    • 空间域中的退化图像: g(x, y) = h(x, y)*f(x, y)+n(x, y)
    • 频率域中的表示: G(u, v) = H(u, v)F(u, v)+N(u, v)
图像复原的分类
  • 按照退化模型
    • 无约束: 仅将图像看做一个数字矩阵, 从数学角度处理
    • 有约束: 还考虑图像的物理约束
  • 按照是否需要用户干预
    • 自动式
    • 交互式
  • 按照处理所在的域
    • 空间域恢复
    • 频率域恢复
噪声模型

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

周期噪声

  • 周期噪声是在图像获取中从电力或机电干扰中产生的. 这是唯一的一种空间依赖型噪声.
均值滤波器

在这里插入图片描述

顺序统计滤波器

在这里插入图片描述

自适应滤波器

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

import cv2
import matplotlib.pyplot as plt
import math


def max_filter(image, ksize=3):
    """
    最大值滤波函数
    :param image: 输入要图像
    :param ksize: 模板尺寸
    :return: 滤波结果图像
    """
    border_width = int((ksize-1)/2)  # 边界填充宽度
    # 填充便捷操作
    border_filling = cv2.copyMakeBorder(image,
                                        border_width, border_width, border_width, border_width,
                                        cv2.BORDER_REPLICATE)
    max_image = image.copy()
    for i in range(border_width, border_filling.shape[0]-border_width):
        for j in range(border_width, border_filling.shape[1]-border_width):
            # 读取模板下像素的灰度值
            lists = []
            for s in range(i-border_width, i+border_width+1):
                for t in range(j-border_width, j+border_width+1):
                    lists.append(border_filling[s][t])
            # 选最大值作为输出图像模板中心像素的灰度值
            max_image[i-border_width][i-border_width] = max(lists)
    return max_image


def min_filter(image, ksize=3):
    """
    最小值滤波函数
    :param image:输入图像
    :param ksize:模板尺寸
    :return:滤波结果图像
    """
    border_width = int((ksize-1)/2)  # 边界填充宽度
    # 填充边界操作
    border_filling = cv2.copyMakeBorder(image,
                                        border_width, border_width, border_width, border_width,
                                        cv2.BORDER_REPLICATE)
    # 从[(ksize-1)/2, (ksize-1)/2]开始向右下角进行漫游重合,
    # 到[borderFilling.shape[0]-3, borderFilling.shape[1]-3]停止
    min_image = image.copy()
    for i in range(border_width, border_filling.shape[0]-border_width):
        for j in range(border_width, border_filling.shape[1]-border_width):
            # 读取模板下像素的灰度值
            lists = []
            for s in range(i-border_width, i+border_width+1):
                for t in range(j-border_width, j+border_width+1):
                    lists.append(border_filling[s][t])
            # 选最大值作为输出图像模板中心像素的灰度值
            min_image[i-border_width][j-border_width] = min(lists)
    return min_image


# 显示函数
def show_images(images):
    for i in range(len(images)):
        img = images[i]
        # 行,列,索引
        x = 2
        plt.subplot(x, math.ceil(len(images) / x), i + 1)
        plt.imshow(img, cmap="gray")
        title = "(" + str(i + 1) + ")"
        plt.title(title, fontsize=10)
        plt.xticks([])
        plt.yticks([])
    plt.show()


if __name__ == '__main__':
    image = cv2.imread("../pic/cat.jpg", 0)
    image = cv2.resize(image, (200, 200))
    maxFilter1 = max_filter(image, 3)
    maxFilter2 = max_filter(maxFilter1, 3)
    maxFilter3 = max_filter(maxFilter2, 3)
    minFilter1 = min_filter(image, 3)
    minFilter2 = min_filter(minFilter1, 3)
    minFilter3 = min_filter(minFilter2, 3)
    imgs = [image, maxFilter1, maxFilter2, maxFilter3, image, minFilter1, minFilter2, minFilter3]
    show_images(imgs)

  • 7
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

墨痕_777

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值