VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 36
Thread
  1. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    How can I add, for instance something like TTempSmooth to the gray midtone in this clip (the window frame and the gray curtain), and mask out the rest of the dark areas?
    Attached Files
    Quote Quote  
  2. Basically you need to build a mask using the absolute values of the (chroma channels - 128). I'm pretty sure masktools can do this but I don't have time to look into it now.
    Quote Quote  
  3. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    It's making sense. So am I masking the gray area or the dark areas surrounding it? Also, what does 128 stand for here?
    Quote Quote  
  4. Banned
    Join Date: Oct 2004
    Location: New York, US
    Search Comp PM
    -30-
    Last edited by sanlyn; 22nd Mar 2014 at 04:21.
    Quote Quote  
  5. Oops, I remembered your original post incorrectly and wrote this reply thinking you wanted to filter the grayscale areas but not the colorful areas... You should be able to extrapolate from this to get what you want...

    The actual value you want to subtract is 130*, not 128. I'm using mt_masktools to build the mask. I don't know if this is exactly what you want. It filters areas of low color saturation but not areas of high color saturation.

    Code:
    Mpeg2Source("sample1.demuxed.d2v").TFM().TDecimate()
    
    umask=UtoY().BicubicResize(width,height).mt_lut("x 130 - abs").mt_lut("x 12 - 16 *")
    vmask=VtoY().BicubicResize(width,height).mt_lut("x 130 - abs").mt_lut("x 12 - 16 *")
    mask=Merge(umask, vmask)
    
    mt_merge(McTemporalDenoise(settings="high"), last, mask)
    Unfiltered on the left, filtered on the right:

    Click image for larger version

Name:	colormask.jpg
Views:	58
Size:	105.7 KB
ID:	12398

    You'll have to play around with the mt_lut() values to get exactly the effect you want.

    UtoY() and VtoY() convert the U and V channels to Y. Since this is YV12 they have to be scaled back to the main clip's width and height. mt_lut("x 130 - abs") generates an image where anything that is gray gets the value 0, anything that has colors is >0 (ie, abs(y-130)). mt_lut("x 12 - 16 *") first subtracts 12 (basically a threshold amount of color) then multiples by 16 to accentuate the mask (ie, (y-12) * 16). Merge() blends the two masks together into one mask. Now anything that is (nearly) grayscale is black in the mask, anything that is colorful is white. Finally, we use mt_merge() to merge a highly filtered version of the video with a non filtered version of the video based on the mask. Here's what the mask looks like:

    Name:  mask.jpg
