Yes you read it correctly I want to convert a video file to a single RGB pixel per frame, so another way to think about it is that this one color per frame is the color you would see on your ceiling when you are watching TV… I am finding it not as easy as you may think… right now it close, but the RGB value when the 1 pixel video is played back I think it “flashes/blinks” too much as the algorithm tried to determine the color…
Maybe you should explain what your current approach is? For example, are you computing an average RGB over the pixels array? are you using scaling, or a shader?
Depending on you area of appliication, you might be interested in bias lighting / ambilight / the adalight – there are privous Processing projects on this, for example:
looks like they are just looking at the perimeter colors and using them on the strip, the result would be OK, its way more complicated trying to get one color for the whole screen…
I tried designing algorithms based on the science of colors and our eyes, like how much each color adds to the overall perception of brightness is approx 60% G 25% R and 15% B, this gets you are good result, but when I calculate it and display it the color seems to change (flicker) too much compared to the video, one moment it picks bright white the next it shows blue… at the flick of a switch as the video pans from the sky down to the water… its a gradual thing but the one led flicks over from one color to another… so its not as easy as it seems…
If you want to reduce flickering and smooth your color transitions, you can save the current color and lerpColor towards the new (flickering) target color. This will reduce the total possible color difference per frame.
Here is a barely modified Video > Loop example to illustrate the idea. It resizes each frame of the movie into a single pixel, then extracts color and makes it the target. The current color chases the changing target using lerpColor and a transition rate 0-1.0.
import processing.video.*;
Movie movie;
PImage img;
color target;
color current;
float transition = 0.5;
void setup() {
size(560, 406);
background(0);
movie = new Movie(this, "launch2.mp4");
movie.loop();
}
void movieEvent(Movie m) {
m.read();
img = m.copy();
img.resize(1,1);
img.loadPixels();
target = img.pixels[0];
}
void draw() {
current = lerpColor(current, target, transition);
background(current);
}
WOW thanks so much, looks like just the conversion to 1x1 resize does the trick, I commented out the lerpColor() and displayed the video as it played with an overlaid patch of color and it behaves nicely!