Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4321a9bd authored by NADAL Morgane's avatar NADAL Morgane
Browse files

modif ImageVerification() -> no image constant + some changes in the dimension verif

parent cdcc8f12
No related branches found
No related tags found
No related merge requests found
File deleted
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment