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 134 of file bilinear_expansion.cpp.

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

Referenced by bilinearExpandPowerOf2().

+ Here is the caller graph for this function: