P03 图像处理 traitement d’image
P03 图像处理 traitement d’image
Target
- 图像增强的不同操作 Les différentes opérations d’amélioration d’une image
- 分割操作(目标和原理)Les opérations de segmentation (objectif et principe)
- 边缘检测 Les opérations morphologiques (objectif et principe)
- 形态学操作(目标和原理)Détection de contour
- 霍夫变换 Transformée de Hough
图像和像素 [1]

图像由离散的像素点组成,每个像素点决定一个边长为最小分辨率的正方形的颜色,一般由一个整数表示。由三种不同类型的图像:
- 二值图像 Image binaire
- 灰度图像 Image en niveaux de gris
- 真彩(RGB)图像 Image en couleur réelle (RGB)
滤波 [1]
- 均值滤波器 filtre moyen
- 高斯滤波器 filtre gaussien
- 中值滤波器(非线性)filtre médian


中值滤波器相比于线性滤波器更优越,因为它能更好地保持边缘特征。由于中值是从像素邻域内的像素值中选择的,因此它对异常值更加鲁棒,不会生成新的不真实的像素值。这有助于防止边缘模糊和图像细节的丢失。
对比度 contraste [1]
对比度是画面黑与白的比值。Le contraste est le rapport entre le noir et le blanc dans une image.
在灰度图和RGB图像中中,使用0-255之间的值代表颜色强度。然而,对于一张图片,可能大量的颜色分布在如100-200之间的一小段区间内,这将导致对比度较低,图片颜色偏灰。如果我们将原本的100视为0,200视为255,颜色对比将更加明显。

锐化 Le renforcement d'image [1]
图像锐化用于增强图像中的细节。锐化滤波器通过从原始图像中减去其平滑版本来突出图像的边缘。平滑版本通常是通过对原始图像应用平均滤波器获得的。
Le renforcement d'image est utilisé pour améliorer les détails d'une image. Le filtre de renforcement met en évidence les contours de l'image en soustrayant la version lissée de l'image originale. La version lissée est généralement obtenue en appliquant un filtre de moyennage sur l'image originale.

分割 segmentation [2]
图像分割的基本目标是将图像划分为互斥的区域régions mutuellement exclusives,以便随后为这些区域附加有意义的标签 attribuer ensuite des étiquettes significatives à ces régions。分割出的对象通常称为前景foreground,而图像的其余部分为背景background。
不存在所谓的“正确”分割,图像的分割强烈依赖于我们感兴趣的对象或区域的类型。为了分割图像,可以利用图像的属性和特征。
- 基本强度阈值法 Basic intensity thresholding Méthode de seuil d'intensité de base:在灰度图像上效果较好fonctionne bien sur
- 颜色阈值法 Color thresholding Méthode de seuil de couleur:在RGB图像上效果较好
形态学技术 Morphological Operations [4]
形态学的应用包括:
- 分离图像中接触的对象
- 去除不需要的图像结构和噪声
- 根据对象的形状进行分类(等同于非线性滤波)
形态学主要应用于二值图像,使用两个关键的形态学操作:腐蚀erosion和膨胀dilation。
- 腐蚀:结构元素从前景中移除像素,减小对象的边缘,用于分离相邻的对象或去除噪声。Morphological erosion removes islands and small objects so that only substantive objects remain.
- 膨胀:结构元素向前景中添加像素,扩大对象的边缘,用于填补对象中的小孔或连接分离的对象。Morphological dilation makes objects more visible and fills in small holes in objects.


- A: 结构元素完全适配图像,表示腐蚀条件下前景对象被保存。
- B: 结构元素部分匹配图像,表示膨胀过程中前景对象被扩展。
- C: 结构元素既不适配也不匹配图像。
闭合和开启 closing and opening
- 闭合操作先进行膨胀,然后进行腐蚀。这种操作通常用于填充小的孔洞,连接相邻的物体或消除细小的裂缝。 Morphological opening is useful for removing small objects from an image while preserving the shape and size of larger objects in the image.
- 开启操作先进行腐蚀,然后进行膨胀。这种操作通常用于去除图像中的小型噪声或孤立的小物体,同时保持图像的大型结构完整。 Morphological closing is useful for filling small holes from an image while preserving the shape and size of the objects in the image.
边缘检测 Détection de contour [3]
边缘检测是一种用于在图像中查找物体边界的技术,通过检测亮度的不连续性来工作。The purpose of edge detection is to find the boundaries of objects within images by detecting discontinuities in brightness.
\[ \frac{\partial I}{\partial x} \approx I(x+1, y)-I(x, y), \quad \frac{\partial I}{\partial y} \approx I(x, y+1)-I(x, y) \]
使用差分计算梯度,从而获得边缘。In order to calculate edges, we need to first calculate the gradient of an image.The result can be used to calculate the gradient magnitude and the direction at each pixel :
\[ \begin{aligned}& G_{\mathrm{mag}}=\sqrt{\left(\frac{\partial A}{\partial x}\right)^2+\left(\frac{\partial A}{\partial y}\right)^2} \\& G_{\mathrm{dir}}=\operatorname{atan}\left(\frac{\partial A}{\partial y} / \frac{\partial A}{\partial x}\right) .\end{aligned} \]

Hough变换 Transformée de Hough [6]
霍夫变换的基本思想是将图像空间中的点映射到参数空间projeter les points de l'espace image dans l'espace des paramètres。在图像空间中,直线可以表示为 \(y=mx+b\)的形式,但这种表示方式在霍夫变换中并不方便。通常,我们使用极坐标方程 \(ρ=xcosθ+ysinθ\)来表示直线,其中:
- \(ρ\) 表示直线到坐标原点的垂直距离,
- \(θ\) 表示该垂线与水平轴的夹角。
主要步骤
- 边缘检测:通常先进行边缘检测(如 Canny 边缘检测)以确定图像中的边缘点。
- 转换到参数空间:将边缘点映射到参数空间,在参数空间中,直线对应于唯一的参数对 (ρ,θ)。
- 累加器:使用累加器记录在参数空间中每一对 (ρ,θ) 的投票值Un accumulateur enregistre les votes pour chaque couple。具有较高投票数的参数对代表图像空间中的可能直线。
- 峰值检测:在累加器中找到投票数较多的峰值,以确定图像中的直线。On recherche les pics dans l'accumulateur pour déterminer les droites présentes dans l'image.






