VideoHelp Forum
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. I have found a simple yet effective way to remove alpha-blended logos but there are some side effects which need fixing.

    First I mix all the frames of the video together into one image like this:

    Code:
    v=ffvideosource("video.mkv").converttoRGB32
    
    s1=v.selectevery(2,0)
    s2=v.selectevery(2,1)
    
    b1=Merge(s1,s2)
    
    s3=b1.selectevery(2,0)
    s4=b1.selectevery(2,1)
    
    b2=Merge(s3,s4)
    
    s5=b2.selectevery(2,0)
    s6=b2.selectevery(2,1)
    
    b3=Merge(s5,s6)
    
    s7=b3.selectevery(2,0)
    s8=b3.selectevery(2,1)
    
    b4=Merge(s7,s8)
    ...etc
    Until we have our averaged image with the isolated logo in the bottom right.
    http://pasteboard.co/2PiMw6hr.png

    The plan is to subtract the original video with this average but we only want the logo area to be affected so the average pixel value of the average composite is taken and everything except the logo area is painted over with that (feathered mask).
    http://pasteboard.co/2PiRR8fn.png

    But that subtraction changes the global brightness of the video so I subtract again with this negative to get the original brightness back:
    http://pasteboard.co/2PjpXvST.png

    And this is the result:
    http://screenshotcomparison.com/comparison/139091

    The logo is removed but there is clipping in bright areas. What did I do wrong? Is it the third step? If the pixel values are floats, I don't understand how subtraction can cause clipping.
    Quote Quote  
  2. I tried this again with makediff() which wraps values instead of clipping them like subtract() does and the results are rather disappointing. This particular logo is so faint that the compression artifacts defined its form a lot more than the logo itself which meant the averaged composite couldn't adapt to its every malformation on every scene. In the end it did reduce it somewhat but the effort isn't worth it.
    I wonder if this could be useful elsewhere though.
    Quote Quote  
  3. Averaging all the frames of the video together will not leave you with just the logo. Consider a video that's a still shot. If you average all the frames together you have the original still image with the logo, not a blank image with just the logo. If you then subtract that image from every frame of the video you will end up with a black picture with a little noise. Of course, real video isn't a single still image but it's not a collection of images that's guaranteed to averages out to a flat grey.

    Much better methods of isolating the logo is to find a frame with the logo over a black background (if the logo is only additive), or a flat grey background (if the logo is both additive and subtractive), or a still sequence where one frame has the logo and another doesn't. If you can't find a single frame (or pair) that match those criteria you can cut/paste portions of several frames together that match the criteria.

    By the way, your convoluted sequence of averaging frames could be simplified to:

    Code:
    Merge(SelectEven(), SelectOdd())
    Merge(SelectEven(), SelectOdd())
    Merge(SelectEven(), SelectOdd())
    etc.
    Last edited by jagabo; 20th Aug 2015 at 09:05.
    Quote Quote  
  4. Yes, but the idea was to subtract the average composite and then do a color correction to reverse the brightening or darkening side effect the operation would have. That's the purpose of the composite negative.

    But you are right, the better method is to find a flat area with the logo. In my case it won't work because the logo is Dodged or Burned (I forget which is which). It doesn't brighten in dark/black areas. The logo is faint and further destroyed by compression and film grain which after denoising leaves the logo in a mess, so I decided to leave it alone. It took me the first half an hour in the movie to notice it anyways.

    And thanks for the simplified script to average out frames. I have a small question, should I worry about there being an odd number of frames which might compromise the true average? In this movie I fixed it by trimming it to 131,072 frames which is a perfect root of 2 since the remaining 4000 frames were credits which didn't show the logo anyway.
    Quote Quote  
  5. Originally Posted by -Habanero- View Post
    should I worry about there being an odd number of frames which might compromise the true average? In this movie I fixed it by trimming it to 131,072 frames which is a perfect root of 2 since the remaining 4000 frames were credits which didn't show the logo anyway.
    The number of frames has to be a power of 2 to get an average of every frame using this technique.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!