Views: 59
Size:  22.5 KB

    If you want only the gray window frame and wooden planks filtered, but not the black parts of the picture, you'll have to add (and massage) the luma channel to the mask.

    * when the chroma channels of a pixel are 130 the pixel has no color, ie, it's a shade of gray. Any deviation from 130 in either of the chroma channels adds color to the pixel. The more the deviation the greater the color saturation.
    Last edited by jagabo; 12th May 2012 at 18:04.
    Quote Quote  
  6. Member
    Join Date: Jul 2009
    Location: Spain
    Search Comp PM
    Originally Posted by jagabo View Post
    when the chroma channels of a pixel are 130 the pixel has no color, ie, it's a shade of gray. Any deviation from 130 in either of the chroma channels adds color to the pixel.
    Doesn't 128 represent gray?

    Incidentally, you could combine the two mt_lut calls with a single expression, ie replace
    mt_lut("x 130 - abs").mt_lut("x 12 - 16 *")
    by
    mt_lut("x 130 - abs 12 - 16 *")
    Quote Quote  
  7. Banned
    Join Date: Oct 2004
    Location: New York, US
    Search Comp PM
    -30-
    Last edited by sanlyn; 22nd Mar 2014 at 04:22.
    Quote Quote  
  8. mt_lut() basically performs mathematical operations on video data. Since all the sources are 8 bit per channel it uses a lookup table (hence the "lut" in the name) to optimize for speed. Ie, there are only 256 possible inputs so there are only 256 possible outputs. The program pre-calculates the outputs for all 256 possible inputs (0 to 255) and puts them in a table. Then when it operates on the video data it performs a quick table lookup rather than the slower calculations.

    Suppose for example you want to perform a 2x luma gain, Y' = 2 * Y, or mt_lut("2 x *"). You first build a table of results for all possible values of Y:

    Y,Y'
    ----
    0,0
    1,2
    2,4
    3,6
    ...
    127,254
    128,255
    129,255
    ...
    254,255
    255,255

    You don't need to store both Y and Y', Y is implied by the position in the table, Y' = table[Y]. So the table only includes the output values. Accessing a table like this faster than preforming the calculations each time, especially in an interpreted system (ie, the text string you supply has to be interpreted into mathematical operations).

    You specify the operations you want to perform in reverse polish notation:

    http://en.wikipedia.org/wiki/Reverse_Polish_notation

    If you've ever used an HP calculator you are familiar with this.
    Quote Quote  
  9. Member
    Join Date: Jul 2009
    Location: Spain
    Search Comp PM
    Originally Posted by jagabo View Post
    You specify the operations you want to perform in reverse polish notation
    It's worth noting that MaskTools has a support function mt_polish() that converts normal ('infix') expressions into reverse polish notation (RPN). So if you find RPN confusing, you can simply write the expression in a more natural form and use mt_polish() to do the conversion.

    Instead of mt_lut("x 130 - abs 12 - 16 *"), you could use
    mt_lut(mt_polish("(abs(x-130) - 12) * 16"))

    @jagabo: I'm still puzzled why you used 130 instead of 128 in the earlier reply.
    Quote Quote  
  10. Originally Posted by Gavino View Post
    @jagabo: I'm still puzzled why you used 130 instead of 128 in the earlier reply.
    Oh, you're right. It should be 128. I used UtoY() and VtoY() to examine the chroma channels of grayscale video in VirtualDub and the on-screen results were 130. I forgot that VirtualDub was using a rec.601 matrix to display the video. So I was seeing a contrast stretched result. If you use ConvertToRGB(matrix="PC.601") you'll see the proper value is 128, not 130.
    Quote Quote  
  11. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    I'm going to review the MT_Mask documents and I bet 47 consecutive paychecks that it is not written in layman's terms.

    In any event jag, thanks for the script. I'm toying around with it and am going to keep reading up to get a better understanding of how to do this.

    Polish notations. Pheh!

    How about ENGLISH explanations with these things?
    Quote Quote  
  12. Banned
    Join Date: Oct 2004
    Location: New York, US
    Search Comp PM
    -30-
    Last edited by sanlyn; 22nd Mar 2014 at 05:50.
    Quote Quote  
  13. Member
    Join Date: Jul 2009
    Location: Spain
    Search Comp PM
    Originally Posted by unclescoob View Post
    I'm going to review the MT_Mask documents and I bet 47 consecutive paychecks that it is not written in layman's terms.
    LOL.
    It's not exactly light reading, the sort of thing that's a useful reference if you already understand it, but lacking in introduction and explanation.

    It's a pity jagabo didn't write the manual - he has a flair for explaining things and his description of mt_lut is the clearest I've seen.
    Quote Quote  
  14. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    Originally Posted by sanlyn View Post
    Are these sources second or third generation copies of other recordings?
    Unfortunately, they're official, retail DVDs. The production company never bothered. I have been doing great work with...believe it or not....Avisynth, yes. And nothing more. This particular episode is almost completely restored using MCTemporalDenoise and TTEmpSmooth. I don't mess with color spaces if I don't have to. In this case, I'm tweaking my almost finished work, and this happens to be one of the scenes I have to tweak.

    Jagabo - I am trying to filter the gray frames and pineboards in the clip, and leave the dark scene unfiltered because I am trying to avoid blurring the black details. However, I think I can accomplish this with TemporalDegrain for this particular scene. So I might not have to mess with masking after all. We'll see.
    Quote Quote  
  15. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    Originally Posted by Gavino View Post
    .. but lacking in introduction and explanation.
    Yeah, no shit. Well jag? Gavino obviously has some pretty nice things to say about your ability to explain MT_Mask. Why not give it a shot? If you won't give the intro, at least can you guide some of us to the right introductory link (if one even exists)?
    Quote Quote  
  16. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    Check out some work I've done with just MCTemporal and TTempSmooth (note, I did not use TTEmpSmooth with the entire episode, just trimmed this particular clip. We've reviewed this clip in my previous thread). Why do I feel like I'm setting myself up here? Ok, in any event, here goes..

    The first one is the clip prior to denoising, and the second is a denoised clip...
    Attached Files
    Quote Quote  
  17. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    Realize that the filtered clip is taking longer, as I encoded at a higher bitrate than the original. Sorry about that for those who wish to watch.
    Quote Quote  
  18. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    So I'm getting the silent treatment, honey? Awwww, come on, what did I do?? Was it the comment about how big your head looks in that turtleneck?? Honeeyyy????
    Quote Quote  
  19. Since your doing all that filtering you should sharpen the chroma channels and shift them left by a few pixels. Otherwise the filtered video looked pretty good.
    Quote Quote  
  20. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    No. That sounds silly and makes no sense.
    Quote Quote  
  21. You really are an idiot and an *******.

    Unsharpened chroma on the left, sharpened on the right (U on top, V on bottom, from your "after" video):
    Name:  croma.png
