Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can l get the features vector associated to each superpixel ? #2

Closed
pinkfloyd06 opened this issue Sep 18, 2018 · 3 comments
Closed

Comments

@pinkfloyd06
Copy link

Hello,

Thank you a lot for your work.

I'm wondering your network learns also features vector of each superpixel or it just learn the superpixels.
If yes, how can l get them otherwise you keep just the raw pixels of each superpixels.

Thank you

@varunjampani
Copy link
Contributor

Our network first learns deep pixel features which are then used for computing distance between pixels and superpixels. We do iterative clustering using deep features. After each iteration of differentiable SLIC, we obtain superpixel centroid features. You can use the following function to convert deep pixel features into superpixel features:

spixel_feat = L.SpixelFeature2(pixel_features,
                                                    pixel_assoc,
                                                    spixel_init,
                                                    spixel_feature2_param =\
        dict(num_spixels_h = num_spixels_h, num_spixels_w = num_spixels_w))

Does this answer your question?

@pinkfloyd06
Copy link
Author

Hi @varunjampani ,

Thank you for your answer. Yes this is what l need. Can l also get the coordinates of each superpixel (gravity center) and the coordinates (index(x,y)) of each pixel ?

Thank you

@varunjampani
Copy link
Contributor

varunjampani commented Oct 5, 2018

You can compute 'XYRGB' pixel features using the following layer:

pixel_features = L.PixelFeature(img,
                                      pixel_feature_param = dict(type = P.PixelFeature.POSITION_AND_RGB,
                                                                 pos_scale = float(pos_scale),
color_scale = float(color_scale)))

And, then pass these pixels features onto 'SpixelFeature2' layer to compute XYRGB gravity center for superpixels:

spixel_feat = L.SpixelFeature2(pixel_features,
                                                    pixel_assoc,
                                                    spixel_init,
                                                    spixel_feature2_param =\
        dict(num_spixels_h = num_spixels_h, num_spixels_w = num_spixels_w))

And, you can convert pixel-superpixel associations into 'superpixel index' using the following function in 'create_net.py':

def compute_final_spixel_labels(pixel_spixel_assoc,
                                spixel_init,
                                num_spixels_h, num_spixels_w):

    # Compute new spixel indices
    rel_label = L.ArgMax(pixel_spixel_assoc, argmax_param = dict(axis = 1),
                         propagate_down = False)
    new_spix_indices = L.RelToAbsIndex(rel_label, spixel_init,
                                       rel_to_abs_index_param = dict(num_spixels_h = int(num_spixels_h),
                                                                     num_spixels_w = int(num_spixels_w)),
                                                                     propagate_down = [False, False])

    return new_spix_indices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants