900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Opencv学习笔记 超像素分割

Opencv学习笔记 超像素分割

时间:2021-01-27 05:23:49

相关推荐

Opencv学习笔记 超像素分割

在计算机视觉领域,图像分割(Segmentation)指的是将数字图像细分为多个图像子区域(像素的集合)(也被称作超像素)的过程。超像素由一系列位置相邻且颜色、亮度、纹理等特征相似的像素点组成的小区域。这些小区域大多保留了进一步进行图像分割的有效信息,且一般不会破坏图像中物体的边界信息。 图像分割的结果是图像上子区域的集合(这些子区域的全体覆盖了整个图像),或是从图像中提取的轮廓线的集合(例如边缘检测)。一个子区域中的每个像素在某种特性的度量下或是由计算得出的特性都是相似的,例如颜色、亮度、纹理。邻接区域在某种特性的度量下有很大的不同。

超像素分割有什么用处?超像素可以用来做跟踪;可以做标签分类;视频前景分割,因为相比像素,超像素处理速度会快几十倍、几百倍甚至更高;超像素还可以用于骨架提取、人体姿态估计、医学图像分割等方面。

Python参考代码如下:

# import the necessary packagesfrom skimage.segmentation import slicfrom skimage.segmentation import mark_boundariesfrom skimage.util import img_as_floatfrom skimage import ioimport matplotlibmatplotlib.use('TkAgg')import matplotlib.pyplot as pltimport argparse# construct the argument parser and parse the arguments# ap = argparse.ArgumentParser()# ap.add_argument("-i", "--image", required = True, help = "Path to the image")# args = vars(ap.parse_args())# load the image and convert it to a floating point data typeimage = img_as_float(io.imread("C:/Users/zyh/Desktop/QQ图片073254.png"))# loop over the number of segmentsfor numSegments in (100, 200, 300):# apply SLIC and extract (approximately) the supplied number# of segmentssegments = slic(image, n_segments = numSegments, sigma = 5)# show the output of SLICfig = plt.figure("Superpixels -- %d segments" % (numSegments))ax = fig.add_subplot(1, 1, 1)ax.imshow(mark_boundaries(image, segments))plt.axis("off")# show the plotsplt.show()

原图

OpenCv的超像素分割算法:opencv——superpixel算法——SLIC,SEEDS,LSC_莫谈天下-CSDN博客_opencv slic

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。