VideoHelp Forum




+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 51
  1. Hello,

    I got an old VHS, and I would like to know if there is anything possible to enhance it's quality.
    The problem is the following: The edges are blurred. They appear to be doubled as if there was to pictures on over the other. You'll see what I mean with this picture:

    Click image for larger version

Name:	dallas2.jpg
Views:	2012
Size:	210.5 KB
ID:	1427

    Click image for larger version

Name:	dallas1.jpg
Views:	1862
Size:	222.7 KB
ID:	1426

    Is there anything I can do to fix this problem?

    Thank you in advance for any advices.
    Quote Quote  
  2. You have interlaced video. Each frame contains two half images, called fields, intended to be viewed one field at a time. If you're making a DVD this doesn't need to be "fixed", it's normal for video. DVD players and TVs will display it properly. But the sample frame you posted indicates the video was mishandled somewhere and the two fields are no longer completely separate. There is no way to fix this. Maybe this mishandling was in your preparation of the samples, not in the source? Post a short sample of the source in its native format.

    Your video also shows signs of severe over sharpening (halos). Typical of multigeneration VHS recordings. If this is a first generation recording the over sharpening could come from your VHS deck, capture card, or any other filtering you're doing. Disable any sharpening filters you can. If you can't you can use a Blur(x,y) filter in AviSynth. There are also Dehalo() filters that may help.
    Last edited by jagabo; 21st Apr 2010 at 06:39.
    Quote Quote  
  3. What do you mean by "the two fields are no longer completely separate"?
    I also posted the two separate fields and there is the same problem on each field... edges doubled.

    What is "over sharpening"?
    Quote Quote  
  4. Before explaining sharpening it helps to understand how to blur an image. Suppose you have a line of pixels (let's use grayscale so we can show each pixel as a single number, its intensity):

    50 50 50 50 100 100 100 100

    That represents a sharp transition from dark (50) to light (100). Blurring an image is basically the "leaking" of light from nearby pixels. You can simulate this by making each pixel the average of itself and the two pixels at its side. Assuming the pixels just outside the edge of this frame are the same as the pixels at the edges (ie, there is another 50 to the left and another 100 to the right):

    [(50+50+50)/3] [(50+50+50)/3] [(50+50+50)/3] [(50+50+100)/3] [(50+100+100)/3] [(100+100+100)/3] [(100+100+100)/3] [(100+100+100)/3]

    50 50 50 67 83 100 100 100

    Now, instead of a sharp transition from 50 to 100 you have a blurry edge that rises from 50 to 67 to 83 then finally 100.

    Sharpening an image can be performed by reversing this process. Instead of adding the light from nearby pixels you subtract light from nearby pixels. Normally this would be done by weighting the pixels but lets use weights of 100 percent to simplify our math:

    [-50+50*3-50] [-50+50*3-67] [-50+67*3-83] [-67+83*3-100] [-83+100*3-100] [-100+100*3-100]

    50 33 68 82 117 100

    As you can see, instead of having a simple sharp transition from 50 to 100, to the left of the edge there is now a dark halo (33) and at the right of the edge there is a bright halo (117). We over sharpened the image. If you sharpen again you'll get even brighter/darker halos. If you continue sharpening you'll eventually get halos around the halos.

    Here's what it looks like visually at 32x enlargement (each 32x32 block of pixels represents one pixel of the source):

    Click image for larger version

Name:	sharpen.png
Views:	2583
Size:	957 Bytes
ID:	1428

    The first line is the original sharp edge. The second line is that sharp edge blurred. The third line is that blurred edge slightly over sharpened. The fourth line is the over sharpened image sharpened again.
    Quote Quote  
  5. Regarding the interlacing issue:

    An interlaced frame contains two separate half images. Here's a 4x enlargement of a portion of a frame where one field is green, the other field red:

    Name:  interlaced.png
Views: 3284
Size:  246 Bytes

    That is easily separated into the two fields by taking every other line of the frame, first the even numbered scanlines, then the odd numbered scanlines:

    Name:  top.png
Views: 3063
Size:  237 Bytes Name:  bottom.png
Views: 3038
Size:  231 Bytes

    If you were to watch that video on an interlaced TV that is exactly what you would see. First the green field (with blank lines in between) then a red field (with black lines in between). In practice the electron beam is not so highly focused so that you can really see those black lines. And they are flashing past at 60 fields per second so you wouldn't perceive them as separate images anyway.

    Now let's resize that interlaced image with a simply bilinear filter:

    Name:  resized.png
Views: 2997
Size:  323 Bytes

    The two fields have become intermixed. Now when we display one field at a time we see this:

    Name:  topx.png
Views: 3028
Size:  258 Bytes Name:  bottomx.png
Views: 3016
Size:  245 Bytes

    You have to be careful when handling interlaced video. Once you have disturbed the integrity of the two fields there is no way to fixing them.
    Quote Quote  
  6. Thank you very much for this explanation. It's much more clear now.

    So, if I understand correctly, it should be possible to correct this by blurring the image:

    50 33 68 82 117 100

    [(50+33+68)/3] [(33+68+82)/3] [(68+82+117)/3] [(82+117+100)/3]

    50 50.33 61 89 99.67 100

    But I'll get something like this:

    http://forum.doom9.org/showthread.php?p=738444#post751380

    don't know if it's better...

    I didn't find the dehalo() function. I just found dehalo_alpha here : http://avisynth.org/mediawiki/DeHalo_alpha

    I also had a look at some .avs script like this one: http://forum.doom9.org/showthread.php?p=803275

    but there are always missing functions when I try to execute the script and I cannot find all the dll required..
    Quote Quote  
  7. I just saw you answer about interlacing issue

    How did you notice this problem in the picture I posted? The bad lines at the top?
    Quote Quote  
  8. Member
    Join Date
    Jan 2007
    Location
    Republic of Texas
    Search Comp PM
    This is more than just an interlacing issue, and it cannot be remedied. The "ghost" outlines around the edges of your subject are the result of multi-generation VHS-to-VHS dubbing. You could try deinterlacing until the cows came home and it still would not help.
    Quote Quote  
  9. The Dehalo Alpha you found tells you it requires the MaskTools and Degrain packages. You have to download and install them too. A little googling should find them. One good place to start is here:

    http://avisynth.org/warpenterprises/

    The sample image you posted was very badly degraded but the side-by-side separated fields showed the artifacts one would expect from contaminated fields (some combing still left in the separated frames).

    Regarding multigenerational VHS copying:

    VHS tape is an inherently low resolution (horizontally) format. VHS decks try to compensate for this by applying a sharpening filter during playback. Over sharpening once doesn't hurt too much. But when you copy a VHS tape onto another VHS tape you get another generation of over sharpening. Each time you repeat this you get more over sharpening.

    Another issue is the scale of the halo. A wide halo requires a wide de-halo algorithm. Your halos are at least two pixels wide. You may get better results by reducing the frame size by half horizontally before applying any dehalo filters. Note that VHS's horizontal resolution is in the 350 pixel range so working at 360x480 or 352x480 is closer to the source's true resolution, and closer to the resolution of the halo artifacts.
    Last edited by jagabo; 21st Apr 2010 at 08:44.
    Quote Quote  
  10. Originally Posted by jagabo View Post
    The Dehalo Alpha you found tells you it requires the MaskTools and Degrain packages. You have to download and install them too. A little googling should find them. One good place to start is here:

    http://avisynth.org/warpenterprises/
    Yes I added these library but I still miss the Prewitt() function.

    And I also get this error: integrity overflow (line 37)

    with this script:

    Code:
    ImageSource("dallas1.bmp")
    BlindDeHalo3( rx=3.0, ry=3.0, strength=125, 
     \            lodamp=0.0, hidamp=0.0, sharpness=0.0, tweaker=0.0,
     \            PPmode=0, PPlimit=0, interlaced=false)
    
    function BlindDeHalo3( clip clp, float "rx", float "ry", int "strength",
     \                     float "lodamp", float "hidamp", float "sharpness", float "tweaker",
     \                     int "PPmode", int "PPlimit", bool "interlaced")
    {
    rx =         default( rx,           3.0 )
    ry =         default( ry,           3.0 )
    strength =   default( strength,     125 )
    lodamp =     default( lodamp,       0.0 )
    hidamp =     default( hidamp,       0.0 )
    sharpness =  default( sharpness,    0.0 )
    tweaker =    default( tweaker,      0.0 )
    PPmode =     default( PPmode,         0 )
    PPlimit =    default( PPlimit, (abs(PPmode)==3) ? 4 : 0 )
    interlaced = default( interlaced, false )
    
    sharpness = (sharpness>1.58) ? 1.58 : sharpness
    tweaker   = (tweaker > 1.00) ? 1.00 : tweaker
    strength  = float(strength)*(1.0+sharpness*0.25)
    RR   = string((rx+ry)/2.0)
    ST   = string(float(strength)/100.0)
    LD   = string(lodamp)
    HD   = string(pow(hidamp,2))
    TWK0 = "x y - 12 "+ST+" / "+RR+" / /"
    TWK  = "x y - 12 "+ST+" / "+RR+" / / abs"
    TWK_HLIGHT = "x y - abs 1 < 128 "+TWK+" 128 "+TWK+" - "+TWK+" 128 / * + "+TWK0+" "+TWK+" "+LD+" + / * "
     \         + "128 "+TWK+" - 20 / 2 ^ 128 "+TWK+" - 20 / 2 ^ "+HD+" + / * 128 + ?"
    
    i     = (interlaced==false) ? clp : clp.separatefields()
    oxi   = i.width
    oyi   = i.height
    sm    = i.bicubicresize(m4(oxi/rx),m4(oyi/ry))
    mm    = mt_lutxy(sm.mt_expand(),sm.mt_inpand(),"x y - 4 *").mt_expand().mt_deflate().blur(1.58).mt_inflate().bicubicresize(oxi,oyi,1.0,.0).mt_inflate()
    sm    = sm.bicubicresize(oxi,oyi,1.0,.0)
    smd   = mt_lutxy(i.sharpen(tweaker),sm,TWK_HLIGHT)
    smd   = (sharpness==0.0) ? smd : smd.blur(sharpness)
    clean = mt_lutxy(i,smd,yexpr="x y 128 - -").mergechroma(i)
    clean = mt_merge(i,clean,mm)
    
    LL    = string(PPlimit)
    LIM   = "x "+LL+" + y < x "+LL+" + x "+LL+" - y > x "+LL+" - y ? ?"
    
    base  = (PPmode<0) ? i : clean
    small = base .bicubicresize(m4(oxi/sqrt(rx*1.5)),m4(oyi/sqrt(ry*1.5)))
    ex1   = small.mt_expand().blur(.5)
    in1   = small.mt_inpand().blur(.5)
    hull  = mt_logic( mt_lutxy( ex1.mt_expand().RemoveGrain(12,-1), ex1, "x y - 1 1 / * 1.0 ^ 1 - 5 *" )
     \               ,mt_lutxy( in1, in1.mt_inpand().RemoveGrain(12,-1), "x y - 1 1 / * 1.0 ^ 1 - 5 *" )
     \               ,"max", U=-128, V=-128)
     \     .bicubicresize(oxi,oyi,1.0,.0)
    
    postclean = (abs(PPmode)== 1) ?  mt_merge(base,small.bicubicresize(oxi,oyi,1.0,.0),hull,Y=3,U=2,V=2)
     \        : (abs(PPmode)== 2) ?  mt_merge(base,base.RemoveGrain(19,-1),hull,Y=3,U=2,V=2)
     \        : (abs(PPmode)== 3) ?  mt_merge(base,base.RemoveGrain(4,-1),hull,Y=3,U=2,V=2)
     \        :                      clean
    
    postclean = (PPlimit==0) ?  postclean
     \        :                 mt_lutxy(base,postclean,yexpr=LIM,U=2,V=2)
    
    (PPmode==0) ? clean   : postclean
    interlaced  ? weave() : last
    
    return( last )
    }
    #---------------------------------------------------------
    function m4(float x) {return(x<16?16:int(round(x/4.0))*4)}
    Quote Quote  
  11. You probably have the wrong version of some of the filters. Prewitt looks to be part of a recent modification of MaskTools2.

    http://avisynth.org/mediawiki/MaskTools2/Mt_edge
    Quote Quote  
  12. I tried these versions:

    http://manao4.free.fr/MaskTools-v1.5.8.zip
    http://manao4.free.fr/masktools-v2.0a38.zip
    http://avisynth.org/warpenterprises/files/masktools_20070805.zip

    but none of them seems to have the prewitt() function...

    I managed to make Dehalo_Alpha work but it doesn't remove the halos, it only blurs the whole image..

    If you want to have a try, you can download a short sample of the video here: http://www.mediafire.com/?ydywionmkzy
    Quote Quote  
  13. That video is hopeless.
    Quote Quote  
  14. ok

    Thank you
    Last edited by mathmax; 21st Apr 2010 at 10:48.
    Quote Quote  
  15. I suspected... but at least I know the problem now.

    And the interlacing issue, was it the problem you diagnosed?
    Quote Quote  
  16. Originally Posted by mathmax View Post
    And the interlacing issue, was it the problem you diagnosed?
    Yes, the two fields are not intact.
    Quote Quote  
  17. How do you noticed that? I mean, what are the effects? The bad lines at the top of the video?
    Quote Quote  
  18. Actually, I take that back. It looks like the two fields are intact but the video is in such poor shape it's hard to tell. Normally you use a simple Bob or discard field detinterlace and look at the results. If you still see combing artifacts the two fields are not intact.

    Here's a simple filter sequence that clears out most of the halos but leaves the video very blurry:

    BilinearResize(160,480)
    Blur(1,0)
    BicubicResize(720,480)
    Quote Quote  
  19. Originally Posted by jagabo View Post
    Normally you use a simple Bob or discard field detinterlace and look at the results. If you still see combing artifacts the two fields are not intact.
    Sounds like Chinese for me.. What does "combing artifacts" means ? The bad lines at the top? And I don't understand after which operation they should disappear if the fields are intacts.

    Here's a simple filter sequence that clears out most of the halos but leaves the video very blurry:

    BilinearResize(160,480)
    Blur(1,0)
    BicubicResize(720,480)
    ok.. and I guess it's not possible to keep a "sharp" video and remove the halos at the same time, is it? Maybe it's possible to only blur the edges..?
    Last edited by mathmax; 21st Apr 2010 at 14:06.
    Quote Quote  
  20. Comb artifacts:
    Click image for larger version

Name:	comb.png
Views:	2512
Size:	85.8 KB
ID:	1450

    because the frame contains two half pictures:
    Click image for larger version

Name:	half.gif
Views:	2477
Size:	298.2 KB
ID:	1451

    bobbed to fill in the black lines:
    Click image for larger version

Name:	bob.gif
Views:	2442
Size:	527.7 KB
ID:	1452

    Regarding the removal of halos, some mix of resizing and dehalo filters, probably with multiple instances of each, may work better. I'll leave that up to you.
    Last edited by jagabo; 21st Apr 2010 at 20:24.
    Quote Quote  
  21. Member
    Join Date
    Jun 2002
    Location
    Redding, California
    Search Comp PM
    I've seen simular results when an SVHS recording was palyed back on a VHS player.

    To save money, people used to drill a hole at the end of the grove on the bottom of the cassette to record SVHS on a standard VHS tape.

    Is there a hole?
    Quote Quote  
  22. Regarding the removal of halos, some mix of resizing and dehalo filters, probably with multiple instances of each, may work better. I'll leave that up to you.
    Why resizing ?

    Megahurts, I'm sorry I don't understand what you mean..
    Quote Quote  
  23. Originally Posted by mathmax View Post
    Regarding the removal of halos, some mix of resizing and dehalo filters, probably with multiple instances of each, may work better. I'll leave that up to you.
    Why resizing ?
    Because dehalo filters are designed to remove halos that are about a single pixel thick. The low bandwidth of VHS tape means the horizontal resolution is closer to 350 pixels than 720 pixels. That means the halos are roughly two pixels wide when captured at 720 pixels. Then when a VHS tape is copied over and over the halos widen, become more severe, and you get halos around the halos. To undo this you may have to run several dehalo passes at the resolution the halos were produced.
    Quote Quote  
  24. Far too goddamn old now EddyH's Avatar
    Join Date
    Jan 2003
    Location
    Soul sucking suburbia! But a different part since I last logged on.
    Search Comp PM
    Originally Posted by mathmax View Post
    How do you noticed that? I mean, what are the effects? The bad lines at the top of the video?
    Nope - its in how you can see the combed lines are quite sharp and distinct in places, and blurred completely together in others, in a fairly regular vertical pattern. Once you've seen it happen a few times it's distinctive. Somewhere between the original recording and the image you uploaded, the video has been improperly resized.
    (I've seen it particularly bad on an anime DVD that was cack-handedly converted to PAL from telecined-NTSC... you could even see artefacts on the CRT TV I first played it on - and forget about making a clean AVI conversion of it. Ended up buying a better quality re-release from a different publisher - very lucky that such a thing even existed, mind, and they changed the audio!)

    Question: What is the original format of the tape? You're showing us a full-size NTSC capture (including the lower twin images that are the two seperate fields)... did it start life as such? My suspicion is it may have been a PAL recording, which doubles up the hurt if improperly handled. First you have a lot of (originally temporally as well as spatially separate) lines being mashed into each other on each field, and then you have the framerate conversion - probably also mishandled - complicating matters.

    The proper way to deal with the two would be to convert to full-frame, 720x576, 50hz video (so doubling up, with each frame having one field different), run some kind of trick deinterlacer, resizer and motion interpolation filter (my brain hasn't the strength to fully explain or research this right now ) and backconvert to your intended format (29.97/59.94 hz interlaced at 720x480). Or at very least, seperate the fields (720x288 50hz), do a simple resize of both sets to 720x240, and pile them back together with an occasional single-field duplication and switching of field order (NB this causes further headaches later...)
    And that's without even dealing with the haloing issue.

    (BTW as VHS is an analogue format, dropping it to 352 PIXELS across and then back up again may cause noticable quantisation effects even so - is there no halo filter that can have the width expanded instead? Particularly as the dividing line may end up sitting halfway across a pixel, then. The clarity is low, but there's an infinite range of positions available)

    What's been done instead is that the entire 2-field frame has been dropped into the editor, bilinear resized to 5/6ths of its previous size, probably had every 5th whole frame duplicated (maybe even without the requisite 1000/1001 drop, so the sound's noticably desynched after a few minutes), and then rewritten out. Possibly the output of a very primitive hardware frame converter, if the tape itself has reached you with these artefacts still in place. Assuming I'm correct about the origins that is
    Last edited by EddyH; 22nd Apr 2010 at 08:49.
    -= She sez there's ants in the carpet, dirty little monsters! =-
    Back after a long time away, mainly because I now need to start making up vidcapped DVDRs for work and I haven't a clue where to start any more!
    Quote Quote  
  25. BlindDehalo3() does support independent halo thickness settings on both the x and y axis, as well as a strength setting. Since this is a multigenerational VHS copy you need multiple passes to get rid of multiple halos. I found two passes of BlindDehalo3(rx=7, ry=1, strength=200) (at the original 720x480 resolution) comes close to eliminating the severe halo around the guitarist's legs. But it leaves the video very blurry, similar to the Blur() method I pointed out earlier. Obviously, you could choose to use a compromise setting that leaves some halos but also leaves the video sharper. Fixing the levels will help too.

    Frame 73, original:
    Click image for larger version

Name:	orig.jpg
Views:	2191
Size:	63.3 KB
ID:	1459

    After:
    MPEG2Source("VTS_01_3.demuxed.d2v")
    Levels(40,1,255,0,255)
    BlindDehalo3(rx=7, ry=1, strength=100)
    BlindDehalo3(rx=7, ry=1, strength=100)
    ConvertToYUY2(interlaced=true)
    Click image for larger version

Name:	s100.jpg
Views:	2055
Size:	48.9 KB
ID:	1460

    After:
    MPEG2Source("VTS_01_3.demuxed.d2v")
    Levels(40,1,255,0,255)
    BlindDehalo3(rx=7, ry=1, strength=200)
    BlindDehalo3(rx=7, ry=1, strength=200)
    ConvertToYUY2(interlaced=true)
    Click image for larger version

Name:	s200.jpg
Views:	1966
Size:	43.5 KB
ID:	1461
    Last edited by jagabo; 22nd Apr 2010 at 09:06.
    Quote Quote  
  26. Thank you very much for your answer EddyH

    Originally Posted by EddyH View Post
    Question: What is the original format of the tape? You're showing us a full-size NTSC capture (including the lower twin images that are the two seperate fields)... did it start life as such? My suspicion is it may have been a PAL recording, which doubles up the hurt if improperly handled.
    I don't know anything about the history of this tape.. I just got the digitalized files.

    Originally Posted by EddyH View Post
    First you have a lot of (originally temporally as well as spatially separate) lines being mashed into each other on each field, and then you have the framerate conversion - probably also mishandled - complicating matters.
    I would really like to see exactly what you mean. Where are these mashed lines? Could you give me the lines and frames numbers?

    Originally Posted by EddyH View Post
    The proper way to deal with the two would be to convert to full-frame, 720x576, 50hz video (so doubling up, with each frame having one field different), run some kind of trick deinterlacer, resizer and motion interpolation filter (my brain hasn't the strength to fully explain or research this right now ) and backconvert to your intended format (29.97/59.94 hz interlaced at 720x480).
    Ok but why you wanna resize it and change the frame rate? Is it necessary to run a deinterlacer or a motion interpolation filter? What are you hopping to fix with the motion interpolation filter?

    Originally Posted by EddyH View Post
    Or at very least, seperate the fields (720x288 50hz), do a simple resize of both sets to 720x240, and pile them back together with an occasional single-field duplication and switching of field order (NB this causes further headaches later...)
    Do you think some fields are missing causing a wrong order in some passages (bottom field in first, top field in second)? Or I didn't understand the problem?

    Originally Posted by EddyH View Post
    What's been done instead is that the entire 2-field frame has been dropped into the editor, bilinear resized to 5/6ths of its previous size, probably had every 5th whole frame duplicated (maybe even without the requisite 1000/1001 drop, so the sound's noticably desynched after a few minutes), and then rewritten out. Possibly the output of a very primitive hardware frame converter, if the tape itself has reached you with these artefacts still in place. Assuming I'm correct about the origins that is
    How can you guess this?
    But I didn't noticed the sound's desynched...

    Sorry to ask all these questions but I'm pretty novice with all that techniques. And I would really like to know more..

    jagabo, thank you for your tests. It's still very blurry but we needn't to resize with this function. I guess it's better... but can we still hope better results with other scripts?
    Quote Quote  
  27. EddyH is talking about poor PAL to NTSC conversions. It's hard to tell exactly with your sample because of the time base errors, blurriness, macroblock artifacts, and halos. But I don't see any convincing evidence of poor resizing from 576 lines to 480 lines, temporal blending of fields, or missing/duplicate frame/fields from frame rate conversion.
    Quote Quote  
  28. Hi

    Is there a way to sharpen the video in one direction (horizontally) after I blur it to get rid of the halos?
    Quote Quote  
  29. sharpen(horizontal,vertical)

    e.g.
    sharpen(1,0)

    weren't you using masks & blurring , or was that someone else at doom9
    Quote Quote  
  30. Thank you

    yes that's me.
    Quote Quote  



Similar Threads

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