91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 10.28MB
    文件類型: .tar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-12-24
  • 語言: Python
  • 標(biāo)簽: 主動輪廓??

資源簡介

The *Morphological Snakes* are a family of related methods for image-guided evolution of curves and surfaces represented as a level-set of an embedding function. They have application in several computer vision areas, such as tracking and image segmentation.

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-

“““
morphsnakes
===========

This?is?a?Python?implementation?of?the?algorithms?introduced?in?the?paper

??Márquez-Neila?P.?Baumela?L.?álvarez?L.?“A?morphological?approach
??to?curvature-based?evolution?of?curves?and?surfaces“.?IEEE?Transactions
??on?Pattern?Analysis?and?Machine?Intelligence?(PAMI)?2013.

This?implementation?is?intended?to?be?as?brief?understandable?and?self-contained
as?possible.?It?does?not?include?any?enhancement?to?make?it?fast?or?efficient.

Any?practical?implementation?of?this?algorithm?should?work?only?over?the
neighbor?pixels?of?the?0.5-levelset?not?over?all?the?embedding?function
and?perhaps?should?feature?multi-threading?or?GPU?capabilities.

The?classes?MorphGAC?and?MorphACWE?provide?most?of?the?functionality?of?this
module.?They?implement?the?Morphological?Geodesic?Active?Contours?and?the
Morphological?Active?Contours?without?Edges?respectively.?See?the
aforementioned?paper?for?full?details.

See?test.py?for?examples?of?usage.
“““

__author__?=?“P.?Márquez?Neila?

from?itertools?import?cycle

import?numpy?as?np
from?scipy?import?ndimage
from?scipy.ndimage?import?binary_dilation?binary_erosion?\
????????????????????????gaussian_filter?gaussian_gradient_magnitude

class?fcycle(object):
????
????def?__init__(self?iterable):
????????“““Call?functions?from?the?iterable?each?time?it?is?called.“““
????????self.funcs?=?cycle(iterable)
????
????def?__call__(self?*args?**kwargs):
????????f?=?next(self.funcs)
????????return?f(*args?**kwargs)
????

#?SI?and?IS?operators?for?2D?and?3D.
_P2?=?[np.eye(3)?np.array([[010]]*3)?np.flipud(np.eye(3))?np.rot90([[010]]*3)]
_P3?=?[np.zeros((333))?for?i?in?range(9)]

_P3[0][::1]?=?1
_P3[1][:1:]?=?1
_P3[2][1::]?=?1
_P3[3][:[012][012]]?=?1
_P3[4][:[012][210]]?=?1
_P3[5][[012]:[012]]?=?1
_P3[6][[012]:[210]]?=?1
_P3[7][[012][012]:]?=?1
_P3[8][[012][210]:]?=?1

_aux?=?np.zeros((0))
def?SI(u):
????“““SI?operator.“““
????global?_aux
????if?np.ndim(u)?==?2:
????????P?=?_P2
????elif?np.ndim(u)?==?3:
????????P?=?_P3
????else:
????????raise?ValueError(“u?has?an?invalid?number?of?dimensions?(should?be?2?or?3)“)
????
????if?u.shape?!=?_aux.shape[1:]:
????????_aux?=?np.zeros((len(P))?+?u.shape)
????
????for?_aux_i?P_i?in?zip(_aux?P):
????????_aux_i[:]?=?binary_erosion(u?P_i)
????
????return?_aux.max(0)

def?IS(u):
????“““IS?operator.“““
????global?_aux
????if?np.ndim(u)?==?2:
????????P?=?_P2
????elif?np.ndim(u)?==?3:
????????P?=?_P3
????else:
????????raise?ValueError(“u?has?an?invalid?number?of?dimensions?(should?be?2?or?3)“)
????
????if?u.shape?!=?_aux.shape[1:]:
????????_aux?=?np.zeros((len(P))?+?u.shape)
????
????for?_aux_i?P_i?in?zip(_aux?P):
????????_aux_i[:]?=?binary_dilation(u?P_i)
????
????return?_aux.min(0)

#?SIoIS?operator.
SIoIS?=?lambda?u:?SI(IS(u))
ISoSI?=?lambda?u:?IS(SI(u))
curvop?=?fcycle([SIoIS?ISoSI])

#?Stopping?factors?(function?g(I)?in?the?paper).
def?gborders(img?a

評論

共有 條評論

相關(guān)資源