pyGCO icon indicating copy to clipboard operation
pyGCO copied to clipboard

segmentation on rgb image

Open foreverzzx opened this issue 2 years ago • 1 comments

Thanks for your contribution. I wonder what is the input for unary_cost in function cut_grid_graph_simple while performing classfication on rgb image. I cannot understand the shape of unary_cost. Could you show me a example of segmentation on rgb image?

def cut_grid_graph_simple(unary_cost, pairwise_cost, n_iter=-1, connect=4, algorithm='expansion'):
    """
    Apply multi-label graphcuts to grid graph. This is a simplified version of
    cut_grid_graph, with all edge weights set to 1.
    Parameters
    ----------
    unary_cost: ndarray, int32, shape=(height, width, n_labels)
        Unary potentials
    pairwise_cost: ndarray, int32, shape=(n_labels, n_labels)
        Pairwise potentials for label compatibility
    connect: int, number of connected components - 4 or 8
    n_iter: int, (default=-1)
        Number of iterations.
        Set it to -1 will run the algorithm until convergence
    algorithm: string, `expansion` or `swap`, default=expansion
        Whether to perform alpha-expansion or alpha-beta-swaps.
    Note all the node indices start from 0.`

foreverzzx avatar Nov 06 '22 09:11 foreverzzx

Hi, you can have a look at my PhD project: https://github.com/Borda/pyImSegm it is using superpixels, but you ll get the point of how to build the unary terms for multiple features either raw RGB values or any other quazi features :otter:

Borda avatar Nov 07 '22 08:11 Borda