diff --git a/brick/processing/frangi3-nt.so b/brick/processing/frangi3-nt.so deleted file mode 100644 index 20ab3515fab53429af8e75d7e96b091e37a1e4e4..0000000000000000000000000000000000000000 Binary files a/brick/processing/frangi3-nt.so and /dev/null differ diff --git a/brick/processing/input.py b/brick/processing/input.py index cbe0996d43593cff370cc2c43fe67c0e241958d1..2e3d3674621e204c38e5c627fe30f4521cb68e2a 100644 --- a/brick/processing/input.py +++ b/brick/processing/input.py @@ -37,29 +37,37 @@ from PIL.ExifTags import TAGS def ImageVerification(image: array_t, channel: str) -> array_t: - if image.ndim == 3: + # + # The image must not be constant + if image.max() == image.min(): + raise ValueError('The input image should not be constant.') + + # Verification of the dimension of the image and its coherence with the parameters (channel) + elif image.ndim == 3: print('Your image has only one color channel.') - if channel == 'RGB': - print('"RGB" channels are specified in the parameters. The image dimensions are not correct:', image.ndim, - ', instead of 4.') - sy_.exit(0) + if channel is not None: + raise ValueError('The image has only 3 dimensions. However, a value for the "channel" parameter is ' + 'specified. Give the channel the value None') elif image.ndim == 4: if channel == 'R' or channel == 'G' or channel == 'B': + # not changed into if --channel in 'RGB'-- because if channel='RG' => True. print('The image has multiple color channels. The channel', channel, 'is specified in the parameters.') - for idx, color in enumerate('RGB'): - if channel == color: - image = image[:, :, :, idx] + image = image[:, :, :, 'RGB'.find(channel)] + + # The obtained image must not be constant + if image.max() == image.min(): + raise ValueError('The input image should not be constant.') + return image - elif channel == 'RGB': - print('"RGB" channels are specified in the parameters. The program does not handle multiple channels for ' - 'now.') - sy_.exit(0) + + else: + raise ValueError('The image has multiple color channels. Error in the value of the parameter channel.') elif image.ndim != 4 and image.ndim != 3: - print('The image dimensions are not correct:', image.ndim, ', instead of 3 or 4.') - sy_.exit(0) + raise ValueError(f'The image dimensions are not correct: {image.ndim}, instead of 3 or 4.') + # if channel != 'RGB' and image.ndim == 4: