Go Back    Forum > Digital Video > Video Project Help > Restore, Filter, Improve Quality

Reply
 
LinkBack Thread Tools
  #1  
04-25-2022, 03:22 PM
London London is offline
Free Member
 
Join Date: Oct 2020
Location: London, UK
Posts: 48
Thanked 11 Times in 9 Posts
I use a script for cleaning the green staining on the right edge that typically occurs when Hi8 tapes are digitized with Sony Handycams.

Today I have a VHS tape, which as far as I am aware is a master recording, on Fuji Super XG Pro 180 VHS Tape, PAL. I am 95% certain it is the original and did not come from Hi8. Anyway, it has green staining on the right border.

The script I normally use to clean the stain is causing magenta staining. Most noticeable on frames 430 to 440 in the attached clip. This is the script:-

Code:
U = UtoY() # separate U channel
V = VtoY() # separate V channel
V = Crop(V,0,0,-16,-0) #remove discoloured portion and black border
extra=FlipHorizontal(V).Crop(0,0,12,-0) # the last 12 pixels of the V channel reflected 
  ###ALTERNATIVELY stretch the last good pixels of chroma rather than reflecting, by changing the "extra" line to: 
#extra=Crop(V,342,0,2,-0).PointResize(12,V.height)
V=StackHorizontal(V,extra).AddBorders(0,0,4,0,$808080) # add the extra, pad to 720 with grey
YtoUV(U, V, last) # mix the separate U and V with the original Y
If I unhash and use the Alternative 'extra' it produces better results but the magenta staining is still apparent:-
Code:
U = UtoY() # separate U channel
V = VtoY() # separate V channel
V = Crop(V,0,0,-16,-0) #remove discoloured portion and black border
extra=Crop(V,342,0,2,-0).PointResize(12,V.height)
V=StackHorizontal(V,extra).AddBorders(0,0,4,0,$808080) # add the extra, pad to 720 with grey
YtoUV(U, V, last) # mix the separate U and V with the original Y
I have temporarily hashed out the Crop and Add Borders at the end of my full script (below) to show the staining more clearly.

I have never understood what this script is doing or how it works, but I would really like some advise on what values I can change. If I change a single number it creates an error so I am lost for what I can change in that script. A breakdown explanation of what the above script is doing would be very helpful.

My full script:-

Code:
function Levels_mod(clip c, int "input_low", float "gamma", int "input_high", int "output_low", int "output_high", bool "coring", bool "dither")
{
return c.Levels(default(input_low, 0),
\		default(gamma, 1.0),
\		default(input_high, 255),
\		default(output_low, 0),
\		default(output_high, 255),
\		default(coring, true),
\		default(dither, false))
}

function LevelsLumaOnly(clip c,
\                       int "input_low", float "gamma", int "input_high",
\                       int "output_low", int "output_high", bool "coring", bool "dither")
{
    return MergeChroma(c.Levels_mod(input_low=input_low, gamma=gamma, input_high=input_high,
    \                           output_low=output_low, output_high=output_high, coring=coring, dither=dither),
    \                  c)
}

# Classic Histogram and Levels Histogram
function ClassicAndLevelsHistogram(clip video)
{
  classic = video.TurnRight().Histogram().TurnLeft().crop(0,0,-0,256)
  levels = video.Histogram("levels").crop(video.width,0,-0,256)
  classic_and_levels = stackhorizontal(classic, levels) # stack classic and levels horizontally
  video2 = video.addborders(0,0,classic_and_levels.width-video.width,0) # add a black border to side of the video to match the width of "both"
  stackvertical(classic_and_levels, video2) # stack the analytics over the video
}



SetFilterMTMode("QTGMC", 2) 
AviSource("2022.04.25a - Lagarith Clip.avi", atrack=0)
AssumeTFF() 

### ----------REMOVE GREEN STAINING FROM THE RIGHT HAND EDGE
U = UtoY() # separate U channel
V = VtoY() # separate V channel
V = Crop(V,0,0,-16,-0) #remove discoloured portion and black border
extra=FlipHorizontal(V).Crop(0,0,12,-0) # the last 12 pixels of the V channel reflected 
  ###ALTERNATIVELY stretch the last good pixels of chroma rather than reflecting, by changing the "extra" line to: 
#extra=Crop(V,342,0,2,-0).PointResize(12,V.height)
V=StackHorizontal(V,extra).AddBorders(0,0,4,0,$808080) # add the extra, pad to 720 with grey
YtoUV(U, V, last) # mix the separate U and V with the original Y

### ----------ADJUST LEVELS  
#Levels(10, 1.0, 245, 16, 235, coring=false, dither=true) 
LevelsLumaOnly(5, 1.0, 240, 16, 235, coring=false, dither=true) 

### ----------ADJUST BRIGHTNESS, SATURATION AND HUE  
Tweak(hue=0.0, sat=1.05, bright=-8, cont=1.05, coring=False, sse=False, startHue=0, endHue=360, maxSat=150, minSat=0, interp=16)

###  ----------DEINTERLACE 
QTGMC(Preset="Slower", Edithreads=4) 

### ----------CROP TEMPORARILY FOR HISTOGRAM CHECK
#Crop(20,12,-20,-20) # HASH OUT THIS TEMPORARY CROP AFTER HISTOGRAM CHECK
#
### ----------CONVERT TO YV12 COLOURSPACE 
#ConvertToYV12(interlaced=false, matrix="PC.601")  
#
###  ----------ADJUST LUMA, RED, GREEN AND BLUE WHILST VIEWING HISTOGRAMS 
#ColorYUV(analyze=true)  
#ColorYUV(off_y=0, off_u=0, off_v=-5) 
#
#ClassicAndLevelsHistogram()


