Repository: kornia/kornia

Issue:
bug in ycbcr_to_rgb function
### Describe the bug

https://github.com/kornia/kornia/blob/2c084f8dc108b3f0f3c8983ac3f25bf88638d01a/kornia/color/ycbcr.py#L70
#### now:
 return torch.stack([r, g, b], -3)
#### need to be:
 return torch.stack([r, g, b], -3).clamp(0,1)
#### because:
![image](https://user-images.githubusercontent.com/33345538/234479794-79174b56-4041-4e9c-96f3-d3117ce44104.png)



Discussion:
@fenneishi clamp or norm_min_max 0/1 ? @cceyda any thoughts here ?
yes, you need clamp the return of ycbcr_to_rgb function into [0,1].
Because you may get "cb=1,cr=0" as ithe input of this function.
This input(cb=1,cr=0) may from a sigmoid function which is  the last layer of a neural network
i see -- feel free to send a pull request with the fix and tests

Resolving patch:
diff --git a/kornia/color/ycbcr.py b/kornia/color/ycbcr.py
--- a/kornia/color/ycbcr.py
+++ b/kornia/color/ycbcr.py
@@ -98,7 +98,7 @@ def ycbcr_to_rgb(image: Tensor) -> Tensor:
     r: Tensor = y + 1.403 * cr_shifted
     g: Tensor = y - 0.714 * cr_shifted - 0.344 * cb_shifted
     b: Tensor = y + 1.773 * cb_shifted
-    return torch.stack([r, g, b], -3)
+    return torch.stack([r, g, b], -3).clamp(0, 1)
 
 
 class RgbToYcbcr(nn.Module):


Test patch:
diff --git a/test/color/test_ycbcr.py b/test/color/test_ycbcr.py
--- a/test/color/test_ycbcr.py
+++ b/test/color/test_ycbcr.py
@@ -185,25 +185,25 @@ def test_unit(self, device, dtype):
             [
                 [
                     [
-                        [1.3226931, 0.5639256, 0.14902398, 1.0217545, 0.2569923],
-                        [0.37973762, 0.64386904, 1.1992811, -0.603531, 0.4239992],
-                        [1.0080798, 1.3131194, -0.1370286, 0.60653293, 0.3505922],
-                        [-0.4573757, 0.6076593, 0.33508536, 0.27470887, 1.2284023],
-                        [0.52727354, -0.1673561, 0.05404532, 1.2725366, 0.5783674],
+                        [1.0000, 0.5639256, 0.14902398, 1.0000, 0.2569923],
+                        [0.37973762, 0.64386904, 1.0000, 0.0000, 0.4239992],
+                        [1.0000, 1.0000, 0.0000, 0.60653293, 0.3505922],
+                        [0.0000, 0.6076593, 0.33508536, 0.27470887, 1.0000],
+                        [0.52727354, 0.0000, 0.05404532, 1.0000, 0.5783674],
                     ],
                     [
-                        [0.736647, -0.01305042, 0.55139434, 0.44206098, 0.4548782],
-                        [-0.22063601, 0.98196536, 0.54739904, 0.33826917, 0.850068],
-                        [0.72412336, 0.6222996, 0.110618, 1.0039049, 0.614918],
+                        [0.736647, 0.0000, 0.55139434, 0.44206098, 0.4548782],
+                        [0.0000, 0.98196536, 0.54739904, 0.33826917, 0.850068],
+                        [0.72412336, 0.6222996, 0.110618, 1.0000, 0.614918],
                         [0.15862459, 0.0699634, 0.66296846, 0.4845066, 0.3705502],
-                        [1.0145653, 0.46070462, 0.5654058, 0.24897486, -0.11174999],
+                        [1.0000, 0.46070462, 0.5654058, 0.24897486, 0.0000],
                     ],
                     [
-                        [1.4161384, 0.88769174, 0.4394987, -0.31889397, -0.5671302],
-                        [0.77483994, 0.99839956, 1.6813064, 0.41622213, 1.3508832],
-                        [0.7488585, -0.04955059, 0.01748962, 0.9683316, 0.49795526],
-                        [0.9473541, 1.2473994, -0.3918787, 0.47037587, 1.2893858],
-                        [1.4082898, -0.21875012, 0.6804801, 0.9795798, 0.24646705],
+                        [1.0000, 0.88769174, 0.4394987, 0.0000, 0.0000],
+                        [0.77483994, 0.99839956, 1.0000, 0.41622213, 1.0000],
+                        [0.7488585, 0.0000, 0.01748962, 0.9683316, 0.49795526],
+                        [0.9473541, 1.0000, 0.0000, 0.47037587, 1.0000],
+                        [1.0000, 0.0000, 0.6804801, 0.9795798, 0.24646705],
                     ],
                 ]
             ],
diff --git a/test/geometry/camera/test_pinhole.py b/test/geometry/camera/test_pinhole.py
--- a/test/geometry/camera/test_pinhole.py
+++ b/test/geometry/camera/test_pinhole.py
@@ -198,6 +198,7 @@ def test_consistency(self, batch_size, device, dtype):
         assert_close(pixel_coords_concat, pixel_coords_input, atol=1e-4, rtol=1e-4)
 
     @pytest.mark.parametrize("batch_size", (1,))
+    @pytest.mark.slow
     def test_gradcheck(self, batch_size, device, dtype):
         H, W = 10, 20
         fx, fy = W, H
diff --git a/test/nerf/test_nerf_solver.py b/test/nerf/test_nerf_solver.py
--- a/test/nerf/test_nerf_solver.py
+++ b/test/nerf/test_nerf_solver.py
@@ -26,6 +26,7 @@ def test_parameter_change_after_one_epoch(self, device, dtype):
             for param_before_update, param_after_update in zip(params_before_update, params_after_update)
         )
 
+    @pytest.mark.slow
     def test_only_red_uniform_sampling(self, device, dtype):
         torch.manual_seed(1)  # For reproducibility of random processes
         camera = create_one_camera(5, 9, device, dtype)