chx_generic_functions.py 文件源码

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

项目:chxanalys 作者: yugangzhang 项目源码 文件源码
def create_wedge(  image, center, radius, wcors,  acute_angle=True) :
    '''YG develop at June 18, 2017, @CHX
        Create a wedge by a combination of circle and a triangle defined by center and wcors
        wcors: [ [x1,x2,x3...], [y1,y2,y3..]

    '''
    from skimage.draw import line_aa, line, polygon, circle
    imy, imx = image.shape   
    cy,cx = center
    x  = [cx] + list(wcors[0])
    y =  [cy] + list(wcors[1])

    maskc = np.zeros_like( image , dtype = bool) 
    rr, cc = circle( cy, cx, radius, shape = image.shape)
    maskc[rr,cc] =1  

    maskp = np.zeros_like( image , dtype = bool)
    x = np.array( x )  
    y = np.array( y ) 
    print(x,y)
    rr, cc = polygon( y,x)
    maskp[rr,cc] =1
    if acute_angle:
        return maskc*maskp
    else:
        return maskc*~maskp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号