MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / get_foreground_image

Function get_foreground_image

monai/auto3dseg/utils.py:69–86  ·  view source on GitHub ↗

Get a foreground image by removing all-zero rectangles on the edges of the image Note for the developer: update select_fn if the foreground is defined differently. Args: image: ndarray image to segment. Returns: ndarray of foreground image by removing all-zero edge

(image: MetaTensor)

Source from the content-addressed store, hash-verified

67
68
69def get_foreground_image(image: MetaTensor) -> np.ndarray:
70 """
71 Get a foreground image by removing all-zero rectangles on the edges of the image
72 Note for the developer: update select_fn if the foreground is defined differently.
73
74 Args:
75 image: ndarray image to segment.
76
77 Returns:
78 ndarray of foreground image by removing all-zero edges.
79
80 Notes:
81 the size of the output is smaller than the input.
82 """
83
84 copper = CropForeground(select_fn=lambda x: x > 0, allow_smaller=True)
85 image_foreground = copper(image)
86 return cast(np.ndarray, image_foreground)
87
88
89def get_foreground_label(image: MetaTensor, label: MetaTensor) -> MetaTensor:

Callers 1

__call__Method · 0.90

Calls 1

CropForegroundClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…