plot.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:circletracking 作者: caspervdw 项目源码 文件源码
def annotate_ellipse(params, ax=None, crop_radius=1.2, **kwargs):
    """Annotates an ellipse on an image

    Parameters
    ----------
    params : tuple or dict
        either (yr, xr, yc, xc) tuple
        or dict with names ['yr', 'xr', 'yc', 'xc']
    """
    from matplotlib.patches import Ellipse
    ellipse_style = dict(ec='yellow', fill=False)
    ellipse_style.update(kwargs)

    if isinstance(params, tuple):
        yr, xr, yc, xc = params
    else:
        yr = params['yr']
        xr = params['xr']
        yc = params['yc']
        xc = params['xc']

    ax.add_artist(Ellipse(xy=(xc, yc), width=xr*2, height=yr*2,
                          **ellipse_style))

    # crop image around ellipse
    ax.set_xlim(xc - crop_radius * xr, xc + crop_radius * xr)
    ax.set_ylim(yc + crop_radius * yr, yc - crop_radius * yr)
    return ax
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号