Views: 49
Size:  148.1 KB

    Alternating original, sharpened chroma sample:
    Attached Files
    Last edited by jagabo; 14th May 2012 at 21:17.
    Quote Quote  
  22. Banned
    Join Date: Oct 2004
    Location: New York, US
    Search Comp PM
    -30-
    Last edited by sanlyn; 22nd Mar 2014 at 05:50.
    Quote Quote  
  23. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    Originally Posted by jagabo View Post
    You really are an idiot and an *******.

    Oowwwwwwww!!!!!! I LOVE it when you talk dirty to me, Jag!!

    First question...what filter do you use to preview the clip in that manner?

    Secondly, you don't even explain how you sharpen the chroma, other than "U on top, V on bottom". Ok, the luma sample is on the top, and the chroma is on the bottom. I see that. What's the script? As usual, you explain things to people as if they already KNOW the answer. Hence defeating the purpose of calling this site VideoHELP

    Thirdly, your attached AVI is nothing but one frame with the word 'original' on the top left. Is this my ORIGINAL clip, or your tweaked version of my original?
    Last edited by unclescoob; 15th May 2012 at 06:58.
    Quote Quote  
  24. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    Originally Posted by sanlyn View Post
    The flicker you complained about in one of the shots with the redhead is still there.
    No it's not.
    Quote Quote  
  25. Banned
    Join Date: Oct 2004
    Location: New York, US
    Search Comp PM
    -30-
    Attached Files
    Last edited by sanlyn; 22nd Mar 2014 at 05:52.
    Quote Quote  
  26. Banned
    Join Date: Oct 2004
    Location: New York, US
    Search Comp PM
    -30-
    Last edited by sanlyn; 22nd Mar 2014 at 05:52.
    Quote Quote  
  27. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    LOL that almost looks greyscale. But I'll give it a shot.
    Quote Quote  
  28. Banned
    Join Date: Oct 2004
    Location: New York, US
    Search Comp PM
    -30-
    Last edited by sanlyn; 22nd Mar 2014 at 05:52.
    Quote Quote  
  29. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    what I meant was, that your sample almost looks too desaturated. Lifeless. There's color, yes, but very little. Why does everyone here have to take things to outer space? I make a comment about the results, and my monitor's calibration comes into question.

    I've been reading some tutorials from Scintilla at AnimeMusicVideos.org and let me be quite frank...they're LEGIBLE. His guides help you understand the filters without the aggravating jargon that everyone seems to use here all the time. He makes it fun to learn this.

    When a question is posted on VideoHelp.com and it's answered in vague, unecessarily complicated jargon, others jump in to further confuse you with "or you can also do it this way..jargon jargon jargon". When the newbie tries it and posts his results, they're "ok". When a regular "expert" posts his/hers/it's results, you all compliment each other (rightfully so) but it gets to the point borderlining a textual circle jerk (i.e. "Ooh, good idea jagabo, you know this better than I do!"). I'm done with VH.com. I'm taking the rest of this road alone and will learn through trial and error. I'm also going to continue reading Scintilla's guides. Have I learned here? Sure, alot actually, no question about it. But at the cost of unecessary aggravation. Working with video is aggravating (but rewarding) enough without the added fanboy crap. "Elevated red crashes" and "blue too close to the bottom" Sanlyn??? Really???? I just wanted to tweak and clean my vid a bit, I didn't need a damn catscan performed on it!

    Bye.
    Last edited by unclescoob; 15th May 2012 at 09:42.
    Quote Quote  
  30. Member
    Join Date: Dec 2010
    Location: New York
    Search Comp PM
    Jagabo, I love you baby!
    Quote Quote  



Similar Threads