Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mu-map
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tamino Huxohl
mu-map
Commits
f9676c4d
Commit
f9676c4d
authored
2 years ago
by
Tamino Huxohl
Browse files
Options
Downloads
Patches
Plain Diff
update join image function to automatically generate separator images
parent
bb53e417
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
mu_map/vis/slices.py
+27
-9
27 additions, 9 deletions
mu_map/vis/slices.py
with
27 additions
and
9 deletions
mu_map/vis/slices.py
+
27
−
9
View file @
f9676c4d
from
typing
import
List
from
typing
import
List
,
Optional
import
numpy
as
np
from
mu_map.dataset.util
import
align_images
from
mu_map.file.dicom
import
load_dcm_img
from
mu_map.file.interfile
import
load_interfile_img
from
mu_map.file.util
import
load_img
def
join_images
(
images
:
List
[
np
.
ndarray
],
separator
:
np
.
ndarray
,
vertical
:
bool
=
False
)
->
List
[
np
.
ndarray
]:
images
:
List
[
np
.
ndarray
],
separator
:
Optional
[
np
.
ndarray
]
=
None
,
vertical
:
bool
=
False
,
)
->
np
.
ndarray
:
"""
Create a new image by joining all input images along a separator image.
If joining horizontally, their shape must be equal along their first axis.
If joining vertically, their shape must be equal along their second axis.
:param images: a list of images to join
:param separator: a separator image inserted between all images
:param vertical: join images vertically instead of horizontally
:return: a new image joined as described above
Parameters
----------
images: list of np.ndarray
a list of images to join
separator: np.ndarray, optional
a separator image inserted between all images - if None a default separator
with a width of 10 pixels is created
vertical: bool
join images vertically instead of horizontally
Returns
-------
np.ndarray
a new image joined as described above
"""
if
separator
is
None
:
shape
=
(
(
10
,
*
images
[
0
].
shape
[
1
:])
if
vertical
else
(
images
[
0
].
shape
[
0
],
10
,
*
images
[
0
].
shape
[
2
:])
)
separator
=
np
.
full
(
shape
,
239
,
np
.
uint8
)
res
=
[]
for
image
in
images
:
res
+=
[
image
,
separator
]
...
...
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