@@ -92,6 +92,9 @@ def adjust_brightness(img: Tensor, brightness_factor: float) -> Tensor:
92
92
Returns:
93
93
Tensor: Brightness adjusted image.
94
94
"""
95
+ if brightness_factor < 0 :
96
+ raise ValueError ('brightness_factor ({}) is not non-negative.' .format (brightness_factor ))
97
+
95
98
if not _is_tensor_a_torch_image (img ):
96
99
raise TypeError ('tensor is not a torch image.' )
97
100
@@ -110,6 +113,9 @@ def adjust_contrast(img: Tensor, contrast_factor: float) -> Tensor:
110
113
Returns:
111
114
Tensor: Contrast adjusted image.
112
115
"""
116
+ if contrast_factor < 0 :
117
+ raise ValueError ('contrast_factor ({}) is not non-negative.' .format (contrast_factor ))
118
+
113
119
if not _is_tensor_a_torch_image (img ):
114
120
raise TypeError ('tensor is not a torch image.' )
115
121
@@ -143,7 +149,7 @@ def adjust_hue(img, hue_factor):
143
149
Returns:
144
150
Tensor: Hue adjusted image.
145
151
"""
146
- if not (- 0.5 <= hue_factor <= 0.5 ):
152
+ if not (- 0.5 <= hue_factor <= 0.5 ):
147
153
raise ValueError ('hue_factor ({}) is not in [-0.5, 0.5].' .format (hue_factor ))
148
154
149
155
if not _is_tensor_a_torch_image (img ):
@@ -171,13 +177,16 @@ def adjust_saturation(img: Tensor, saturation_factor: float) -> Tensor:
171
177
172
178
Args:
173
179
img (Tensor): Image to be adjusted.
174
- saturation_factor (float): How much to adjust the saturation. 0 will
175
- give a black and white image, 1 will give the original image while
176
- 2 will enhance the saturation by a factor of 2.
180
+ saturation_factor (float): How much to adjust the saturation. Can be any
181
+ non negative number. 0 gives a black and white image, 1 gives the
182
+ original image while 2 enhances the saturation by a factor of 2.
177
183
178
184
Returns:
179
185
Tensor: Saturation adjusted image.
180
186
"""
187
+ if saturation_factor < 0 :
188
+ raise ValueError ('saturation_factor ({}) is not non-negative.' .format (saturation_factor ))
189
+
181
190
if not _is_tensor_a_torch_image (img ):
182
191
raise TypeError ('tensor is not a torch image.' )
183
192
0 commit comments