开始使用免费开始使用

超像素分割

在本练习中,您将对同一张图像应用无监督分割,然后再将其传入人脸检测机器学习模型。

也就是说,您会把这张图像从 \(265 \times 191 = 50,615\) 个像素降维为 \(400\) 个区域。

Young woman
已预加载为 face_image

show_image() 函数也已为您预加载。

本练习是课程的一部分

Python 图像处理

查看课程

练习说明

  • segmentation 模块导入 slic() 函数。
  • color 模块导入 label2rgb() 函数。
  • 使用 slic() 获得包含 400 个区域的分割结果。
  • 使用 label2rgb() 将分割结果叠加到原始图像上进行对比。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import the slic function from segmentation module
from skimage.____ import ____

# Import the label2rgb function from color module
from skimage.____ import ____

# Obtain the segmentation with 400 regions
segments = ____(____, ____= ____)

# Put segments on top of original image to compare
segmented_image = ____(____, ____, kind='avg')

# Show the segmented image
show_image(segmented_image, "Segmented image, 400 superpixels")
编辑并运行代码