Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing doc-string for blend API #3363

Merged
merged 9 commits into from
Nov 19, 2021
17 changes: 15 additions & 2 deletions monai/visualize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,22 @@ def matshow3d(
def blend_images(
image: NdarrayOrTensor, label: NdarrayOrTensor, alpha: float = 0.5, cmap: str = "hsv", rescale_arrays: bool = True
):
"""Blend two images. Both should have the shape CHW[D].
"""
Blend a image and a label. Both should have the shape CHW[D].
The image may have C==1 or 3 channels (greyscale or RGB).
The label is expected to have C==1."""
The label is expected to have C==1.

Args:
image: the input image to blend with label data.
label: the input label to blend with image data.
alpha: when blending image and label, `alpha` is the weight for the image region mapping to `label != 0`,
and `1 - alpha` is the weight for the label region that `label != 0`, default to `0.5`.
cmap: specify colormap in the matplotlib, default to `hsv`, for more details, please refer to:
https://matplotlib.org/2.0.2/users/colormaps.html.
rescale_arrays: whether to rescale the array to [0, 1] first, default to `True`.

"""

if label.shape[0] != 1:
raise ValueError("Label should have 1 channel")
if image.shape[0] not in (1, 3):
Expand Down