View Full Version : Add static grain?
MrTroy
27th June 2006, 09:29
Is it possible to add static grain to a video? AddGrain can only add random grain, but I would like the grain to remain in the same spots every frame.
Chances are it will look very ugly, but still I'd like to try it. I want to achieve a grainy look, but I don't like randomness.
Manao
27th June 2006, 09:36
video = source(...)
grained_video = video.addgrain(...).freezeframe(0, framecount(video), 0)
return grained_video
Didée
27th June 2006, 09:51
Not quite, Manao, That will freeze all of the video content, won't it? ;)
video = whatever
grain = blankclip(video, color=$808080).AddGrain(parameters)
grain = grain.trim(1,1).loop(framecount(video))
Overlay(video,grain,mode="difference")
Note: there might be slight mistakes, as I never use Overlay() ... never am sure if "neutral grey" is 128 or 126 (126 probably?), and I never feel safe about clip's chroma when using overlay...
The MaskTools variant, fast & secure:
video = whatever
grain = video.mt_lut(Y=-128).AddGrain(parameters)
grain = grain.trim(1,1).loop(framecount(video))
mt_makediff(video,grain,U=2,V=2)
foxyshadis
27th June 2006, 10:08
Or you could just use.... AddGrainC(x,seed=1) where x is your other parameters.
http://www.avisynth.org/mediawiki/wiki/AddGrainC
Didée
27th June 2006, 10:13
Uh, of course!
Excuse: That mod of AddGrain is pretty new, and hasn't crawled into brain stem, yet ... ;)
Manao
27th June 2006, 11:06
That will freeze all of the video content, won't it?:D ( and indeed, mt_makediff is better suited than overlay )
MrTroy
27th June 2006, 12:15
Thanks all. Your MaskTools solution works great, Didée. But I'll be sure to try foxyshadis' way too.
I'm not sure static grain works tho, the fact that it's the same every frame makes it look like there's dust on my display instead of the grain belonging to the film. :o
And you were right, the Overlay solution contains a mistake. :D
Soulhunter
27th June 2006, 13:15
GNoise(Sigma=SomeFloat,Temporal=False) (http://soulhunter.chronocrossdev.com/data/gnoise_r4.zip)
Bye
Chainmax
27th June 2006, 13:57
foxyshadis, I've been meaning to ask you about AddGrainC. As you know, I usually include AddGrain(10,0,0) in many of my footage restoration scripts. Would AddGrainC(10,0,0) yield the exact same result?
foxyshadis
27th June 2006, 20:36
Yes, but for the wrong reason (second param is chroma grain now, not hcorr), not that I guess it really matters; but it'll replace AddGrain also and extend its syntax in a backward compatible way. :p
btw, quick tidbit: I found that AddGrain(whatever).Undot() (or .Removegrain(mode=1)) is a great way to add edge-hugging noise without looking as randomly sprayed as it normally does. Undot hardly changes the nature of the original, especially if it's detail-free enough that you need grain, but it shapes the grain toward areas with more detail.
Chainmax
27th June 2006, 23:07
Yes, but for the wrong reason (second param is chroma grain now, not hcorr), not that I guess it really matters; but it'll replace AddGrain also and extend its syntax in a backward compatible way. :p
I don't follow you: does it work identically or not? And is AddGrainC(10,0,0) identical to AddGrain(10,0,0) or not?
btw, quick tidbit: I found that AddGrain(whatever).Undot() (or .Removegrain(mode=1)) is a great way to add edge-hugging noise without looking as randomly sprayed as it normally does. Undot hardly changes the nature of the original, especially if it's detail-free enough that you need grain, but it shapes the grain toward areas with more detail.
Yeah, we talked about this when brainstorming for BlockTerminator.
foxyshadis
28th June 2006, 00:02
I don't follow you: does it work identically or not? And is AddGrainC(10,0,0) identical to AddGrain(10,0,0) or not?
The output is identical. The argument order changed, but if they're 0 anyway it makes no difference, that was intentional. (Also everything is optional now.)
Boulder
28th June 2006, 09:36
There's also BlockBuster that can add static grain. Blockbuster(method="dither",detail_min=1,detail_max=100) will do the trick.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.