Question about grid_subsampling code
See original GitHub issueThanks for your great work and nice code.
My question is about the code in grid_subsampling when computing the subsampled_class for the subsampled point. The code is:
The logic here is to find out the label with the most occurrence number. The label’s occurrence number is stored in an unordered_map, with different labels as different keys, and corresponding occurrence number as values.
The code is using max_element to do it, but does not pass the third comp param. So what the code actually does, is just to find the max key in the unordered_map. It’s not what we want.
I think we need to add the third param to max_element like this:
max_element(v.second.labels[i].begin(), v.second.labels[i].end(),
[](const pair<int, int>&a, const pair<int, int>&b){return a.second < b.second;})
My test code is as follows:
#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;
int main() {
unordered_map<int, int> map; // label -> occurrence number
map[5] = 2;
map[2] = 3;
auto r1 = max_element(map.begin(), map.end());
cout << r1->first << "->" << r1->second << endl; // output: 5->2, it's wrong!
auto r2 = max_element(map.begin(), map.end(),
[](const pair<int, int>&a, const pair<int, int>&b){return a.second < b.second;});
cout << r2->first << "->" << r2->second << endl; // output: 2->3, it's right
return 0;
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Grid Subsampling - HuguesTHOMAS/KPConv-PyTorch - GitHub
I have a slight different question regarding visualizing feature map. In your KPConv paper, you have visualized feature maps for different ...
Read more >Anyone know the code for GRID BASED SAMPLING
I read in a paper that grid based sampling is used for finding the patches in a an image based on color.Please share...
Read more >Subsamplings - an overview | ScienceDirect Topics
A quincunx subsampling divides the image grid into a coarse grid that keeps one point out of two and a detail grid of...
Read more >How to automate LiDAR point cloud sub-sampling with ... - ORBi
The ultimate guide to subsample 3D point clouds from scratch, with. Python. Two efficient methods are shown to import, process, structure as a...
Read more >How to automate LiDAR point cloud sub-sampling with Python
The grid subsampling strategy will be based on the division of the 3D space in regular cubic cells called voxels. For each cell...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for the info
I see, probably the pointXYZ part let me think it’s from PCL. Particularly, I encountered this piece of code in RandLA-Net (here: https://github.com/QingyongHu/RandLA-Net/tree/master/utils/cpp_wrappers)