FastLED 3.9.15
Loading...
Searching...
No Matches

◆ bilinearInterpolatePowerOf2()

uint8_t fl::bilinearInterpolatePowerOf2 ( uint8_t v00,
uint8_t v10,
uint8_t v01,
uint8_t v11,
uint8_t dx,
uint8_t dy )

Definition at line 137 of file bilinear_expansion.cpp.

138 {
139 uint16_t dx_inv = 256 - dx; // 0 to 256
140 uint16_t dy_inv = 256 - dy; // 0 to 256
141
142 // Scale down weights to fit into uint16_t
143 uint16_t w00 = (dx_inv * dy_inv) >> 8; // Max value 256
144 uint16_t w10 = (dx * dy_inv) >> 8;
145 uint16_t w01 = (dx_inv * dy) >> 8;
146 uint16_t w11 = (dx * dy) >> 8;
147
148 // Sum of weights should be approximately 256
149 uint16_t weight_sum = w00 + w10 + w01 + w11;
150
151 // Compute the weighted sum of pixel values
152 uint16_t sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11;
153
154 // Normalize the result
155 uint8_t result = (sum + (weight_sum >> 1)) / weight_sum;
156
157 return result;
158}

Referenced by bilinearExpandPowerOf2().

+ Here is the caller graph for this function: