scikit-image库-- 主动轮廓模型(十六)

本文深入探讨了主动轮廓模型,一种将样条拟合到图像特征的图像分割技术。通过实例展示了如何使用该模型进行人脸分割及寻找最暗路径,解释了参数调整对模型的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

主动轮廓模型。

通过将snake拟合到图像特征来激活轮廓。 支持单通道和多通道2D图像。 snake可以是周期性的(用于分割)或具有固定和/或自由端。 输出snake与输入边界的长度相同。 由于点的数量不变,请确保初始snake具有足够的点来捕获最终轮廓的细节。

skimage.segmentation.active_contour(image, snake, alpha=0.01, beta=0.1, w_line=0, w_edge=1,
 gamma=0.01, bc='periodic', max_px_move=1.0, max_iterations=2500, convergence=0.1)
参数:

image:(N,M)或(N,M,3)ndarray 输入图像。

snake:(N,2)ndarray 初始snake坐标。对于周期性边界条件,不得复制端点。

alpha:float,可选,snake长度参数。值越高,蛇的收缩速度越快。
beta:浮动,可选, snake平滑形状参数。较高的值使蛇更平滑。

w_line:float,可选,控制对亮度的吸引力。使用负值吸引黑暗区域。
w_edge:float,可选,控制对边缘的吸引力。使用负值可以从边缘排斥snake。
gamma:float,可选,显式时间步进参数。

bc:{‘periodic’,‘free’,‘fixed’},可选,蠕虫的边界条件。 'periodic’连接snake的两端,'fixed’将端点固定到位,'free’允许端部自由移动。 ‘fixed’和’free’可以通过解析’fixed-free’,'free-fixed’来组合。解析“固定固定”或“免费”分别产生与“固定”和“免费”相同的行为。

Returns: snake,(N,2)ndarray,与输入参数相同的形状。


活动轮廓模型是一种将开放或闭合样条拟合到图像中的线或边的方法。 它的工作原理是最小化部分由图像定义的能量,部分由样条的形状:长度和平滑度。 最小化在形状能量中隐含地完成并且明确地在图像能量中完成。

在以下两个示例中,使用活动轮廓模型(1)通过将闭合曲线拟合到面的边缘来从图像的其余部分分割人的面部,以及(2)找到两个固定之间的最暗曲线。 在遵守平滑性考虑的同时提出要点。 通常,在分析之前平滑图像是个好主意,如以下示例中所做的那样。
我们围绕宇航员的脸部初始化一个圆圈,并使用默认边界条件bc ='periodic’来拟合闭合曲线。 默认参数w_line = 0,w_edge = 1将使曲线搜索到边缘,例如面的边界。

import numpy as np
import matplotlib.pyplot as plt
from skimage.color import rgb2gray
from skimage import data
from skimage.filters import gaussian
fro
使用GVF域和VFC域进行图片分割 % Vector field convolution (VFC) external force field example. % % See also AMT, EXAMPLE_PIG, AM_VFC, AM_VFK, AC_DISPLAY. % % Reference % [1] Bing Li and Scott T. Acton, "Active contour external force using % vector field convolution for image segmentation," Image Processing, % IEEE Trans. on, vol. 16, pp. 2096-2106, 2007. % [2] Bing Li and Scott T. Acton, "Automatic Active Model % Initialization via Poisson Inverse Gradient," Image Processing, % IEEE Trans. on, vol. 17, pp. 1406-1420, 2008. % % (c) Copyright Bing Li 2005 - 2009. clear all disp('======================================') disp('Vector field convolution (VFC) example') %% parameter settings disp('Initializing parameters ...') SAVE_AVI = 0; % set it to 1 if you want to save the process as .avi movie DISPLAY_STREAMLINE = 0; % set it to 1 if you want to plot streamlines, note that it takes a while mu = .2; GVF_ITER = 100; normalize = 1; alpha = .5; beta = 0; tau = .5; SNAKE_ITER = 5; SNAKE_ITER1 = 60; RES = .5; clr = {'b' 'b' 'r'}; %% Read images disp('Reading images ...') U = imread('im_U.bmp'); noisyU=imread('im_Unoisy.bmp'); figure(1) %% compare 3 different cases for cs = 1:3, %% compute external force fields switch cs, case 1, % traditional GVF with Gaussian filter disp('--------------------------------------------------') disp('Case 1: GVF snake with initial circle close to FOI') disp('Computing the external force field ...') h = fspecial('gaussian',[5 5],5); f = imfilter(double(noisyU),h); titl = 'GVF'; Fext = AM_GVF(f, mu, GVF_ITER, normalize); R = 20; case 2, % traditional GVF with Gaussian filter disp('--------------------------------------------------') disp('Case 2: GVF snake with initial circle far away from FOI') disp('Computing the external force field ...
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值