基于MATLAB的特定前景图像分离,将车辆识别并分离出来的三种方法。
本项目想要实现的是通过构建一个特定的框架,将特定的前景目标从图中分离出来。数据集是19张带有拖拉机的照片,下面是其中一张。
**
- 方法一:基于CIElab空间颜色K均值聚类的彩色图像分割。
**
CIELAB是CIE的颜色系统。基于CIE Lab的方法是基于这种颜色系统,基本上用于确定颜色的数值信息。Lab模式是CIE于1976年发布的一种颜色模式。它是CIE定义的一种颜色模式,理论上包括人眼可见的所有颜色。实验室模式弥补了RGB和CMYK的不足。实验室模式也由三个通道组成。第一个通道是亮度,即“L”。通道a是红色到深绿色;通道B是蓝色到黄色。从表现色范围来看,最全面的是lab模式,其次是RGB模式,最窄的是CMYK模式。也就是说,lab模式定义了大多数颜色,这些颜色独立于光和设备,并且处理速度与RGB模式一样快,比CMYK模式快几倍。CIELAB是一个统一的颜色空间。所谓一致性,是指当数值变化一致时,人的感官也会发生一致的变化。在Lab模型中,均匀变化对应于感知颜色的均匀变化。因此,在Lab中任意两种颜色的相对感知差可以通过将每种颜色视为三维空间中的一个点(包含三个分量:L*,a*,b*)并计算它们之间的欧氏距离来近似。Lab空间中的欧几里德距离是Δe(通常称为“delta e”,更准确地说是ΔeAB)。
具体步骤如下:
i. Read image file data;
ii. Transform color image from RGB to lab color space;
iii. Format conversion;
iv. Segmentation of image into n regions by K-mean clustering;
v. Take out a component and B component of lab space;
vi. Repeated clustering n times;
vii. Displays segmented regions.
结果还可以。
讨论一下该方法的优缺点
优点:不同颜色的识别度高,最终分离度高。
缺点:它会遗漏目标对象的某些部分。所以这会导致不完整的结果。
**
- 通过图像的RGB线性变换的像素操作分离背景。
**
我发现了一个灰色线性变换函数。这个MATLAB函数将灰度图像I中的强度值映射到J中的新值,使得1%的数据在I的低强度和高强度下饱和。对图像f中任意像素的灰度值x进行变换,得到图像f 中对应像素的灰度值XF。
具体的算法步骤如下:
i. Set adjustment linearity value;
ii. Read in the image to be processed and assign it to I;
iii. Assign image data to R. Change the original image into a monochrome image and keep the red color. Use the function imadjust to adjust the gray level of R, and the result returns R1;
iv. Assign image data to G. Change the original image into a monochrome image and keep the green color. Use the function imadjust to adjust the gray level of R, and the result returns G1;
v. Assign image data to B. Change the original image into a monochrome image and keep the blue color. Use the function imadjust to adjust the gray level of R, and the result returns B1;
vi. Get RGB image after transformation;
vii. Draw R, R1, G, G1, B, B1 images and observe the results of linear gray-scale transformation.
结果一般。
讨论一下该方法的优缺点:
优点:算法简单快速。它不需要很长时间,但可以直观地显示目标和背景。
缺点:分离的结果有很多背景。它可能需要进一步的优化和额外的算法。
**
- 基于阈值分割的数字图像前景分离。
**
阈值分割是一种简单有效的图像分割方法,适用于目标与背景对比度强的图像分割。所有灰度值大于或等于阈值的像素都被确定为属于对象,灰度值为255表示前景,否则这些像素将从对象区域中排除,灰度值为0表示背景。多阈值分割与单阈值分割没有本质区别,但分割技术不同。
具体的算法步骤如下:
i. Read the image directly, and do binary processing, make preliminary segmentation inspection according to the value of data cursor, or use imhist to draw the pixel distribution histogram of the image to determine the segmentation pixel value;
ii. If the direct threshold segmentation is not good, we can consider whether it is convenient to segment the image based on color by changing the color space;
iii. On the image with color space transformed, the approximate threshold value is directly selected by data cursor, and then improved manually;
iv. There are often holes in the segmented image. At this time, we need to use morphological methods (morphological processing: corrosion and expansion) to fill the holes;
v. Image splicing requires image size () to be the same size;
我们看到结果差强人意,仅仅去掉了部分背景。
这就是以上三种方法,有问题可以加QQ169195689进行交流。