05 image processing 图像处理

image processing 图像处理

摘要:

  1. 图像的处理有两种方式,时域(空间域)处理(比如卷积,降噪因子)和频域处理(傅里叶,低通Low pass高通High pass滤波)
  2. A common technique for increasing contrast in an image is histogram equalization . 增强图像对比度的一种常用技术是直方图均衡化
  3. Median filtering 中值滤波适合去除 椒盐噪声
  • Image restoration
    Degradation model must be known.
    The degradation is reversed using this known model.
  • Image enhancement
    Degradation model is not known.
    Goal is to (1) clean up noise or (2) make image visually more pleasing
  • Methods:
    Spatial filtering methods
    Frequency domain methods
  • Point operations
    Contrast stretching
    Histogram modification and histogram equalization
  • Spatial neighborhood operations
    Averaging filters
    Median filters (nonlinear)
    Unsharp masking

Image processing

Restoration & Enhancement 图像复原&图像增强

Both enhancement and restoration aim to improve the quality of degraded images operations on them. 增强和恢复的目的都是为了提高对退化图像的处理质量。

Restoration: the model of degradation known, and this information is used to undo its effect and obtain the undegraded image. Assumes degradation is reversible. 复原:已知退化模型,利用该信息抵消退化效果,得到未退化图像。假设退化是可逆的。
需要考虑图像质量下降的原因,然后去除干扰的因素,来复原
Enhancement: the model of degradation not known, and the improvements are done with the goal of obtaining a visually pleasing results or reducing noise for later processing. 增强:退化模型未知,改进的目的是获得视觉上令人满意的结果或减少后续处理的噪声。

Restoration 图像复原

Types of noise

The degradation can be systematic or random 降解可以是系统的,也可以是随机的
In case degradation is random, the noise can come from a known probability distribution: 如果退化是随机的,噪声可能来自一个已知的概率分布: Gaussian 高斯
Uniform 统一的
Salt and pepper noise 椒盐噪声

An application:

We knew what the degradation was: a sinusoidal noise added to the image. 如果我们知道质量下降的原因是一个正弦噪声 We could undo the effect of the noise by 我们可以通过以下方法消除噪音的影响:

  1. Identifying the frequency component, and 确定频率分量
  2. Filtering it out using frequency domain techniques. 使用频域技术过滤它
Another application: vignetting 衰减

可以给一个简单的输入(画面),先去分析固定灰度值的影响是什么,再用这个分析好的模型去恢复其他的模型。


23-25


Enhancement 图像增强(本科容易实现)

Goal: is to produce enhanced or cleaned up image for further processing and/or making the image more acceptable to human eye. 目标:产生增强或清除图像,以便进一步处理和/或使图像更易于人眼接受。

Typically, the model of noise or degradation is not known. 通常,噪声或退化的模型是未知的。

Image enhancement methods 图像增强的方法

  1. Point operations 点操作
    Contrast stretching 对比度拉伸
    Gray level transforms 灰度变换
    Histogram modifications 直方图修改
  2. Spatial filtering operations 空间滤波操作
    Averaging 平均
    Median filtering 中值滤波
    Unsharp masking Low pass, band pass, high pass filtering 低通,带通,高通滤波
    Zooming 缩放
  3. Pseudocoloring 伪彩色

Point operations 点操作

1. 分段线性变换

Each pixel’s gray value is modified independently of the values of its spatial neighbors. Input 𝑢: gray level ∈[0,𝐿−1] where 𝐿 is the number of gray levels. Output 𝑣: gray level ∈[0,𝐿−1], 𝑣=𝑓(𝑢) Sometimes referred to as zero-memory methods, because there is no need to remember surrounding pixel values. 与周围像素点无关 看每个像素点在哪个阈值里,大于就是白,小于就是黑

2. Contrast stretching 反色

用最高灰度级-当前灰度级


26 27 28!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


Gray scale reversal 灰度反转 𝑓(𝑢)=(𝐿−1)−𝑢 Example usage: displaying X-ray images which are normally negatives. Nonlinear contrast stretching 非线性对比拉伸
对数变换 拉伸暗的范围,压缩亮的范围


29


3. Point operations based on histogram 基于直方图的点操作

Definitions:
The relative frequency of occurrence of gray levels in an image is ℎ(𝑢).
If ℎ(𝑢) is normalized such that


30 ∫_0^𝐿▒〖ℎ(𝑢)𝑑𝑢="image area” 〗


then ℎ(𝑢) is called the histogram.

