DODOX

0

0

Pogoda w Łodzi


 


niedziela, 15 maja 2011

Poprawianie jakości materiału video - Filtr: DeGrainMedian

DeGrainMedian

Spatio-Temporal Limited Median filter for grain removal Czasoprzestrzennego Limited Mediana filtr do usuwania ziarna

Plugin for Avisynth 2.5 Plugin dla Avisynth 2.5
Version 0.8.2 Wersja 0.8.2
Copyright (C)2004-2006 Alexander G. Balakhnin (aka Fizick). Copyright (C) 2004-2006 Aleksander G. Balakhnin (aka Fizick).
http://avisynth.org.ru http://avisynth.org.ru

DeGrainMedian plugin is mainly for film grain removal, but may be used for general denoising. DeGrainMedian plugin jest głównie do usuwania ziarno filmu, ale może być stosowane do ogólnego odszumianie.
It uses some spatio-temporal limited median method. Używa niektórych czasoprzestrzennych ograniczony mediana metody.

Syntax Składnia

DeGrainMedian ( clip, int "limitY", int "limitUV", int "mode", bool "interlaced", bool "norow" ) DeGrainMedian (clip, int "Shinigami", int "limitUV" int "mode", bool "z przeplotem" bool "norow")

Filter Parameters Parametry filtra

first parameter as always is input clip or default last, Pierwszy parametr jak zawsze jest domyślnie plik wejścia lub ostatnim

limitY (0 to 255, default=4) -limit of pixel luma correction, limitY (0 do 255, domyślnie = 4)-limit korekta jasności pikseli,

limitUV (0 to 255, default=6) - limit of pixel chroma correction, limitUV (0 do 255, domyślnie = 6) - limit pikseli korekcji barwy,

mode (0 to 5, default=1) - operation mode (the more, the weaker) tryb (0 do 5, domyślnie = 1) - tryb pracy (im więcej, tym słabszy)

interlaced (true or false, default=false) - process clip as interlaced przeplotem (prawdziwe lub fałszywe, default = false) - klip proces z przeplotem

norow (true or false, default=false) - do not use same row in spatial filter norow (prawdziwe lub fałszywe, default = false) - nie używać tego samego wiersza w filtr przestrzenny

Using for grain and noise removal Korzystanie usuwania ziarna i szumów

Load plugin, adjust parameters value for your clip. Załaduj plugin, zmienić wartości parametrów klipu.

Set limitY to typical value about 2-8 (compromise between denoising and bluring). Ustaw limitY do typowych wartości około 2-8 (kompromis między odszumianie i bluring).

It seems, that bigger values of limitUV for chroma (4-15) are often quite safe. Wydaje się, że większe wartości limitUV do barw (4-15) są często dość bezpieczny.

Set mode parameter to bigger value if you found picture as oversmoothed (try!). parametr mode Ustaw większą wartość, jeśli znaleziono obrazu jako oversmoothed (try!).

The more mode number, the bigger limit values is safe. Więcej numer trybu, tym większe wartości dopuszczalne jest bezpieczny.

It seems, that mode =1 or 2 is good compromise, but it is dependent from source. Wydaje się, że mode = 1 lub 2 jest dobry kompromis, ale jest to zależne od źródła.

With mode =5 the result changes are invisible, but some of "hot" pixels are removed. W trybie = 5 zmiany wynikają są niewidoczne, ale niektóre "gorące" piksele są usuwane.

Option norow =true is useful on video with horizontal noise stripes , such as analog TV or VHS captures. norow Option = true to przydatne na film z paskami hałasu, takich jak analogowe lub oddaje VHS.

Simple sample scripts (use correct file path) skryptów Simple (stosowanie prawidłowej ścieżki do pliku)

Subtle filtering but useful for hot pixels removal: Subtelne, ale przydatne do filtrowania gorących usuwanie pikseli:

Avisource("dvd-input.avi") AVISource ("dvd-input.avi")

loadplugin("DeGrainMedian.dll") loadplugin ("DeGrainMedian.dll")
DeGrainMedian(limitY=5,limitUV=5,mode=3) DeGrainMedian (limitY = 5, limitUV = 5, mode = 3) 

