Opencv学习笔记 超像素分割
? ? ? ? 在計(jì)算機(jī)視覺領(lǐng)域,圖像分割(Segmentation)指的是將數(shù)字圖像細(xì)分為多個(gè)圖像子區(qū)域(像素的集合)(也被稱作超像素)的過(guò)程。超像素由一系列位置相鄰且顏色、亮度、紋理等特征相似的像素點(diǎn)組成的小區(qū)域。這些小區(qū)域大多保留了進(jìn)一步進(jìn)行圖像分割的有效信息,且一般不會(huì)破壞圖像中物體的邊界信息。 圖像分割的結(jié)果是圖像上子區(qū)域的集合(這些子區(qū)域的全體覆蓋了整個(gè)圖像),或是從圖像中提取的輪廓線的集合(例如邊緣檢測(cè))。一個(gè)子區(qū)域中的每個(gè)像素在某種特性的度量下或是由計(jì)算得出的特性都是相似的,例如顏色、亮度、紋理。鄰接區(qū)域在某種特性的度量下有很大的不同。
? ? ? ? 超像素分割有什么用處?超像素可以用來(lái)做跟蹤;可以做標(biāo)簽分類;視頻前景分割,因?yàn)橄啾认袼?#xff0c;超像素處理速度會(huì)快幾十倍、幾百倍甚至更高;超像素還可以用于骨架提取、人體姿態(tài)估計(jì)、醫(yī)學(xué)圖像分割等方面。
? ? ? ? Python參考代碼如下:
# import the necessary packages from skimage.segmentation import slic from skimage.segmentation import mark_boundaries from skimage.util import img_as_float from skimage import io import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt import 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 type image = img_as_float(io.imread("C:/Users/zyh/Desktop/QQ圖片20200922073254.png")) # loop over the number of segments for 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 plots plt.show() 原圖? ? ? ? OpenCv的超像素分割算法:opencv——superpixel算法——SLIC,SEEDS,LSC_莫談天下-CSDN博客_opencv slic?
總結(jié)
以上是生活随笔為你收集整理的Opencv学习笔记 超像素分割的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 随机种子的详解
- 下一篇: VGG16和VGG19网络结构图