View Single Post
Old 28th March 2021, 10:47   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by Mounir View Post
English please ?
Part 1 [Copy/Paste]
Code:
# StrongHaloGhostDeconvolution.avs : Emulgator :: https://forum.doom9.org/showthread.php?t=182604

#€€€€€€€€€€€€€€€€€€€€€€€€   Start of Emulgator's Avisynth Bergwerk "StrongHaloGhostDeConvolution.avs" from 2021-03-26   €€€€€€€€€€€€€€€€€€€€€€€€€€€
# ------------------------- (This is the snippet by .mp4guy from where it started) ----------
# string1 = string(" 0 -20 28 -32 36 36 128 128 72 -56 12 12 -4 ")
# mt_convolution(horizontal=" "+string(string1)+" ", vertical=" 1 ", u=3, v=3)
# ----------------------------------------------------------------------------------------
# StrongHaloGhostDeConvolution.avs
# 2021-03-26 by Emulgator
#
# Das vorliegende Script arbeitet in AviSynth64 (getestet ab 3.6.2) mit 16 bit Auflösung und befaßt sich erfolgreich mit der Auskompensation
# von besonders groben Schärfungs-oder Echoartefakten, wie sie bei Video-Aufzeichnungen früher Analog-Camcorder auftraten.
# Die Anwendung bisher üblicher De-Halo-Algorithmen konnte dort nicht befriedigen, da diese i.d.R. nicht imstande sind,
# Halos größerer Ausdehnung ohne starken Detailverlust zu bekämpfen.
# ssS:
# This script works in AviSynth64 (tested from 3.6.2) with 16 bit resolution and deals successfully with the compensation
# of particularly coarse sharpening or echo artifacts, such as those that occurred with video recordings in earlier analog camcorders.
# The application of the previously common de-halo algorithms could not be satisfactory there, as these are usually not able to
# Combat halos of larger dimensions without losing a great deal of detail.
# ----------------------
# Lösungsansatz: Verwendung von Punkt für Punkt manuell angepaßten Faltungsfiltern größerer Länge.
# In der Regel treten Analog-Schärfungs-oder Echoartefakte kausalitätsbedingt zeitlich immer nach einem auslösenden Ereignis auf,
# bei rechtslaufender Scanrichtung also einer Kante rechts nachfolgend.
# Damit ist ein asymmetrischer Korrekturkernel zu erwarten, welcher hauptsächlich Anzapfungsfaktoren links vom aktuellen Pixel besetzt.
# (Eine analytische Lösung wird hier nicht a priori versucht, steht aber jedem offen, der dies versuchen will.)
# ssS:
# Approach to a solution: Use of convolution filters of greater length that are manually adapted point by point.
# As a rule, analog sharpening or echo artifacts always occur after a triggering event due to their causality,
# with a clockwise scan direction following an edge to the right.
# This means that an asymmetrical correction kernel is to be expected, which mainly occupies tapping factors to the left of the current pixel.
# (An analytical solution is not attempted a priori here, but is open to anyone who wants to try it.)
#
# Eine prinzipbedingte Eigenheit der mt_convolution unter AviSynth ergibt, daß das Ergebnisvideo in YUV keine negativen Werte enthalten kann.
# Daraus ergab sich die Notwendigkeit einer betragsorientierten Aufteilung der Korrektur in 2 Kompensationsvorgänge:
# Der erste Korrekturgang arbeitet mit den Beträgen der positiv ausfallenden 1. horizontalen Ableitungen,
# der zweite mit den Beträgen der negativ ausfallenden 1. horizontalen Ableitungen.
# Dies bedient 1. die Notwendigkeit der vollständigen vorherigen Auskompensation
# der ansonsten erneut fehlereinbringenden Rückgangsflanken der Fehlerantwort aus positiven Gradienten.
# Erst dann kann im 2. Pass die Suche nach "echten" (im gewünschten Bildinhalt befindlichen) negativen Gradienten beginnen.
# (Das Problem existiert umgekehrt zwar auch, tritt aber in dieser Reihenfolge nicht so prominent auf.)
# 2. Dabei erarbeitet man sich  "en passant" den Luxus der nun für positive und negative Gradienten getrennt verfügbaren Parametrierung.
# ssS:
# A principle-related peculiarity of mt_convolution under AviSynth shows that the result video in YUV cannot contain negative values.
# This made it necessary to divide the correction into 2 compensation processes based on the amount:
# The first correction process works with the amounts of the positive 1st horizontal derivatives,
# the second with the amounts of the negative first horizontal derivatives.
# This serves 1. the need for full prior compensation
# of the falling edges of the error response from positive gradients that would otherwise again introduce errors.
# Only then can the search for "real" negative gradients (in the desired image content) begin in the 2nd pass.
# (The problem also exists the other way round, but does not occur so prominently in this order.)
# 2. In doing so, the luxury of parameterization, which is now separately available for positive and negative gradients, is worked out "en passant".
# --------------------------
# Ermitteln der geeigneten Filterfolge:
# Quellvideo -> Abspalten Hilfsvideo -> Farbraum-Reduktion auf Y16
# -> Bilden der Beträge der positiv ausfallenden räumlichen 1.Ableitung in horizontaler Richtung = scharfes positives Ableitungsvideo
# -> Manuelles Vorformen einer primitiven Kompensationsfunktion durch Faltungsvektor
# -> Globale Vor-Skalierung des Überlagerungsfaktors per Gain = geglättetes positives Ableitungsvideo
# -> probeweise Überlagerung (Overlay) des geglätteten positiven Ableitungsvideos auf das Quellvideo
# -> Probeweises Schieben über die passende x-Bezugsspalte <-> Ausprobieren der Anzapfungsorte im Faltungsvektor
# <-> probeweise x-Verschiebungskorrektur im Overlay <-> finale Anpassung der Anzapfungspegel im Faltungsvektor unter Kontrolle im Overlay.
# ss:
# Determine the appropriate filter sequence:
# Source video -> splitting auxiliary video -> color space reduction to Y16
# -> Formation of the amounts of the positive spatial 1st derivative in the horizontal direction = sharp positive derivative video
# -> Manual preforming of a primitive compensation function using a convolution vector
# -> Global pre-scaling of the superimposition factor per gain = smoothed positive derivative video
# -> trial overlay of the smoothed positive derivative video on the source video
# -> Trial slide over the appropriate x reference column <-> Trying out the tapping locations in the convolution vector
# <-> trial x-shift correction in the overlay <-> final adjustment of the tap level in the convolution vector under control in the overlay.
# ---------------------------
# Vorbereitung: Ermitteln der Halofehler-Ausdehnung d, danach die Faltungs-Matrix und Größe mindestens (2*d)+1  vorgeben.
# Ersteckt sich also ein Halofehler horizontal über 14 Pixel, gibt man einen 29 Parameter langen Vektor in x-Richtung vor.
# Dann werden die Anzapfungwerte sukzessiv durch Probieren mit Anfangswert Mittelanzapfung = 1 ermittelt.
# Erst wenn der erste Teil perfekt auskompensiert ist, wird der 2.Teil gelingen !
# ssS:
# Preparation: Determine the halo error extension d, then specify the convolution matrix and size at least (2 * d) +1.
# If a halo error extends horizontally over 14 pixels, a 29 parameter long vector is given in the x direction.
# Then the tap values ​​are successively determined by trial and error with the initial value mean tap = 1.
# Only when the first part is perfectly compensated, the second part will succeed!
# ---------------------------
# Bildfehleranalyse
# Die unbekannte Videoquelle war vermutlich eine frühe Amateur-SONY im Handtaschenformat.
# Diese Cam A wird "PAL-Stronghalo" benannt.
# Einer der zuerst auszukompensierenden Hauptfehler des vorliegenden PAL-Videos:
# Der zu kompensierende Fehler taucht nur in der Y-Komponente auf
# und folgt der 1.Ableitung von Y, die invertiert 7 Pixel später als negiertes und verschmiertes Echo auftaucht.
# Positive und negative Gradienten tauchen verschieden verschmiert auf, die Gesamtfehlerlänge erstreckt sich jeweils über 14 horizontale Pixel.
# Fehlerlänge 1% der PAL-Zeilenlänge Zeilenfrequenz 1MHz/64 = 15625Hz 64µs = 640ns.
# Pixelrate PAL: 720x576 = 414720 Pixel * 25 = 10.368.000 pix/s Netto.
# Es ist aber ein 625-Zeilen-System, also Scan-Timing 720x625x25 = 1/11.250.000s = 88ns/Pixel * 7 =620ns Delay Duration / 1240ns Fault Duration.
# ssS:
# Image defect analysis
# The unknown video source was probably an early amateur pocket-sized SONY.
# This Cam A is named "PAL-Stronghalo".
# One of the main errors of the present PAL video to be compensated first:
# The error to be compensated only appears in the Y component
# and follows the 1st derivative of Y, which appears inverted 7 pixels later as a negated and smeared echo.
# Positive and negative gradients appear with different smears, the total length of the error extends over 14 horizontal pixels.
# Error length 1% of the PAL line length Line frequency 1MHz / 64 = 15625Hz 64µs = 640ns.
# Pixel rate PAL: 720x576 = 414720 pixels * 25 = 10,368,000 pix / s net.
# But it is a 625 line system, i.e. scan timing 720x625x25 = 1 / 11,250,000s = 88ns / pixel * 7 = 620ns delay duration / 1240ns fault duration.
#
# Beschreibung der horizontalen Halo-Fehler an frame 924
# Ein Dunkel->Hell Eingangssprung von Sollwert Y=16 auf Sollwert Y=106 (deltaY=+90) ergibt eine 14 Pixel lange Impulsantwort !
# Anstiegsflanke beginnend bei x=9,Y=16:
# Folge der Abtastwerte 16,62,106,121,111,106,96,86,81,84,86,90,94,98,104,106, Zielwert 106
# Überschwingantwort mit Maximum nach 3 Pixeln, eingeschwungen nach 5 Pixeln:
# x+1: -> Y/2;  x+2 -> Y+0;  x+3 -> Y+10..15;  x+4 -> Y+5;  x+5 -> Y+0
# Unterschwingantwort mit Maximum nach 8 Pixeln ab x+6 bis x+14 länger negativ gerichtet:
# x+6 -> Y-10, x+7 -> Y-20,  x+8  -> -25, x+9 -> Y-22,  x+10 -> Y-20, x+11 -> Y-16 , x+12 -> Y-12 , x+13 -> Y-8 , x+14 -> Y -2, x+15 -> Y-0
# ssS:
# Description of the horizontal halo errors on frame 924
# A dark-> light input jump from target value Y = 16 to target value Y = 106 (deltaY = + 90) results in a 14 pixel long impulse response!
# Rising edge starting at x = 9, Y = 16:
# Sequence of samples 16,62,106,121,111,106,96,86,81,84,86,90,94,98,104,106, target value 106
# Overshoot response with a maximum after 3 pixels, settled after 5 pixels:
# x + 1: -> Y / 2; x + 2 -> Y + 0; x + 3 -> Y + 10..15; x + 4 -> Y + 5; x + 5 -> Y + 0
# Undershoot response with a maximum after 8 pixels from x + 6 to x + 14 longer negative direction:
# x + 6 -> Y-10, x + 7 -> Y-20, x + 8 -> -25, x + 9 -> Y-22, x + 10 -> Y-20, x + 11 -> Y-16, x + 12 -> Y-12, x + 13 -> Y-8, x + 14 -> Y -2, x + 15 -> Y-0
#-------
# Ein Hell->Dunkel Eingangssprung von Sollwert Y=150 auf Sollwert Y=20 (deltaY=-130) ergibt eine 14 Pixel lange Impulsantwort !
# Abfallflanke in Zeile 414, beginnend bei x=425: (x=425,y=414):
# Folge der Abtastwerte 150,130,107,88,63,46,38,40,51,62,64,58,30,24,22,20,  Zielwert 20
# Unterschwingantwort mit 1.Zwischenminimum nach 6 Pixeln,
# Rückschlag mit Maximum Y+44 nach 10 Pixeln, eingeschwungen auf Endwert nach 15 Pixeln
# ssS:
# A light-> dark input jump from target value Y = 150 to target value Y = 20 (deltaY = -130) results in a 14 pixel long impulse response!
# Falling edge in line 414, starting at x = 425: (x = 425, y = 414):
# Sequence of samples 150,130,107,88,63,46,38,40,51,62,64,58,30,24,22,20, target value 20
# Undershoot response with 1st intermediate minimum after 6 pixels,
# Setback with maximum Y + 44 after 10 pixels, settled to final value after 15 pixels
#
# Probier-Methodik: Vorbereitung: Ermitteln der Halofehler-Ausdehnung d
# Nun die Matrix mindestens genau so groß vorgeben. Da sie auto-zentriert berechnet wird, je 1x in jede Richtung.
# Soll das Quellbild Teil der Faltung sein, ist der mittlere Koeffizient <>0, also Länge (2*d)+1.
# Ersteckt sich der Halofehler horizontal über 14 Pixel, gibt man also einen 29 Parameter langen Vektor vor.
# ssS:
# Trial methodology: Preparation: Determine the halo error expansion d
# Now specify the matrix at least as large. Since it is calculated auto-centered, 1x in each direction.
# If the source image is to be part of the convolution, the mean coefficient is <> 0, i.e. length (2 * d) +1.
# If the halo error extends horizontally over 14 pixels, a 29 parameter long vector is given.
#
# Jetzt gehts los !
# ssS:
# Here we go !
##################################
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 28th March 2021 at 10:52.
StainlessS is offline   Reply With Quote