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

Question about how to generate superpixels of raw images #4

Closed
GWwangshuo opened this issue Dec 3, 2019 · 5 comments
Closed

Question about how to generate superpixels of raw images #4

GWwangshuo opened this issue Dec 3, 2019 · 5 comments

Comments

@GWwangshuo
Copy link

GWwangshuo commented Dec 3, 2019

Hi, I am attempting to run your code on several datasets. However, I cannot figure out how to generate the superpixels files for these input images. I have carefully checked the preprocessing-scripts/selections.py and found the reseeds_cli.exe is needed.

I followed the instruction in https://github.com/davidstutz/seeds-revised to install reseeds_cli on Ubuntu, but it seems the arguments required are not the same with yours, e.g., there is no argument --index.

$ ../bin/reseeds_cli --help
Allowed options:
    --help                          produce help message
    --input arg                     the folder to process, may contain several 
                              images
    --bins arg (=5)                 number of bins used for color histograms
    --neighborhood arg (=1)         neighborhood size used for smoothing prior
    --confidence arg (=0.100000001) minimum confidence used for block update
    --iterations arg (=2)           iterations at each level
    --spatial-weight arg (=0.25)    spatial weight
    --superpixels arg (=400)        desired number of supüerpixels
    --verbose                       show additional information while processing
    --csv                           save segmentation as CSV file
    --contour                       save contour image of segmentation
    --labels                        save label image of segmentation
    --mean                          save mean colored image of segmentation
    --output arg (=output)          specify the output directory (default is 
                              ./output)

Could you please offer the executable file reseeds_cli.exe or give me some hints about how can I get access to this file? Thank a lot.

Moreover, why the generated superpixel files are all black in dataset/scannet-sample/raw/selections/superpixel? Thank again.

@nihalsid
Copy link
Owner

nihalsid commented Dec 3, 2019

Hey! Sorry for the confusion. Just saw that I have an index argument.
To enable it, add index as an option in program options in cli/main.cpp

desc.add_options()
...
        ("index", "save label indexes")
...

Enable index outputs with this code in cli/main.cpp

if (parameters.find("index") != parameters.end()) {
    boost::filesystem::path extension = inputPath.filename().extension();
    int position = inputPath.filename().string().find(extension.string());
    std::string store = outputPath.string();

    cv::Mat labelImage = Draw::indexImage(seeds.getLabels(), image);
    cv::imwrite(store, labelImage);

    if (verbose == true) {
        std::cout << "Image " << inputPath.string() << " with indexed labels saved to " << store << " ..." << std::endl;
    }
}

The generated superpixels look black because they are 16 bit indexed images, e.g. having values between 0-39 for 40 superpixels, therefore appearing black.

Let me know if it helps.

@GWwangshuo
Copy link
Author

Thanks for your reply. It dose help. But I still have some problems for generating superpixel files as follows:

  • In the origin seeds-revised, one of the options --csv, --contour, --labels or --mean is needed for generating different superpixel file. However, in your code, instead of using these options, you use the --output option to generate corresponding superpixel file for the input image.
  • In the origin seeds-revised, the --input option denotes the folder to process. But in your implementation, it is the input image. Also, for the --output option, yours is the output superpixel file while in original implementation, it represents the output directory.
  • What I concern most is that I cannot directly generate the same black superpixel file as yours. If I use one of these options --contour, --labels, --mean, I get colored superpixel files rather than black 16 bit indexed images.

Could you please tell me how can I handle these problems? I really appreciate your kind help.

@nihalsid
Copy link
Owner

nihalsid commented Dec 4, 2019

It seems like my main.cpp is quite different than the one on the master branch from seeds. Here's my version. Hopefully this helps.

main.txt

@GWwangshuo
Copy link
Author

It seems like my main.cpp is quite different than the one on the master branch from seeds. Here's my version. Hopefully this helps.

main.txt

Thank you for offering the main.cpp file. In this file, you define the --index option which is implemented by the function Draw::indexImage(seeds.getLabels(), image) in lib\Tools.cpp. Could you also please offer the implementation of this function since I cannot generate the black superpixel files as yours without this --index option. I am really appreciate!

@nihalsid
Copy link
Owner

nihalsid commented Dec 6, 2019

Hey, here's my lib/Tools.cpp file

Tools .txt

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