util.py 文件源码

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

项目:camelyon17 作者: hyosari 项目源码 文件源码
def connected_component_image(otsu_image):

    """ 
        apply Connected Component Analysis to otsu_image 
        it is because of detect tissue 
        choose the label that has largest spces in the image

        otsu_image = input image that applied otsu thresholding

        max_label = maximum label of components
        cnt_label = the number of pix which in certin lebel 
        result_label = the label which indicate tissue 

        return tissue image 
    """

    image_labels = measure.label(otsu_image) 
    max_label = np.max(image_labels) 
    cnt_label = 0 
    result_label = 1

    for i in range(1,max_label):
        temp = (image_labels == i) 
        temp = temp.astype(float)
        cnt_nonzero = np.count_nonzero(temp) 
        if cnt_nonzero > cnt_label:
            cnt_label = cnt_nonzero
            result_label = i

    tissue_image = (image_labels == result_label)
    tissue_image = tissue_image.astype(float) 

    return tissue_image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号