Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
17th June 2006, 04:15 | #1 | Link |
Registered User
Join Date: Nov 2003
Posts: 1,281
|
Saving grain for later use
Is there any way (perhaps with masks and such) to create a copy of the grain and perhaps fine details of video, and save that information in to a small file, with the ability to add that information back to the video at playback?
It's only an idea, I would not be able to attempt it myself, nor have I really any idea how to do it. But I know you guy's use masks and such for denoising/sharpening/etc. Perhaps is there was a way to save that information into say a smaller than 1mb file, then use ffdshow's avisynth to insert it back in at playback. Would be great for x264!! |
17th June 2006, 04:19 | #2 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
My company's silicon can do something like this (STMicroelectronics' 7109 MPEG/AVC/VC1 decoder). It doesn't save the grain, but it regenerates random grain and adds it to the display frames. It is very effective at eliminating that plastic look. There's no need to save the actual grain because it is random.
I also noticed Sony's big LCOS TVs have a slightly grainy display panel surface that achieves the same effect! Last edited by Guest; 17th June 2006 at 04:22. |
17th June 2006, 04:53 | #3 | Link |
Registered User
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,984
|
ffdshow can add some grain during playback. It IS a good way to reduce excess smoothness.
Hmm...I wonder if harshly removing grain and using a slight application of MSU's cartoon filter would give a semi-CGI appearance. That would be kind of funny, emulating CGI with live action.
__________________
Reclusive fart. Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers |
17th June 2006, 04:59 | #4 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
do you mean something similar to wavpack's dualstream feature, where a lossy track is stored, and a residual is also stored losslessly so they can be combined later?
easiest way would be to run your favourite denoiser, then subtract the result from the original. then encode both versions (maybe the noisy one with a different codec?) and subtract them again on playback using an avisynth script. i can't see it being terribly useful though - random noise doesn't compress very well at all, and will tend to swim around just like it would if it were left in the original (perhaps it'll swim in different directions which could be an improvement). this means you'll have twice (or more) the filesize to do what an addgrain on playback would do. as neuron alluded to, newer encoding technologies can add grain on playback. i think h.264 (though no current software implementations that i know of) will store grain paramerically and reproduce it on playback. it wont be the same grain, but will have the same properties and look the same. quite clever actually, considering how much grain is removed by h.264 even at relatively low quantisers (~17-20).
__________________
sucking the life out of your videos since 2004 |
17th June 2006, 05:50 | #5 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
Use this prior to denoising or encoding and save it:
Code:
grain=default(grain,10) gthresh=default(gthresh,1.0) gmask=fft3dfilter(sigma=gthresh*10,sigma2=gthresh*4,sigma3=gthresh,sigma4=0,plane=4) \ .mt_lutxy(last,expr="x y - abs",chroma="process") \ .BilinearResize(m(4,width/4),m(4,height/4)).mt_lut(expr="x 2 ^",chroma="process") Code:
mt_merge(last,addgrainc(grain*10,grain*2),gmask.bilinearresize(width,height),chroma="process") A smart enough grain filter could probably determine the best areas to apply it back to without an external reference, which would be an interesting area of research someday. Probably too mathematical for me though! Last edited by foxyshadis; 17th June 2006 at 06:02. |
17th June 2006, 09:20 | #6 | Link |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,733
|
A grain factory created by Didée, needs MaskTools v1.5.x and AddGrain:
Code:
function GrainFactory(clip last,int "grain1_strength",int "grain2_strength",int "grain1_sharpness",int "grain2_sharpness") { grain1_strength=default(grain1_strength,5) grain2_strength=default(grain2_strength,2) grain1_sharpness=default(grain1_sharpness,75) grain2_sharpness=default(grain2_sharpness,75) #grain1_strength = 7 # [ 0 - ???] strength of grain / for mid-tone areas grain1_size = 1.15 # [0.5 - 4.0] size of grain / for mid-tone areas #grain2_strength = 0 # [ 0 - ???] strength of grain / for dark & bright areas grain2_size = 0.8 # [0.5 - 4.0] size of grain / for dark & bright areas #grain1_sharpness = 75 # [ 0 - 100] very soft (0) to very sharp(100) #grain2_sharpness = 75 # [ 0 - 100] grain definition grain1_texture = 0 # [ 0 - 100] strength of "material texture" appearance grain2_texture = 0 # [ 0 - 100] (in fact: 'bump' effect) ontop_grain = 0 # [ 0 - ???] additional grain to put on top of prev. generated grain temp_avg = 20 # [ 0 - 100] percentage of noise's temporal averaging brightness_bias = 0.96 # [0.5 - 2.0] bias for dark|bright --> midtone fading #----------------------------------------------------------------------------------- o = last ox = o.width oy = o.height sx1 = m4(ox/grain1_size) sy1 = m4(oy/grain1_size) sx1a = m4((ox+sx1)/2.0) sy1a = m4((oy+sy1)/2.0) sx2 = m4(ox/grain2_size) sy2 = m4(oy/grain2_size) sx2a = m4((ox+sx2)/2.0) sy2a = m4((oy+sy2)/2.0) b1 = grain1_sharpness/(-50.0) + 1.0 b2 = grain2_sharpness/(-50.0) + 1.0 b1a = b1/2.0 b2a = b2/2.0 c1 = (1.0-b1)/2.0 c2 = (1.0-b2)/2.0 c1a = c1/2.0 c2a = c2/2.0 t1a = string(grain1_texture) t1b = string(100-grain1_texture) t2a = string(grain2_texture) t2b = string(100-grain2_texture) tmpavg = temp_avg/100.0 #----------------------------------------------------------------------------------- ADD_DIFF = "x y - 128 +" BUMPKERNEL1 = T1a + " 0 0 0 " + T1b + " 0 0 0 0" BUMPKERNEL2 = T2a + " 0 0 0 " + T2b + " 0 0 0 0" CENTER2MAX_BIAS = "x 120 - abs "+string(brightness_bias)+" ^ 2.5 *" #----------------------------------------------------------------------------------- grainlayer1 = blankclip(o, width=sx1, height=sy1, color=$808080) .AddGrain(grain1_strength, 0, 0) grainlayer1 = (grain1_texture==0) \ ? grainlayer1 \ : yv12lutxy(grainlayer1,grainlayer1.DEdgeMask(0,255,0,255, BUMPKERNEL1), ADD_DIFF) grainlayer1 = (grain1_size == 1.0) ? grainlayer1 \ : (grain1_size < 0.75) ? grainlayer1.bicubicresize(sx1a,sy1a, b1a, c1a).bicubicresize(ox,oy, b1a,c1a) \ : grainlayer1.bicubicresize(ox,oy, b1,c1) #----------------------------------------------------------------------------------- grainlayer2 = blankclip(o, width=sx2, height=sy2, color=$808080) .AddGrain(grain2_strength, 0, 0) grainlayer2 = (grain2_texture==0) \ ? grainlayer2 \ : yv12lutxy(grainlayer2,grainlayer2.DEdgeMask(0,255,0,255, BUMPKERNEL1), ADD_DIFF) grainlayer2 = (grain2_size == 1.0) ? grainlayer2 \ : (grain2_size < 0.75) ? grainlayer2.bicubicresize(sx2a,sy2a, b2a, c2a).bicubicresize(ox,oy, b2a,c2a) \ : grainlayer2.bicubicresize(ox,oy, b2,c2) #----------------------------------------------------------------------------------- grainlayer = MaskedMerge(grainlayer1, grainlayer2, o.yv12lut(CENTER2MAX_BIAS), U=1,V=1) grainlayer = (temp_avg==0) ? grainlayer \ : grainlayer.mergeluma(grainlayer.temporalsoften(1,255,255,255,2), tmpavg) grainlayer = (ontop_grain==0) ? grainlayer \ : grainlayer.AddGrain(ontop_grain,0,0) #----------------------------------------------------------------------------------- result = yv12lutxy(o, grainlayer, ADD_DIFF, U=2,V=2) return result } #----------------------------------------------------------------------------------- function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) } #=================================================================================== The function can be used to create a very nice film grain effect and add fake details to the image.
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
17th June 2006, 09:55 | #7 | Link |
Registered User
Join Date: Nov 2003
Posts: 1,281
|
I've never really liked any of the addgrain implementations of ffdshow for one reason or the other.
X264 removes grain at lower bitrates. I was thinking that if it was possible to take the "original" grain from the video and add it back at playback, that would be better than adding artificial grain. |
17th June 2006, 11:48 | #9 | Link | |
Registered User
Join Date: May 2005
Posts: 236
|
Quote:
You all say that x264 is removing too much noise and gives a plastic look, but to me it's getting closer to reality... When I filter the noise but keep details, and then encode with --filter -3:-1 or so to limit the blur from inloop, this preserves quite well the textures, and I don't have the "plastic" impression that I had with the rv10 codec for instance.. |
|
17th June 2006, 15:54 | #10 | Link | |
Registered User
Join Date: Apr 2005
Posts: 224
|
Quote:
__________________
PAL FACTS * 20% more horizontal scan lines than NTSC * No telecine judder |
|
17th June 2006, 16:55 | #11 | Link |
Registered User
Join Date: May 2005
Posts: 236
|
Yes, but you can greatly preserve details with motion compensation tools, and remove mainly noise ; I do plenty of comparison between my source and my filtered clip, I hardly see what detail is altered, only the noise ; I think the noise is a way to compensate the small pixel resolution we have, that makes all small movements obvious and unnatural on a noiseless pictures, but as we increase the resolution of the clips, I think it will be less and less needed to do this..
|
17th June 2006, 23:16 | #12 | Link | |
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
New: Now with 500% more words!
Quote:
Anyway, here is another filter to add noise via avisynth... ^^ Last edited by Soulhunter; 17th June 2006 at 23:23. |
|
18th June 2006, 01:16 | #14 | Link |
Registered User
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,984
|
@soulhunter,
You're vague, again. Would it be too much to ask for you to be specific in your posts? A little attention to detail and some background information never hurt anyone.
__________________
Reclusive fart. Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers Last edited by FredThompson; 18th June 2006 at 01:19. |
18th June 2006, 04:11 | #15 | Link | |
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
Quote:
Bye Last edited by Soulhunter; 18th June 2006 at 05:35. |
|
18th June 2006, 04:59 | #16 | Link |
Registered User
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,984
|
Sorry, I still don't understand what you're trying to explain. Can you give more details?
It's obvious you're trying to be helpful. I appreciate that. It's still a little...to...vague...
__________________
Reclusive fart. Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers |
18th June 2006, 05:16 | #17 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Fred, please knock it off. A rule 11 strike is imminent. Thank you.
http://forum.doom9.org/forum-rules.htm If you have any questions, please follow up in PM, not here. |
18th June 2006, 06:25 | #18 | Link |
Registered User
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,984
|
Geez, lighten up. The smiley should make the first reply obvious. He's got thick enough skin to recognize the backhanded comment and the humor.
edit: That's supposed to read "compliment" - should be obvious ...
__________________
Reclusive fart. Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers Last edited by FredThompson; 18th June 2006 at 09:07. |
18th June 2006, 08:28 | #19 | Link | |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Quote:
|
|
18th June 2006, 10:36 | #20 | Link | |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
Quote:
actually i think if someone would be willing to write an avs plugin that outputs the grain info into a file aku will add support for the avc filmgrain feature to x264
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
|
|
|