1010 ImageEditor ,
1111 letterboxed ,
1212 resized ,
13- adjusted ,
1413 greyscaled ,
1514 compressed_to_jpeg ,
1615 compressed_to_png
@@ -87,53 +86,6 @@ def test_resize_interpolation_methods(self, sample_frame):
8786 result = ImageEditor .resize (sample_frame , target_size = target_size , interpolation = interpolation )
8887 assert result .shape [:2 ] == (50 , 40 )
8988
90- def test_adjust_brightness (self , sample_frame ):
91- """Test brightness adjustment."""
92- # Increase brightness
93- result = ImageEditor .adjust (sample_frame , brightness = 50 )
94- assert result .shape == sample_frame .shape
95- # Brightness should increase (but clipped at 255)
96- assert np .all (result >= sample_frame )
97-
98- # Decrease brightness - should clamp at 0, so all values <= original
99- result = ImageEditor .adjust (sample_frame , brightness = - 50 )
100- assert result .shape == sample_frame .shape
101- assert result .dtype == sample_frame .dtype
102- assert np .all (result <= sample_frame )
103- # Values should never go below 0
104- assert np .all (result >= 0 )
105-
106- def test_adjust_contrast (self , sample_frame ):
107- """Test contrast adjustment."""
108- # Increase contrast
109- result = ImageEditor .adjust (sample_frame , contrast = 1.5 )
110- assert result .shape == sample_frame .shape
111-
112- # Decrease contrast
113- result = ImageEditor .adjust (sample_frame , contrast = 0.5 )
114- assert result .shape == sample_frame .shape
115-
116- def test_adjust_saturation (self , sample_frame ):
117- """Test saturation adjustment."""
118- # Increase saturation
119- result = ImageEditor .adjust (sample_frame , saturation = 1.5 )
120- assert result .shape == sample_frame .shape
121-
122- # Decrease saturation (towards grayscale)
123- result = ImageEditor .adjust (sample_frame , saturation = 0.5 )
124- assert result .shape == sample_frame .shape
125-
126- # Zero saturation should be grayscale
127- result = ImageEditor .adjust (sample_frame , saturation = 0.0 )
128- # All channels should be equal for grayscale
129- assert np .allclose (result [:, :, 0 ], result [:, :, 1 ], atol = 1 )
130- assert np .allclose (result [:, :, 1 ], result [:, :, 2 ], atol = 1 )
131-
132- def test_adjust_combined (self , sample_frame ):
133- """Test combined brightness, contrast, and saturation adjustment."""
134- result = ImageEditor .adjust (sample_frame , brightness = 10 , contrast = 1.2 , saturation = 0.8 )
135- assert result .shape == sample_frame .shape
136-
13789 def test_greyscale_conversion (self , sample_frame ):
13890 """Test grayscale conversion."""
13991 result = ImageEditor .greyscale (sample_frame )
@@ -250,17 +202,6 @@ def test_resized_pipe_operator(self, sample_frame):
250202 assert result .shape [:2 ] == (50 , 40 )
251203 assert result .shape [2 ] == 3
252204
253- def test_adjusted_function_returns_pipeable (self ):
254- """Test that adjusted function returns PipeableFunction."""
255- result = adjusted (brightness = 10 , contrast = 1.2 )
256- assert isinstance (result , PipeableFunction )
257-
258- def test_adjusted_pipe_operator (self , sample_frame ):
259- """Test adjusted function with pipe operator."""
260- result = adjusted (brightness = 10 , contrast = 1.2 , saturation = 0.8 )(sample_frame )
261-
262- assert result .shape == sample_frame .shape
263-
264205 def test_greyscaled_function_returns_pipeable (self ):
265206 """Test that greyscaled function returns PipeableFunction."""
266207 result = greyscaled ()
@@ -329,9 +270,7 @@ def test_simple_pipeline(self, sample_frame):
329270 def test_complex_pipeline (self , sample_frame ):
330271 """Test complex pipeline with multiple operations."""
331272 # Create pipeline using function-to-function composition
332- pipe = (letterboxed (target_size = (150 , 150 )) |
333- adjusted (brightness = 10 , contrast = 1.1 , saturation = 0.9 ) |
334- resized (target_size = (75 , 75 )))
273+ pipe = (letterboxed (target_size = (150 , 150 )) | resized (target_size = (75 , 75 )))
335274 result = pipe (sample_frame )
336275
337276 assert result .shape [:2 ] == (75 , 75 )
@@ -344,19 +283,15 @@ def test_pipeline_with_compression(self, mock_imencode, sample_frame):
344283 mock_imencode .return_value = (True , mock_encoded )
345284
346285 # Create pipeline using function-to-function composition
347- pipe = (letterboxed (target_size = (100 , 100 )) |
348- adjusted (brightness = 5 ) |
349- compressed_to_jpeg (quality = 90 ))
286+ pipe = (letterboxed (target_size = (100 , 100 )) | compressed_to_jpeg (quality = 90 ))
350287 result = pipe (sample_frame )
351288
352289 assert np .array_equal (result , mock_encoded )
353290
354291 def test_pipeline_with_greyscale (self , sample_frame ):
355292 """Test pipeline with greyscale conversion."""
356293 # Create pipeline using function-to-function composition
357- pipe = (letterboxed (target_size = (100 , 100 )) |
358- greyscaled () |
359- adjusted (brightness = 10 , contrast = 1.2 ))
294+ pipe = (letterboxed (target_size = (100 , 100 )) | greyscaled ())
360295 result = pipe (sample_frame )
361296
362297 assert len (result .shape ) == 3 and result .shape [2 ] == 3
@@ -411,25 +346,4 @@ def test_invalid_target_sizes(self):
411346 ImageEditor .resize (frame , target_size = (0 , 100 ))
412347
413348 with pytest .raises ((ValueError , cv2 .error )):
414- ImageEditor .resize (frame , target_size = (- 10 , 100 ))
415-
416- def test_extreme_adjustment_values (self , sample_frame = None ):
417- """Test extreme adjustment values."""
418- if sample_frame is None :
419- sample_frame = np .random .randint (0 , 256 , (50 , 50 , 3 ), dtype = np .uint8 )
420-
421- # Extreme brightness
422- result = ImageEditor .adjust (sample_frame , brightness = 1000 )
423- assert result .shape == sample_frame .shape
424- assert np .all (result <= 255 ) # Should be clipped
425-
426- result = ImageEditor .adjust (sample_frame , brightness = - 1000 )
427- assert np .all (result >= 0 ) # Should be clipped
428-
429- # Extreme contrast
430- result = ImageEditor .adjust (sample_frame , contrast = 100 )
431- assert result .shape == sample_frame .shape
432-
433- # Zero contrast
434- result = ImageEditor .adjust (sample_frame , contrast = 0 )
435- assert result .shape == sample_frame .shape
349+ ImageEditor .resize (frame , target_size = (- 10 , 100 ))
0 commit comments