MCPcopy Create free account
hub / github.com/FastLED/FastLED / calcAverageColorDifference

Function calcAverageColorDifference

src/noise_test_helpers.h:8–21  ·  view source on GitHub ↗

Helper function to calculate average color difference between two frames

Source from the content-addressed store, hash-verified

6namespace noise_test_helpers {
7 // Helper function to calculate average color difference between two frames
8 inline float calcAverageColorDifference(const fl::CRGB* frame1, const fl::CRGB* frame2, int num_leds) {
9 float total_diff = 0.0f;
10 for (int i = 0; i < num_leds; i++) {
11 // Calculate delta for each channel
12 int r_diff = (int)frame1[i].r - (int)frame2[i].r;
13 int g_diff = (int)frame1[i].g - (int)frame2[i].g;
14 int b_diff = (int)frame1[i].b - (int)frame2[i].b;
15
16 // Use Euclidean distance for color difference
17 float pixel_diff = fl::sqrt(r_diff*r_diff + g_diff*g_diff + b_diff*b_diff);
18 total_diff += pixel_diff;
19 }
20 return total_diff / num_leds;
21 }
22}

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 1

sqrtFunction · 0.85

Tested by

no test coverage detected