Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
instance_segmentation_classic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maciej Wielgosz
instance_segmentation_classic
Commits
d722ffcc
Commit
d722ffcc
authored
1 year ago
by
Maciej Wielgosz
Browse files
Options
Downloads
Patches
Plain Diff
implemented low vegatation removal in folders
parent
df38aa13
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nibio_preprocessing/distance_filtering_dem_based_in_folder.py
+56
-0
56 additions, 0 deletions
...o_preprocessing/distance_filtering_dem_based_in_folder.py
with
56 additions
and
0 deletions
nibio_preprocessing/distance_filtering_dem_based_in_folder.py
0 → 100644
+
56
−
0
View file @
d722ffcc
import
argparse
import
os
from
glob
import
glob
from
tqdm
import
tqdm
from
joblib
import
Parallel
,
delayed
from
nibio_preprocessing.distance_filtering_dem_based
import
DistanceFilteringDemBased
# Import your existing class
def
process_file
(
las_file
,
DISTANCE
,
OUTPUT_FOLDER
,
VERBOSE
):
if
VERBOSE
:
print
(
f
"
Processing
{
las_file
}
...
"
)
# Determine the output file path
filename
=
os
.
path
.
basename
(
las_file
)
filename
=
filename
.
replace
(
'
.las
'
,
'
_filtered.las
'
)
output_las_file
=
os
.
path
.
join
(
OUTPUT_FOLDER
,
filename
)
# Run the distance filtering
distance_filtering
=
DistanceFilteringDemBased
(
distance
=
DISTANCE
,
input_las_file_path
=
las_file
,
output_las_file_path
=
output_las_file
,
verbose
=
VERBOSE
)
distance_filtering
.
run
()
if
VERBOSE
:
print
(
f
"
Filtered
{
las_file
}
and saved to
{
output_las_file
}
"
)
if
__name__
==
'
__main__
'
:
# Command-line argument parser
parser
=
argparse
.
ArgumentParser
(
description
=
'
Batch processing of distance filtering based on DEM
'
)
parser
.
add_argument
(
'
-d
'
,
'
--distance
'
,
help
=
'
Distance in meters e.g. 0.5
'
,
default
=
0.5
,
required
=
False
,
type
=
float
)
parser
.
add_argument
(
'
-i
'
,
'
--input_folder
'
,
help
=
'
Input folder containing LAS files
'
,
required
=
True
)
parser
.
add_argument
(
'
-o
'
,
'
--output_folder
'
,
help
=
'
Output folder to save filtered LAS files
'
,
required
=
True
)
parser
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
store_true
'
,
help
=
"
Print information about the process
"
)
args
=
vars
(
parser
.
parse_args
())
DISTANCE
=
args
[
'
distance
'
]
INPUT_FOLDER
=
args
[
'
input_folder
'
]
OUTPUT_FOLDER
=
args
[
'
output_folder
'
]
VERBOSE
=
args
[
'
verbose
'
]
# Make sure output folder exists
if
not
os
.
path
.
exists
(
OUTPUT_FOLDER
):
os
.
makedirs
(
OUTPUT_FOLDER
)
# List all LAS files in the input folder
las_files
=
glob
(
os
.
path
.
join
(
INPUT_FOLDER
,
'
*.las
'
))
# Run parallel processing using joblib
Parallel
(
n_jobs
=-
1
)(
delayed
(
process_file
)(
las_file
,
DISTANCE
,
OUTPUT_FOLDER
,
VERBOSE
)
for
las_file
in
tqdm
(
las_files
))
if
VERBOSE
:
print
(
"
Batch processing complete.
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment