Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Istvan N. Huszar, MD
tirl
Commits
184d92d7
Commit
184d92d7
authored
Jul 20, 2020
by
inhuszar
Browse files
Added padding option.
parent
6c828b6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/tirl/scripts/mnd/histology_to_block.py
View file @
184d92d7
...
...
@@ -716,6 +716,28 @@ def mask_roi_defects(histo, block, p):
block
.
mask
=
bmask
*
binary
def
pad
(
timg
,
**
kwargs
):
""" Zero-pads the image by 1/5 of the image shape on both ends along each
spatial dimension. """
padding
=
[]
for
dim
in
timg
.
vshape
:
padding
.
append
((
dim
//
6
,
dim
//
6
))
padding
=
tuple
(
padding
)
offset
=
TxTranslation
([
-
pad
[
0
]
for
pad
in
padding
],
name
=
"padding"
)
lpad
=
((
0
,
0
),)
*
timg
.
tdim
if
timg
.
order
==
TENSOR_MAJOR
:
padding
=
lpad
+
padding
else
:
padding
=
padding
+
lpad
imdata
=
np
.
pad
(
timg
.
data
,
padding
,
mode
=
"maximum"
)
offset
=
offset
+
timg
.
domain
.
offset
chain
=
timg
.
domain
.
chain
padded
=
TImage
.
fromarray
(
imdata
,
tensor_axes
=
timg
.
taxes
)
padded
.
domain
.
offset
=
offset
padded
.
domain
.
chain
=
chain
return
padded
# PROGRAM FLOW CONTROL
def
histology_to_block
(
args
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment