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)
| 67 | |
| 68 | |
| 69 | def 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 | |
| 89 | def get_foreground_label(image: MetaTensor, label: MetaTensor) -> MetaTensor: |
no test coverage detected
searching dependent graphs…