FastLED 3.9.15
Loading...
Searching...
No Matches
noise_test_helpers.h
Go to the documentation of this file.
1#pragma once
2
3#include "crgb.h"
4#include "fl/math/math.h"
5
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}
Legacy header.
constexpr enable_if< is_fixed_point< T >::value, T >::type sqrt(T x) FL_NOEXCEPT
float calcAverageColorDifference(const fl::CRGB *frame1, const fl::CRGB *frame2, int num_leds)
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38