#Crop(12,0,-12,-12) 
#AddBorders(4,4,4,8) 

#ClassicAndLevelsHistogram() # (final check of levels with Crop and Add Borders) 

Prefetch(14)


Attached Files
File Type: avi 2022.04.25a - Lagarith Clip.avi (70.74 MB, 7 downloads)
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
04-26-2022, 05:43 AM
themaster1 themaster1 is offline
Free Member
 
Join Date: Feb 2011
Location: France
Posts: 509
Thanked 104 Times in 88 Posts
I think i got it covered

Quote:
AVISource("2022.04.25a - Lagarith Clip.avi")
assumetff()
coloryuv(cont_u=7,cont_v=90,gamma_y=-25,autogain=true)
converttoyv12(interlaced=true)
qtgmc("fast",edithreads=4)
selecteven()

# Green edge removal (Hi-8)

U = UtoY() # separate U channel
V = VtoY() # separate V channel
V = Crop(V,0,0,-16,-0) #remove discoloured portion and black border
extra=Crop(V,342,0,2,-0).PointResize(12,V.height)
V=StackHorizontal(V,extra).AddBorders(0,0,4,0,$808 080) # add the extra, pad to 720 with grey
YtoUV(U, V, last) # mix the separate U and V with the original Y

The green removal part does the magic i just don't fully understand it either; you basically crop (16 pixels on the right) the green part of the V channel and you color adjust it. Why you crop 342 pixels, the video now being 704 pixels wide..no idea.

The most subtle part: you add a border with an hex value of #808080 and this value in HSL = hue: 0.00 , saturation: 0.00, lightness: 0.50 / RGB value: 128,128,128

Someone will explain to us i'm sure


Attached Images
File Type: jpg og.jpg (35.9 KB, 18 downloads)
File Type: jpg fixed.jpg (39.4 KB, 18 downloads)
Reply With Quote
The following users thank themaster1 for this useful post: London (04-26-2022)
  #3  
04-26-2022, 07:03 AM
lollo2 lollo2 is offline
Free Member
 
Join Date: Mar 2013
Location: Italy
Posts: 673
Thanked 189 Times in 163 Posts
THe origin of that script is here: https://forum.videohelp.com/threads/...VHS-capture%29

A channel on S-VHS / VHS capture and AviSynth restoration https://bit.ly/3mHWbkN
Reply With Quote
The following users thank lollo2 for this useful post: London (04-26-2022)
  #4  
04-26-2022, 07:24 AM
themaster1 themaster1 is offline
Free Member
 
Join Date: Feb 2011
Location: France
Posts: 509
Thanked 104 Times in 88 Posts
Exactly where i picked it up yep. Silly me, we're working on U,V so half the resolution(~360), i should have known that
Reply With Quote
The following users thank themaster1 for this useful post: lollo2 (04-26-2022)
  #5  
05-01-2022, 09:54 AM
Selur Selur is offline
Free Member
 
Join Date: Feb 2022
Posts: 79
Thanked 20 Times in 18 Posts
Cropping followed by BalanceBordersMod (bbmod) also works fine.


Cu Selur
Reply With Quote
The following users thank Selur for this useful post: London (05-01-2022)
  #6  
05-01-2022, 01:40 PM
London London is offline
Free Member
 
Join Date: Oct 2020
Location: London, UK
Posts: 48
Thanked 11 Times in 9 Posts
Quote:
Originally Posted by lollo2 View Post
Thanks Lollo, that is an interesting thread. Jagabo seems to have developed the script and it now only requires 1 value to be set called EDGE_SIZE. Much simpler to use now.

Code:
EDGE_SIZE = 22

AviSource("2022.04.25a - Lagarith Clip.avi", atrack=0) 

cropped = Crop(0,0,-EDGE_SIZE,-0)
extra = cropped.FlipHorizontal().Crop(0,0,EDGE_SIZE,-0)
chroma = StackHorizontal(cropped, extra)
MergeChroma(last, chroma)
Setting EDGE_SIZE to 22 cleaned up the right border on my clip.
Reply With Quote
  #7  
05-01-2022, 01:47 PM
London London is offline
Free Member
 
Join Date: Oct 2020
Location: London, UK
Posts: 48
Thanked 11 Times in 9 Posts
Quote:
Originally Posted by Selur View Post
Cropping followed by BalanceBordersMod (bbmod) also works fine.


Cu Selur
Thanks Selur. The image is missing from your post. I couldn't find BalanceBordersMod for AviSynth, it it a VapourSynth only script?
Reply With Quote
  #8  
05-01-2022, 01:56 PM
Selur Selur is offline
Free Member
 
Join Date: Feb 2022
Posts: 79
Thanked 20 Times in 18 Posts
Image works fine when I click on it, but I also attached it now. (had to zip it to prevent the board software from converting the png to jpg)
Regarding bbmod: https://github.com/Asd-g/AviSynthPlu.../bborders.avsi
(it's also ported to Vapoursynth as part of havsfunc)

Cu Selur


Attached Files
File Type: zip Balance-Borders.zip (1.13 MB, 6 downloads)
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
VHS cleaning script, lost in colorspace? chrisbati Restore, Filter, Improve Quality 5 09-01-2021 02:03 PM
Problems with Hauppauge USB-Live2 black border? mbassiouny Capture, Record, Transfer 5 06-16-2021 04:55 AM
VHS head switching and border? leroysmith12 General Discussion 4 08-17-2019 06:28 PM
VirtualDub border masking? (not cropping!) friendly_jacek Edit Video, Audio 38 09-21-2018 03:34 PM
Why is there a black border around my video? (JVC DR-MH30) quarkz Capture, Record, Transfer 6 01-07-2013 10:58 PM




 
All times are GMT -5. The time now is 05:50 PM