A common technique for increasing contrast in an image is histogram equalization (or histogram flattening). 增强图像对比度的一种常用技术是直方图均衡化(或直方图平坦化)。
The goal is to redistribute gray levels among pixels so that the resulting histogram is flat. 我们的目标是在像素之间重新分配灰度,这样得到的直方图就是平坦的。
The result of this redistribution is that the gray level range is expanded near the peak of the histogram (where most pixels are) and compressed near the tails. 这种重新分布的结果是,灰度范围在直方图的峰值附近(其中大多数像素都在)扩大,并在尾部附近压缩。
Since gray levels are stretched for most pixels, more detail is visible. 由于大多数像素的灰度会被拉伸,因此可以看到更多的细节。

直方图分布变成近似均匀分布,从而增强图像的对比度:将集中于一个频率区域的色彩扩大到所有频率内,使得图像中所有频率的都有,颜色就会更多彩,对比度就更高了

Histogram equalization 直方图均衡: Define a mapping E: P→ Q, where P is the set of gray levels for the input image, and Q is the new set of transformed gray levels. 定义一个映射E: P→Q,其中P为输入图像的灰度集合,Q为转换后的灰度新集合。
直方图均衡:使变换后的图像中各灰度级出现的几率相当, 变换后概率密度函数(pdf)为均匀分布
直方图规定化:使处理后的直方图具有规定的形状


31-32 概念


Magnification (zooming) 缩放

1. zooming in 放大

Method 1: Replication 复制 For doubling each dimension: Let 𝑓 be the resulting image and 𝐼 be the input image Each pixel in a scan line is repeated once

>𝑓(𝑖,2𝑗)=𝐼(𝑖,𝑗)
>𝑓(𝑖,2𝑗+1)=𝐼(𝑖,𝑗)

Each scan line is repeated once. 最近临放大


33


Method 2: Linear interpolation 差值放大
The intensities between two pixels are linearly interpolated in a row
Then each scan line is interpolated
相邻两个像素的平均值来填充中间的像素,边缘选用丢弃法等方法


34


2. zooming out 缩小

Method 1: Sampling 采样 Every other pixel is sampled from the rows and columns 隔一个像素取一个


35


Method 2: Averaging 取平均 2x2 windows are averaged and the result is assigned to the appropriate pixel in the smaller resulting image. 每2x2个取一个平均值


36


Other interpolation and sampling methods

filtering and sampling 滤波与采样

Gaussian filter one possibility
在信号采样前加一个滤波,以避免屏幕混叠。如果照片中有变化快/非常细的纹理,那么降采样的时候如果频率不够高就会有波纹。加入滤波就可以避免
Solution: filter the image (smooth using neighborhood operations), then subsample

Spatial (neighborhood) operations 空域滤波

Weighted combinations of pixels in small neighborhoods
Simplest enhancement operation is replacing a pixel value with the average of its neighbors. (4-neighbors, 8-neighbors or other neighborhoods)
Let 𝐼(𝑖,𝑗) be the original image and 𝑓(𝑖,𝑗) be the computed image.
使用空域模板进行的图像处理,被称为空域滤波。
模板本身被称为空域滤波器。
在待处理的图像中逐点地移动模板,滤波器在该点的响应通过事先定义的滤波器系数与滤波模板扫过区域的相应像素值的关系来计算
Masks and convolution 模板与卷积 In image processing, various convolution operations are often represented by masks with which the image is convolved. 在图像处理中,各种卷积操作通常用卷积图像的模板表示

This is accomplished by the following steps 这可以通过以下步骤来实现

  1. Place mask on pixel (𝑖,𝑗) for which result is to be computed
  2. Compute point wise multiplication of all pixels of the image and mask that overlap
  3. Sum up the products
  4. Replace pixel (𝑖,𝑗) value with the computed sum of products
  5. Slide mask over to the next pixel and repeat operation

Median filtering 中值滤波

适合去除 椒盐噪声(孤立的噪声)
黑白颜色的小点
Input pixel is replaced by the median value in a window. 𝑓(𝑖,𝑗)="Median”(𝐼(𝑖−𝑘,𝑗−𝑙),” for” (𝑘,𝑙)∈𝑊}


37


Properties:

  1. Nonlinear filter
  2. Useful for removing isolated pixels or lines (of course, we may not want to lose lines, in which case this would be considered bad).
  3. Preserves step edges (does not smooth them)
  4. Clips corners
  5. Performs well on binary noise (salt-and-pepper noise) but poorly on Gaussian noise.
  6. Computationally costly (needs sorting of values)
    Practical implementation: separable median filter: i.e., two 1D median filters in x and y directions.