Transform the splats parameters to new domain e.g. for SH coefficients, transform them from RGB domain to YCbCr domain for quats: 1) normalize to unit quaternion 2) transform to Euler angles or other equivalent representations (Optional, depends on k
(self, splats_list: List[Dict], transform_attributes: Dict[str, bool])
| 100 | #self.compress_dir.mkdir(parents=True, exist_ok=True) |
| 101 | |
| 102 | def param_transform(self, splats_list: List[Dict], transform_attributes: Dict[str, bool]) -> List[Dict]: |
| 103 | """Transform the splats parameters to new domain |
| 104 | e.g. |
| 105 | for SH coefficients, transform them from RGB domain to YCbCr domain |
| 106 | for quats: |
| 107 | 1) normalize to unit quaternion |
| 108 | 2) transform to Euler angles or other equivalent representations (Optional, depends on kwargs) |
| 109 | |
| 110 | Args: |
| 111 | splats_list (List[Dict]): splats parameters of all frames |
| 112 | transform_attributes (Dict[str, bool]): indicate attributes whether to transform domain |
| 113 | """ |
| 114 | transformed_splats_list = [] |
| 115 | |
| 116 | # Define the RGB to YCbCr transformation matrices for different standards |
| 117 | |
| 118 | # BT.709 (Rec. 709) standard, which is the most widely used for HD content |
| 119 | # Reference: ITU-R BT.709-6 (06/2015) |
| 120 | # |
| 121 | # Key characteristics: |
| 122 | # - Designed for HD and Full HD content (1080p) |
| 123 | # - Uses D65 white point |
| 124 | # - Assumes RGB values are in range [0,1] |
| 125 | # - Output Y in range [0,1], Cb/Cr in range [-0.5,0.5] |
| 126 | bt709_rgb_to_ycbcr = torch.tensor([ |
| 127 | [ 0.299, 0.587, 0.114 ], # Y = 0.299R + 0.587G + 0.114B |
| 128 | [-0.169, -0.331, 0.5 ], # Cb = -0.169R - 0.331G + 0.5B |
| 129 | [ 0.5, -0.419, -0.081 ] # Cr = 0.5R - 0.419G - 0.081B |
| 130 | ], dtype=torch.float32) |
| 131 | |
| 132 | # BT.470 (older standard for SD/analog TV content) |
| 133 | # Reference: ITU-R BT.470 |
| 134 | # |
| 135 | # Key characteristics: |
| 136 | # - Designed for SD content and analog TV broadcasts |
| 137 | # - Uses different chroma scaling compared to BT.709 |
| 138 | # - Assumes RGB values are in range [0,1] |
| 139 | # - Output Y in range [0,1], Cb/Cr in range [-0.5,0.5] |
| 140 | bt470_rgb_to_ycbcr = torch.tensor([ |
| 141 | [ 0.299, 0.587, 0.114 ], # Y = 0.299R + 0.587G + 0.114B |
| 142 | [-0.147, -0.289, 0.436 ], # Cb = -0.147R - 0.289G + 0.436B |
| 143 | [ 0.615, -0.515, -0.100 ] # Cr = 0.615R - 0.515G - 0.100B |
| 144 | ], dtype=torch.float32) |
| 145 | |
| 146 | # Select the appropriate transformation matrix based on color standard |
| 147 | if self.color_standard == "BT470": |
| 148 | rgb_to_ycbcr = bt470_rgb_to_ycbcr |
| 149 | if self.verbose: |
| 150 | print("Using BT470 RGB to YCbCr transformation matrix") |
| 151 | else: # Default to BT709 |
| 152 | rgb_to_ycbcr = bt709_rgb_to_ycbcr |
| 153 | if self.verbose: |
| 154 | print("Using BT709 RGB to YCbCr transformation matrix") |
| 155 | |
| 156 | for splats in splats_list: |
| 157 | transformed_splats = {} |
| 158 | |
| 159 | # Process all keys in the splats dictionary |
no outgoing calls