segmentation_functions.py
def createMask(levelDims, vertices, pattern):
    """
    Input: levelDims (nested list): dimensions of each layer of the slide.
           vertices (dict object as describe above)
    Output: (tuple) mask
            numpy nd array of 0/1, where 1 indicates inside the region
            and 0 is outside the region
    """
    # Down scale the XML region to create a low reso image mask, and then 
    # rescale the image to retain reso of image mask to save memory and time 
    Xratio, Yratio = calculateRatio(levelDims)

    nRows, nCols = levelDims[-1]
    mask = np.zeros((nRows, nCols), dtype=np.uint8)

    for i in range(len(vertices[pattern])):
        lowX = np.array(vertices[pattern][i]['X'])/Xratio
        lowY = np.array(vertices[pattern][i]['Y'])/Yratio
        rr, cc = polygon(lowX, lowY, (nRows, nCols))
        mask[rr, cc] = 1

    return mask

    Input: levelDims (nested list): dimensions of each layer of the slide.
           vertices (dict object as describe above)
    Output: (tuple) mask
            numpy nd array of 0/1, where 1 indicates inside the region
            and 0 is outside the region
    
levelDims (nested list): dimensions of each layer of the slide.
vertices (dict object as describe above)
Output: (tuple) mask
numpy nd array of 0/1, where 1 indicates inside the region
and 0 is outside the region
levelDims ( nested list ) : dimensions of each layer of the slide . vertices ( dict object as describe above ) Output : ( tuple ) mask numpy nd array of 0 / 1 where 1 indicates inside the region and 0 is outside the region
def createMask(levelDims, vertices, pattern):
    Xratio, Yratio = calculateRatio(levelDims)
    nRows, nCols = levelDims[-1]
    mask = np.zeros((nRows, nCols), dtype=np.uint8)
    for i in range(len(vertices[pattern])):
        lowX = np.array(vertices[pattern][i]['X'])/Xratio
        lowY = np.array(vertices[pattern][i]['Y'])/Yratio
        rr, cc = polygon(lowX, lowY, (nRows, nCols))
        mask[rr, cc] = 1
    return mask
def createMask ( levelDims , vertices , pattern ) : Xratio , Yratio = calculateRatio ( levelDims ) nRows , nCols = levelDims [ - 1 ] mask = np . zeros ( ( nRows , nCols ) , dtype = np . uint8 ) for i in range ( len ( vertices [ pattern ] ) ) : lowX = np . array ( vertices [ pattern ] [ i ] [ 'X' ] ) / Xratio lowY = np . array ( vertices [ pattern ] [ i ] [ 'Y' ] ) / Yratio rr , cc = polygon ( lowX , lowY , ( nRows , nCols ) ) mask [ rr , cc ] = 1 return mask
Input: levelDims (nested list): dimensions of each layer of the slide.
Input : levelDims ( nested list ) : dimensions of each layer of the slide .
"""
    Input: levelDims (nested list): dimensions of each layer of the slide.
           vertices (dict object as describe above)
    Output: (tuple) mask
            numpy nd array of 0/1, where 1 indicates inside the region
            and 0 is outside the region
    """ # Down scale the XML region to create a low reso image mask, and then  # rescale the image to retain reso of image mask to save memory and time 
levelDims
vertices
pattern