Two-stage filtering for more full noise removal: Dwustopniowe filtrowanie bardziej pełny usuwanie szumu:

Avisource("input.avi") AVISource ("input.avi")

loadplugin("DeGrainMedian.dll") loadplugin ("DeGrainMedian.dll")
DeGrainMedian(limitY=2,limitUV=3,mode=1) DeGrainMedian (limitY = 2, limitUV = 3, mode = 1)
DeGrainMedian(limitY=2,limitUV=3,mode=1) DeGrainMedian (limitY = 2, limitUV = 3, mode = 1) 

Strong filtering for big grain removal: Silne filtrowania dużych usuwanie ziarna:

Avisource("analog-input.avi") AVISource (analogowo-input.avi ")

loadplugin("DeGrainMedian.dll") loadplugin ("DeGrainMedian.dll")
DeGrainMedian(limitY=5,limitUV=7,mode=0) DeGrainMedian (limitY = 5, limitUV = 7, mode = 0) 

Filtering for horizontal noise stripes removal: Filtrowanie poziome paski usuwania szumów:

Avisource("analog-input.avi") AVISource (analogowo-input.avi ")

loadplugin("DeGrainMedian.dll") loadplugin ("DeGrainMedian.dll")
DeGrainMedian(limitY=5,limitUV=7,mode=1, norow=true) DeGrainMedian (limitY = 5, limitUV = 7, mode = 1, norow = true) 

Technical details Dane techniczne

The plugin is mostly based on two ideas, used at two stages of processing. Wtyczka opiera się głównie na dwóch założeniach, używane w dwóch etapach przetwarzania.

First stage - detecting Pierwszy etap - wykrywanie

The first idea is from STMedianFilter plugin by Tom Barry Pierwszy pomysł jest z STMedianFilter plugin Tom Barry
I also use part of its great optimized code and put some part of its nice doc (edited a little) here: Używam również część wielkiej zoptymalizowany kod i umieścić część jej ładny doc (red. niewiele) tu:

"STMedianFilter is a (slightly motion compensated) spatial/temporal median filter. It fairly very fine grained, using only adjacent pixels in space and time, so it looks at the adjacent 26 locations to filter each location. It filters both luma and chroma.... "STMedianFilter jest (nieco zrekompensowane ruchu) przestrzenne / czasowego mediana filtrujące. Stosunkowo bardzo drobnoziarnista, używając tylko sąsiadujących pikseli w czasie i przestrzeni, tak to wygląda w sąsiednim 26 miejsc do filtrowania każdej lokalizacji. Filtruje zarówno jasności i nasycenia barw. ...
...A simple median filter is just a clipping step where a value is set to not extend past the high and low of its neighbors. ... Prosty mediana filtr jest tylko wycinek etapie, na którym jest wartość nie obejmuje obok wysokiego i niskiego sąsiadów.
( probably more strictly: median is middle member of ranked (ordered by value) series - Fizick ). (Prawdopodobnie bardziej ściśle: mediana jest członkiem środku rankingu (na zlecenie wartości) series - Fizick).
For instance, if you had 3 pixels in a row that had the values <5,8,7> you could clip the center one to not be outside the low of 5 or the high of 7, so you would set it to 7. Na przykład, jeśli miał 3 piksele w rzędzie, który miał wartości <5,8,7> można przypiąć centrum nie znajduje się poza niskim 5 lub 7 wysokie, więc można ustawić go na 7.
Now imagine you had a small 3x3 video screen, like one surface of a Rubiks cube. Teraz wyobraź sobie, że masz małe 3x3 ekranu wideo, jak jednej powierzchni kostki Rubiks. Imagine the previous frame was the bottom layer of the cube, the current frame was the middle layer, and the next frame was the top. Wyobraź sobie, że poprzedniego ramę dolną warstwę sześcianu, obecne ramy był warstwy środkowej, i następnej klatki był na szczycie.
Then the current center pixel would be right in the center of the Rubics cube and there would be 13 ways you could draw a line through it and a pair of two nearest neighbors. Następnie prąd pikseli centrum będzie w samym centrum sześcianu Rubics i nie byłoby 13 sposobów można narysować linię przez to i parę dwóch najbliższych sąsiadów.
What I ( and I - Fizick ) did was to compare each of those pairs of neighbors to see which pair was most agreeing on value. Co (i - Fizick) nie było porównanie każdej z tych par sąsiadów, aby zobaczyć, która para była najbardziej uzgodnienie wartości. I ( and I - Fizick ) used that pair to clip the value of the center pixel." (The end of Tom Barry citation). I (i ja - Fizick) używane tę parę do klipu wartości pikseli w środku). "(Tom Barry koniec cytatu.

Very interesting RemoveGrain plugin by Kassandro in mode=9 works similar to STMedianFilter at this stage, but in spatial plane only (not in temporal). Bardzo ciekawe RemoveGrain plugin Kassandro w trybie = 9 działa podobnie do STMedianFilter na tym etapie, ale w płaszczyźnie przestrzennej (nie w czasie). It than changes pixel to this value of neighbors (by minimax). To nie zmiany tej wartości pikseli sąsiadów (przez minimax). But it can not remove middle sized grain from my bad film source. Ale nie można usunąć średniej wielkości ziarna z moich złych źródło filmu.
RemoveGrain is considered by Kassandro as prefilter for RemoveDirt , he says in doc: RemoveGrain uważany jest przez filtr wstępny jak Kassandro dla RemoveDirt , mówi w doc:
"If grain is too crude, RemoveGrain can only partially remove it or cannot remove it at all." "Jeżeli ziarno jest zbyt surowy, RemoveGrain tylko częściowo usunąć lub nie może go usunąć w ogóle."
( The end of Kassandro citation) (Koniec cytatu Kassandro)
It seems, that it is mostly due to lack of temporal information from neighbor frames. Wydaje się, że jest to głównie ze względu na brak informacji od czasowych ram sąsiada.

Since version 0.2, I add to DeGrainMedian also some other more safe operation modes 1-4(later 5) (code borrowed from RemoveGrain). Od wersji 0.2, dodałem do DeGrainMedian też inne bardziej bezpieczne tryby pracy 1-4 (później 5) (kod zapożyczone z RemoveGrain).
We consider the same 3x3x3 cube. Rozważymy ten Kostka 3x3x3.
New pixel candidate value (newp) is clipped by values of neighbor pixels from pair (bound1 and bound2). Nowa wartość piksela kandydata (newp) jest obcięty o wartości pikseli sąsiad z pary (bound1 i bound2).
But mode1-mode5 use more safe criterion (weight) of optimal pixel pair, Ale mode1-mode5 użyć bardziej bezpieczne kryterium (waga) optymalnych pikseli pary,
We take into account also the difference of new value from central pixel old value (oldp) . Bierzemy również pod uwagę różnicę nową wartość od centrum starego wartość pikseli (oldp).

Mode=0 of DeGrainMedian (similar to mode=9 of RemoveGrain) uses weight=|bound1 -bound2|, it is strongest. Mode = 0 DeGrainMedian (podobny do trybu = 9 RemoveGrain) wykorzystuje waga = | bound1-bound2 |, to jest najsilniejszy.
Mode=1 of DeGrainMedian (more strong than mode=8 of RemoveGrain) uses weight=|oldp - newp|+4* |bound1 - bound2| Mode = 1 DeGrainMedian (więcej silnych niż mode = 8 RemoveGrain) wykorzystuje waga = | oldp - newp | +4 * | bound1 - bound2 |
Mode=2 of DeGrainMedian (similar to mode=8 of RemoveGrain) uses weight=|oldp - newp|+2* |bound1 - bound2| Mode = 2 DeGrainMedian (podobny do trybu = 8 RemoveGrain) wykorzystuje waga = | oldp - newp | +2 * | bound1 - bound2 |
Mode=3 of DeGrainMedian (similar to mode=7 of RemoveGrain) uses weight=|oldp - newp|+ |bound1 - bound2| Mode = 3 DeGrainMedian (podobny do trybu = 7 RemoveGrain) wykorzystuje waga = | oldp - newp | + | bound1 - bound2 |
Mode=4 of DeGrainMedian (similar to mode=6 of RemoveGrain) uses weight=2*|oldp - newp|+ |bound1 - bound2| Mode = 4 DeGrainMedian (podobny do trybu = 6 RemoveGrain) wykorzystuje waga = 2 * | oldp - newp | + | bound1 - bound2 |
Mode=5 of DeGrainMedian (similar to mode=5 of RemoveGrain) uses weight=|oldp - newp|, it is weakest. Mode = 5 DeGrainMedian (podobny do trybu = 5 RemoveGrain) wykorzystuje waga = | oldp - newp |, to jest najsłabszy.

norow option excludes horizontal pixels pair of same frame, so filter considers 12 pairs only. Opcja norow wyłącza poziome parę pikseli tej samej klatki, więc filtr uważa tylko 12 par.

Second stage - filtration Drugi etap - filtracji

STMedianFilter at second stage don't filter pixel if it would change it more than some threshold. STMedianFilter w drugim etapie nie filtrują pixel, czy to zmienić więcej niż kilka progu.
(More correctly, it firstly makes temporal detecting and thresholding, (Więcej prawidłowo, to po pierwsze sprawia, że ​​wykrywanie i obcinanie czasie,
with following spatial detecting and thresholding) z następujących przestrzennego wykrywania i obcinanie)

The most denoisers also do not filter pixels with big noise (big luma differences). Najbardziej denoisers również nie filtrowania pikseli z dużym hałasem (duże różnice jasności).
But both such single pixels are very visible on flat smoothed regions, Ale i takie pojedyncze piksele są bardzo widoczne na płaskich wygładzone regionów,
and group of them forms very annoying edge artifacts. i ich grupa tworzy bardzo irytujące artefakty krawędzi.

Moreover, pure temporal denoisers often produce ghosting even for not very big thresholds. Ponadto czysty czasie denoisers często przynoszą efekty zjawy nawet progi nie bardzo duża.

DeGrainMedian at this second stage uses other (different) method of pixel processing. DeGrainMedian w tym drugim etapie, innych (różnych) metody przetwarzania pikseli.

Here I use second idea, borrowed from Dust plugin by Steady. Używam tutaj druga koncepcja, zapożyczone z Dust plugin Steady. See part of Dust doc here: Zobacz część Dust doc tutaj:

"Limit=5 "Limit = 5
Sets the strength of the temporal filtering. Ustawia siły w czasie filtrowania. (How much it can change the original pixel)." (The end of Steady citation). (Ile można to zmienić oryginalną pikseli). "(Koniec cytatu stacjonarnym).

So, if filtered pixel would be changed more than some threshold (limit), Tak więc, jeśli sączy pikseli zostanie zmienione więcej niż kilka próg (limit),
it will NOT be restored to original in DeGrainMedian, to nie może być przywrócony do pierwotnego w DeGrainMedian,
but will be changed by LIMITED value. ale można zmienić poprzez ograniczoną wartość.
DeGrainMedian plugin filters ALL pixels, but with limited strength. DeGrainMedian plugin filtrów pikseli ALL, ale z ograniczoną wytrzymałość.
Therefore, all grain and strikes are (fully or partially) smoothed. Dlatego też wszystkie ziarna i strajków (w pełni lub częściowo) wygładzone.

Filter almost don't produce edge artifacts. Filtr prawie nie produkują artefaktów krawędzi.
Ghosting is also minimal, since it is automatically switched to spatial smoothing as more nearest pair by values. Ghosting jest minimalny, ponieważ jest on automatycznie włączony do wygładzania bardziej przestrzenny najbliższego pary przez wartości.
You may select one of 6 modes of operation, from strong (but smoothed) to weak (but sharp). Możesz wybrać jeden z 6 trybów pracy, od silnego (ale wygładzone) do słabego (ale ostry).

So, DeGrainMedian have a speed of STMedianFilter (true) and strength of Dust (true by limit value :-)! Tak więc, DeGrainMedian mieć prędkość STMedianFilter (true) i siły Dust (true :-) wartości limitu!
It is almost not joke :-). To nie żart prawie :-).

It can greatly increase the compession degree. może znacznie zwiększyć stopień compession.

What is bad, really? Co to jest źle, naprawdę?

1. 1. Some blurring (you want denoising without it ? :-) . Niektóre rozmycia (chcesz denoising bez niego? :-).
2. 2. It can not produce flat fully smooth picture, some noise always remains (you like oversmoothed and blocked clips ?). Nie można w pełni sprawnego wytwarzania płaskich obraz, szum jest zawsze (chcesz oversmoothed i zablokowane pliki?).
3. 3. Motion compensation is limited to 1 pixel value (of course, it is NOT as Dust , but what about external motion compensation ?). kompensacja ruchu jest ograniczona do wartości 1 piksela (oczywiście, to nie jest jak Dust , ale co z zewnętrznych kompensacji ruchu?).

Seriously, it is not super filter and still experimental, but for my noisy grainy films, it makes quite good results. Poważnie, to nie jest super filtr i wciąż w fazie eksperymentalnej, ale na moje głośne filmy gruboziarniste, sprawia, że ​​bardzo dobre wyniki.
Firstly I developed it as prefilter (to Vaguedenoiser etc), but it seems now, that sometimes it can be used alone... Po pierwsze opracowałem go jako filtr wstępny (do Vaguedenoiser itp.), ale wydaje się, że czasami może być stosowany samodzielnie ...
Probably, it can help somebody else. Pewnie, może pomóc komuś innemu. That is why I release it. Dlatego zwolnij go.

Some note. Niektóre notatki. With limitY=255, DeGrainMedian must have the same (or similar) output Z limitY = 255, DeGrainMedian muszą mieć takie same (lub podobne) wyjście
as STMedianFilter with thresholds=255 (and with the same artifacts), but it is not true now, jak STMedianFilter progów = 255 (i tym samym artefakty), ale nie jest prawdą teraz,
probably due to some bug or bugs :-( prawdopodobnie ze względu na jakiś błąd lub błędów :-(

Edit: It is true now - it was a bug in STMedianFilter , I fixed it in v 1.0.3. Edit: To prawda, teraz - to był błąd w STMedianFilter , Naprawiłem to w v 1.0.3.

Combining usage Łącząc wykorzystanie

It must be applied before other denoising filters. Należy stosować przed innymi filtrami odszumianie.
Sometimes I use two DeGrainMidian filters in script with lower limits for better noise removal. Czasami używam dwóch DeGrainMidian filtry skrypt z niższych limitów dla lepszego usuwania szumów.
The better results for films restoration within Avisynth can be achieved with my global motion compensation plugin DePan . Lepsze wyniki na przywrócenie filmów w Avisynth można osiągnąć z moim globalnej kompensacji ruchu plugin DePan .

Features and limitations of current version Funkcji i ograniczeń aktualnej wersji

  1. Works only in YV12 and YUY2 color format. Działa tylko w YV12 i YUY2 format koloru.
  2. Requires a P-III, Athlon, or higher. Wymaga P-III, Athlon lub wyższy. Needs SSEMMX (Integer SSE) support. Potrzebuje SSEMMX (Integer SSE) wsparcia.
  3. No scenechange detector in current version. Nr detektor scenechange w aktualnej wersji. But I do not see any ghosting - filter is switched to spatial pixel pairs. Ale ja nie widzę żadnego smużenia - filtr jest włączony przestrzennych pikseli par.
  4. First and last line (line pair for interlaced) of every frame are not filtered. Pierwsza i ostatnia linia (pary linii z przeplotem) z każdej ramki nie są filtrowane.
  5. First and last 8 (YV12) or 4 (YUY2) pixels in every row are filtered with more simple (same columns) method. Imię i 8 (YV12) lub 4 (YUY2) pikseli w każdym wierszu są filtrowane metodą bardziej proste (te same kolumny).
  6. Chroma filtering in YUY2 mode is also in same columns only. Chroma filtrowania w trybie YUY2 jest również same kolumny tylko.
  7. First and last frames are not filtered Pierwszą i ostatnią klatkę nie są filtrowane
  8. Tested with Avisynth 2.5.5. Testowane z Avisynth 2.5.5.
  9. It is very fast filter. Jest bardzo szybki filtr.
Pobierz wersję 0.8.2 DeGrainMedian