Skip to main content
Inspiring
December 14, 2022
Question

Getting quantitative indicators of the color channel.

  • December 14, 2022
  • 5 replies
  • 656 views

Hi all.

 

There is a video about 20 seconds long. Somewhere around 7 seconds
at 2 seconds, the shooting scene is illuminated by a red light source.

 

You need to find the frame number when such lighting began.

 

The search strategy is to find the number of red pixels in the current frame
video, and comparing this value with the number of red pixels in the next frame.

 

Is there any filter that can give such a value?

 

Can anyone suggest another strategy for solving this problem, using AE?

This topic has been closed for replies.

5 replies

Mathias Moehl
Community Expert
Community Expert
December 14, 2022

suggestion:

1) create a slider control

2) apply an expression to the slider control which does the following:

- sample image (preferably only of the region where the laser occurs, if you know that region) at current frame and at previous one.
- subtract color at previous frame from color at current frame, let's call that "color delta"

- you now have "color delta" values for all three channels r,g, and b and they tell you how much the intensity in these colors changed. Compute an additional "color delta average" as the average of the "color delta"s for r,g and b.
- subtract the "color delta average" from the red "color delta" and use this value as the end result of the expression.

3) bake the expression into keyframes and look at the keyframes values in the graph editor.

The keyframes should have a high peak at all the frame where the laser occurred.


By subtracting the average from the red channel, you make sure that you only have high peaks when the area becomes more red and not if the entire scene gets just brigher (i.e. red, but also green and blue increase).

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
ShiveringCactus
Community Expert
Community Expert
December 14, 2022

What is the purpose of the search?  Are you hoping to remove the red pixels by using the frame next to it?  If so, a difference matte might be the simplest option, or content aware fill will be a bit more time consuming but lead to a better result.

Given that it's a laser beam, a luma key is another possibility.    

If you just need to identify the frames, you're only dealing with 2 seconds of footage to check. Pop a podcast one, and use the page down key to go frame by frame and hit the numpad * key whenever the light is on screen.

Mylenium
Legend
December 14, 2022

You don't just "set" sampleImage(). In your case one would need to construct an algorithm that loops through all the pixel areas until it finds pixels with a pre-defined threshold, then accumulates them in some form. Again, this is not exactly trivial stuff and would take some time to develop and test. Given the low contrast in your image there may also be other factors to consider like additional processing with effects. For the basics of sampleImage() you can find enough tutorials online just by typing in the function name in a web search.

 

Mylenium

Mylenium
Legend
December 14, 2022

You could try to use an effect like Shift Channels and set it to Red only, then apply some sort of sampleImage() expression to detect and count the pixels. Either way, anything but trivial.

 

Mylenium 

AnyONAuthor
Inspiring
December 14, 2022

Hello Mylenium

Can you describe the proposed algorithm in more detail?

Where should sampleImage() be set??

OussK
Community Expert
Community Expert
December 14, 2022

can you post some screenshots for both frames, with and without the red light? so we can better idea about the difference

AnyONAuthor
Inspiring
December 14, 2022

The stage is illuminated by a red laser