Commit 184d92d7 authored by inhuszar's avatar inhuszar
Browse files

Added padding option.

parent 6c828b6d
......@@ -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):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment