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
0d7b1892
Commit
0d7b1892
authored
2 years ago
by
Maciej Wielgosz
Browse files
Options
Downloads
Patches
Plain Diff
extracting individual instances implemented
parent
7981d89b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nibio_postprocessing/get_instances_side_by_side.py
+39
-37
39 additions, 37 deletions
nibio_postprocessing/get_instances_side_by_side.py
with
39 additions
and
37 deletions
nibio_postprocessing/get_instances_side_by_side.py
+
39
−
37
View file @
0d7b1892
...
...
@@ -44,45 +44,45 @@ class GetInstancesSideBySide():
for
file
in
files
:
instance_points
,
header
,
point_format
=
self
.
process_single_file
(
file
)
# save files to separate files
for
instance_label
,
points
in
instance_points
.
items
():
# creat a new las file
new_header
=
laspy
.
LasHeader
(
point_format
=
point_format
.
id
,
version
=
header
.
version
)
las
=
laspy
.
LasData
(
new_header
)
# save files to separate files
for
instance_label
,
points
in
instance_points
.
items
():
# creat a new las file
new_header
=
laspy
.
LasHeader
(
point_format
=
point_format
.
id
,
version
=
header
.
version
)
las
=
laspy
.
LasData
(
new_header
)
# get box coordinates
min_x
=
np
.
min
(
points
[:,
0
])
max_x
=
np
.
max
(
points
[:,
0
])
min_y
=
np
.
min
(
points
[:,
1
])
max_y
=
np
.
max
(
points
[:,
1
])
min_z
=
np
.
min
(
points
[:,
2
])
max_z
=
np
.
max
(
points
[:,
2
])
# print box coordinates
print
(
"
Instance {} has box coordinates: ({}, {}, {}) - ({}, {}, {})
"
.
format
(
instance_label
,
min_x
,
min_y
,
min_z
,
max_x
,
max_y
,
max_z
))
# zero the coordinates
points
[:,
0
]
=
points
[:,
0
]
-
min_x
points
[:,
1
]
=
points
[:,
1
]
-
min_y
points
[:,
2
]
=
points
[:,
2
]
-
min_z
# get the new box coordinates
min_x
=
np
.
min
(
points
[:,
0
])
max_x
=
np
.
max
(
points
[:,
0
])
min_y
=
np
.
min
(
points
[:,
1
])
max_y
=
np
.
max
(
points
[:,
1
])
min_z
=
np
.
min
(
points
[:,
2
])
max_z
=
np
.
max
(
points
[:,
2
])
# print the new box coordinates
print
(
"
Instance {} has zeroed box coordinates: ({}, {}, {}) - ({}, {}, {})
"
.
format
(
instance_label
,
min_x
,
min_y
,
min_z
,
max_x
,
max_y
,
max_z
))
# get box coordinates
min_x
=
np
.
min
(
points
[:,
0
])
max_x
=
np
.
max
(
points
[:,
0
])
min_y
=
np
.
min
(
points
[:,
1
])
max_y
=
np
.
max
(
points
[:,
1
])
min_z
=
np
.
min
(
points
[:,
2
])
max_z
=
np
.
max
(
points
[:,
2
])
# print box coordinates
print
(
"
Instance {} has box coordinates: ({}, {}, {}) - ({}, {}, {})
"
.
format
(
instance_label
,
min_x
,
min_y
,
min_z
,
max_x
,
max_y
,
max_z
))
# zero the coordinates
points
[:,
0
]
=
points
[:,
0
]
-
min_x
points
[:,
1
]
=
points
[:,
1
]
-
min_y
points
[:,
2
]
=
points
[:,
2
]
-
min_z
# get the new box coordinates
min_x
=
np
.
min
(
points
[:,
0
])
max_x
=
np
.
max
(
points
[:,
0
])
min_y
=
np
.
min
(
points
[:,
1
])
max_y
=
np
.
max
(
points
[:,
1
])
min_z
=
np
.
min
(
points
[:,
2
])
max_z
=
np
.
max
(
points
[:,
2
])
# print the new box coordinates
print
(
"
Instance {} has zeroed box coordinates: ({}, {}, {}) - ({}, {}, {})
"
.
format
(
instance_label
,
min_x
,
min_y
,
min_z
,
max_x
,
max_y
,
max_z
))
# add the points to the las file
las
.
x
=
points
[:,
0
]
las
.
y
=
points
[:,
1
]
las
.
z
=
points
[:,
2
]
# write the las file to the output folder
las
.
write
(
os
.
path
.
join
(
self
.
output_folder
,
str
(
instance_label
)
+
'
.las
'
))
if
self
.
verbose
:
print
(
"
Saved instance {} to file
"
.
format
(
instance_label
))
# add the points to the las file
las
.
x
=
points
[:,
0
]
las
.
y
=
points
[:,
1
]
las
.
z
=
points
[:,
2
]
# write the las file to the output folder
las
.
write
(
os
.
path
.
join
(
self
.
output_folder
,
str
(
instance_label
)
+
'
.las
'
))
if
self
.
verbose
:
print
(
"
Saved instance {} to file
"
.
format
(
instance_label
))
# # get mean coordinates x, and y
# mean_x = np.mean(points[:, 0])
...
...
@@ -99,6 +99,8 @@ class GetInstancesSideBySide():
def
get_new_coordinates
(
self
,
points
):
pass
# save files to separate files
# for instance_label, points in instance_points.items():
# for instance_label, points in instance_points.items():
# # get box coordinates
# min_x = np.min(points[:, 0])
...
...
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