04-25-2022, 03:22 PM
|
|
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)
|
Someday, 12:01 PM
|
|
Ads / Sponsors
|
|
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
|
|
|
04-26-2022, 05:43 AM
|
|
Free Member
|
|
Join Date: Feb 2011
Location: France
Posts: 553
Thanked 120 Times in 104 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
|
The following users thank themaster1 for this useful post:
London (04-26-2022)
|
04-26-2022, 07:03 AM
|
|
Free Member
|
|
Join Date: Mar 2013
Location: Italy
Posts: 676
Thanked 193 Times in 165 Posts
|
|
A channel on S-VHS / VHS capture and AviSynth restoration https://bit.ly/3mHWbkN
|
The following users thank lollo2 for this useful post:
London (04-26-2022)
|
04-26-2022, 07:24 AM
|
|
Free Member
|
|
Join Date: Feb 2011
Location: France
Posts: 553
Thanked 120 Times in 104 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
|
The following users thank themaster1 for this useful post:
lollo2 (04-26-2022)
|
05-01-2022, 09:54 AM
|
|
Free Member
|
|
Join Date: Feb 2022
Posts: 102
Thanked 23 Times in 21 Posts
|
|
Cropping followed by BalanceBordersMod (bbmod) also works fine.
Cu Selur
|
The following users thank Selur for this useful post:
London (05-01-2022)
|
05-01-2022, 01:40 PM
|
|
Free Member
|
|
Join Date: Oct 2020
Location: London, UK
Posts: 48
Thanked 11 Times in 9 Posts
|
|
Quote:
Originally Posted by lollo2
|
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.
|
05-01-2022, 01:47 PM
|
|
Free Member
|
|
Join Date: Oct 2020
Location: London, UK
Posts: 48
Thanked 11 Times in 9 Posts
|
|
Quote:
Originally Posted by Selur
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?
|
05-01-2022, 01:56 PM
|
|
Free Member
|
|
Join Date: Feb 2022
Posts: 102
Thanked 23 Times in 21 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
|
All times are GMT -5. The time now is 04:06 PM
|