-
Notifications
You must be signed in to change notification settings - Fork 33
Add trivial FilterDecimate for fast downsampling without spatial awareness #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
mp2p_icp_filters/include/mp2p_icp_filters/FilterDecimate.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /* _ | ||
| _ __ ___ ___ | | __ _ | ||
| | '_ ` _ \ / _ \| |/ _` | Modular Optimization framework for | ||
| | | | | | | (_) | | (_| | Localization and mApping (MOLA) | ||
| |_| |_| |_|\___/|_|\__,_| https://github.com/MOLAorg/mola | ||
|
|
||
| A repertory of multi primitive-to-primitive (MP2P) ICP algorithms | ||
| and map building tools. mp2p_icp is part of MOLA. | ||
|
|
||
| Copyright (C) 2018-2026 Jose Luis Blanco, University of Almeria, | ||
| and individual contributors. | ||
| SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| /** | ||
| * @file FilterDecimate.h | ||
| * @brief Naive point cloud downsampling (every N-th point). | ||
| * @author Jose Luis Blanco Claraco | ||
| * @date Jan 12, 2026 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <mp2p_icp/metricmap.h> | ||
| #include <mp2p_icp_filters/FilterBase.h> | ||
|
|
||
| namespace mp2p_icp_filters | ||
| { | ||
| /** | ||
| * @brief Naive point cloud downsampling. | ||
| * | ||
| * This filter reduces the number of points by keeping only one out of every N | ||
| * points. It can be configured either with a fixed decimation factor or by | ||
| * providing a target maximum size (in which case the decimation factor is | ||
| * computed automatically). | ||
| * | ||
| * If the output layer exists, new points are accumulated on it: previous contents are not cleared. | ||
| * | ||
| * Note: This filter is non-deterministic regarding the spatial distribution | ||
| * of points, as it relies purely on the internal storage order. | ||
| * | ||
| * \ingroup mp2p_icp_filters_grp | ||
| */ | ||
| class FilterDecimate : public mp2p_icp_filters::FilterBase | ||
| { | ||
| DEFINE_MRPT_OBJECT(FilterDecimate, mp2p_icp_filters) | ||
| public: | ||
| FilterDecimate(); | ||
|
|
||
| // See docs in FilterBase | ||
| void filter(mp2p_icp::metric_map_t& inOut) const override; | ||
|
|
||
| struct Parameters | ||
| { | ||
| void load_from_yaml(const mrpt::containers::yaml& c); | ||
|
|
||
| /** Input layer name (must be a point cloud) */ | ||
| std::string input_layer = mp2p_icp::metric_map_t::PT_LAYER_RAW; | ||
|
|
||
| /** Output layer name */ | ||
| std::string output_layer; | ||
|
|
||
| /** Keep one out of every 'decimation' points. If > 0, this takes | ||
| * precedence over target_max_size. */ | ||
| uint32_t decimation = 0; | ||
|
|
||
| /** Target maximum number of points in the output cloud. | ||
| * Used only if decimation == 0. */ | ||
| uint64_t target_max_size = 0; | ||
| }; | ||
|
|
||
| /** Algorithm parameters */ | ||
| Parameters params; | ||
|
|
||
| protected: | ||
| void initialize_filter(const mrpt::containers::yaml& c) override; | ||
| }; | ||
|
|
||
| } // namespace mp2p_icp_filters |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.