nonoitall
1st June 2007, 23:28
I have a motion compensated clip and I want to selectively replace frames in it that are dissimilar from the original clip by a certain threshold. Basically, a certain amount of luma difference will decide whether the motion compensated clip is too different or not. But I also want to weight this difference against the average luma in the original clip. (For example, a tiny difference on a frame with lots of luma will be ignored, but a tiny difference on a darker frame will have a better chance of going over the threshold.) Here's what I want to do:
#source is the original clip
#mocomp is the motion compensated clip
#abs_difference is a clip with the absolute luma difference between the two
#threshold is a threshold!
new_mocomp = ConditionalFilter(abs_difference, mocomp, source, \
"abs_difference.AverageLuma() / source.AverageLuma()", "<", String(threshold))
Unfortunately, I can only test the average luma of the test clip (abs_difference) and not the source clip (unless, of course, I make source the test clip, in which case I can't test the average luma of the abs_difference clip). For the moment, I stack the two clips together and then crop a couple of times inside the ConditionalFilter function to separate them again, but this seems horribly inefficient. Is there a better way?
#source is the original clip
#mocomp is the motion compensated clip
#abs_difference is a clip with the absolute luma difference between the two
#threshold is a threshold!
new_mocomp = ConditionalFilter(abs_difference, mocomp, source, \
"abs_difference.AverageLuma() / source.AverageLuma()", "<", String(threshold))
Unfortunately, I can only test the average luma of the test clip (abs_difference) and not the source clip (unless, of course, I make source the test clip, in which case I can't test the average luma of the abs_difference clip). For the moment, I stack the two clips together and then crop a couple of times inside the ConditionalFilter function to separate them again, but this seems horribly inefficient. Is there a better way?