Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !

# is this even possible with Avisynth?

1. I've been working on some cartoons with Mdegrain lately. Works great but some fast motion dark scenes slightly suffer with blurring/ghosting.

So I thought about this crazy idea: Using Histogram("luma"), which removes all the chroma from the picture while maintaining all details, THEN applying mdegrain. I think this would give me a better motion vector and an overall, more accurate cleanup job.

Two questions: Will this work and can someone assist me with a script on how to do it (if it's possible)?
2. Originally Posted by unclescoob
I've been working on some cartoons with Mdegrain lately. Works great but some fast motion dark scenes slightly suffer with blurring/ghosting.

So I thought about this crazy idea: Using Histogram("luma"), which removes all the chroma from the picture while maintaining all details, THEN applying mdegrain. I think this would give me a better motion vector and an overall, more accurate cleanup job.

Two questions: Will this work and can someone assist me with a script on how to do it (if it's possible)?
You don't want to use histogram("luma"), not even for a mask, or prefilter, or to take vectors from - because it's a distorted, enhanced view. It enhances amplifies noise, flaws and all the defects on purpose. It's more of a visualization aid to see defects
3. I mostly agree with poisondeathray. But there might be some circumstances where you could use a variation of histogram("luma") in the motion vector analysis. But histogram("luma") alone will increase noise. You have to decrease the noise before the histogram. Use a script like the following to visualize motion vectors found by mvtools2:

Code:
```WhateverSource("filename.ext")
src = last

# show motion vectors of original video
super = MSuper()
vectors = MAnalyse(super, isb = false)
full = MShow(super, vectors) # implicit last works properly

# show motion vectors of histogram video
last = src
ColorYUV(gain_y=-224) # divide luma by 8 to reduce noise, try different strengths
Histogram("luma")
ColorYUV(gain_y=-128, off_y=32) # darken the histogram so we can see motion vectors better
super = MSuper()
vectors = MAnalyse(super, isb = false)
hist = MShow(super, vectors) # implicit last works properly

# show them side by side
StackHorizontal(full, hist)```
When I ran this on a few test videos there wasn't much difference in the motion vectors.
4. Thanks guys. PDR I'll give it a shot.
5. Use a mask for using lower settings on dark areas or simply to disable denoising there. You can also brighten the clip that gets the motion vectors, while denoising the actual clip.

Things like plane based motion vectors or prefiltering, etc are things implemented in smdegrain for simplicity reasons.
6. Jagabo, I used your script but I really don't know what to do with this. I see one side color with alot of dots and lines, and the other side in b&w with the same dots and lines (I assume those are motion vectors?)

Ok, so I see it. Is the purpose of the script just to see the motion vectors? Can I incorporate my clean-up job in this script?

I'm confused.

Please explain this to me like I'm an idiot.
7. Dogway, can I get a sample script?
8. Originally Posted by unclescoob
Jagabo, I used your script but I really don't know what to do with this. I see one side color with alot of dots and lines, and the other side in b&w with the same dots and lines (I assume those are motion vectors?)

Ok, so I see it. Is the purpose of the script just to see the motion vectors?
Yes, the purpose was to visualize the motion vectors so you can compare between the regular video and the histogram("luma") video. In the handful of video I tried it with there was very little difference.

Originally Posted by unclescoob
Can I incorporate my clean-up job in this script?
I haven't used MDegrain. I don't know if it supports the use of a separate video for motion vector analysis.

Regarding protecting dark areas from over filtering:

Code:
```weakfiltered = yadayada()