(image: SimpleITK.Image, name: str, is_label: bool = False)
| 27 | |
| 28 | |
| 29 | def save_image(image: SimpleITK.Image, name: str, is_label: bool = False): |
| 30 | |
| 31 | if is_label: |
| 32 | output_img = SimpleITK.LabelToRGB(image) |
| 33 | elif image.GetPixelID() in [SimpleITK.sitkUInt8, SimpleITK.sitkVectorUInt8]: |
| 34 | output_img = image |
| 35 | else: |
| 36 | stats = SimpleITK.StatisticsImageFilter() |
| 37 | stats.Execute(image) |
| 38 | |
| 39 | shift_scale = SimpleITK.ShiftScaleImageFilter() |
| 40 | shift_scale.SetOutputPixelType(SimpleITK.sitkUInt8) |
| 41 | shift_scale.SetShift(-stats.GetMinimum()) |
| 42 | shift_scale.SetScale(255.0 / (stats.GetMaximum() - stats.GetMinimum())) |
| 43 | |
| 44 | output_img = shift_scale.Execute(image) |
| 45 | |
| 46 | SimpleITK.WriteImage(output_img, Path("..") / "images" / f"{name}.png") |
| 47 | |
| 48 | |
| 49 | def run_example(module_name: str, func_name: str, args: list) -> dict: |
nothing calls this directly
no test coverage detected