digitalFAQ.com Forum

digitalFAQ.com Forum (https://www.digitalfaq.com/forum/)
-   Restore, Filter, Improve Quality (https://www.digitalfaq.com/forum/video-restore/)
-   -   Removal script for ghosts or halo effects? (https://www.digitalfaq.com/forum/video-restore/13041-removal-script-ghosts.html)

banaguitar 10-20-2022 12:41 PM

Removal script for ghosts or halo effects?
 
1 Attachment(s)
Hi,

is there any way to remove this halo and ghost effect?

https://drive.google.com/file/d/1j_T...ew?usp=sharing

I played the tape on different vcr and everywhere the same halo and ghost effect.

lordsmurf 10-21-2022 03:20 AM

Avisynth can probably tackle much of that, maybe all.

I can't help with writing that script right now, so defer to some of our other members here, like lollo2 of themaster1. Maybe PM them, ask them to help you in this thread. Not in PM, but in the thread, so we can all see the script.

banaguitar 10-21-2022 03:21 AM

1 Attachment(s)
Thank you lordsmurf

And here is the raw sample

lollo2 10-21-2022 09:07 AM

1 Attachment(s)
First of all you should try a new capture without any sharpening set active in the VCR or in the "capture device". Your sample is DV encoded, so I suspect a camera or an analog to dv converter.

Removing a strong halo always "destroys" the rest of the content; it's true that you can further process the video for removing noise and do some sharpening after the halo removal, but what was lost is lost.
In your sample the defect on the left of the person is very very difficult to process.

Here a quick 2 minutes attempt just to show the principle. The chroma shift is intentionally exaggerated and must be reduced. No deinterlace performed, it should be done because Dehalo_Alpha needs progressive material.
You can try to play with the parameters of the filters, apply Dehalo_Alpha twice with different set of parameters, etc..., but the best is to introduce a mask to preserve the rest of the area and only act on the edges. Again, try to re-capture if the defetcs are not already in the tape.

https://imgsli.com/MTMxMTcy

Code:

video_org=DirectShowSource("sample.avi")

# plugins directory
plugins_dir="C:\Users\giuse\Documents\VideoSoft\MPEG\AviSynth\extFilters\"

        # ChromaShift
loadPlugin(plugins_dir + "chromashift27\ChromaShift.dll")

        # Dehalo_alpha
Import(plugins_dir + "Dehalo_alpha\Dehalo_alpha_MT2.avsi")
        # Dither
Import(plugins_dir + "dither-1.28.0\mt_xxpand_multi.avsi")
loadPlugin(plugins_dir + "dither-1.28.0\win32\dither.dll")

        # MaskTools2
loadPlugin(plugins_dir + "masktools2-v2.2.23\x86\masktools2.dll")

### convert to YV16
video_org_yv16=video_org.convertToYV16()

### shifting chroma
video_cs_yv16=video_org_yv16.ChromaShift(C=-10)

### dehaloing
video_dehaloed_yv16=video_cs_yv16.Dehalo_alpha(rx=4,ry=4,darkstr=0.0,brightstr=1.2,lowsens=200,highsens=300)
 
### convert to YUY2
video_restored=video_dehaloed_yv16.convertToYUY2()

#return(subtitle(video_org,"video_org",size=20,align=2))

#return(subtitle(video_restored,"video_restored",size=20,align=2))

#interleave(\
stackhorizontal(\
subtitle(video_org,"video_org",size=20,align=2),\
subtitle(video_restored,"video_restored",size=20,align=2)\
)

Attachment 15750

banaguitar 10-21-2022 10:46 AM

Hi, thank you. This looks better!!! I use ADVC-55 with Scenalyzer. I think, there is no way to change any settings here.

lollo2 10-21-2022 10:49 AM

Quote:

This looks better!!!
Well, it depends...

Quote:

I use ADVC-55 with Scenalyzer. I think, there is no way to change any settings here.
Check also the VCRs. Otherwise, it means the halos are in the source.

banaguitar 10-21-2022 10:55 AM

Yes, I played the source tape (betamax) on two different vcr and both the same

lollo2 10-21-2022 12:50 PM

Try to check if there is any "sharpening" setting in the beta VCRs that you can switch off

Hushpower 10-21-2022 08:22 PM

Non-AVISynth... :wink2: VDub Flaxen VHS and CCD filters, just for the exercise.

https://imgsli.com/MTMxMjYx

lordsmurf 10-21-2022 08:43 PM

Quote:

Originally Posted by Hushpower (Post 87359)
Non-AVISynth... :wink2: VDub Flaxen VHS and CCD filters, just for the exercise.

https://imgsli.com/MTMxMjYx

Nice, but needs some more tweaking. Look at the chin.

Hushpower 10-21-2022 09:40 PM

Chinny chin chin! Yes, noted, LS. A compromise...

banaguitar 10-22-2022 01:34 AM

Quote:

Originally Posted by lollo2 (Post 87352)
Try to check if there is any "sharpening" setting in the beta VCRs that you can switch off

Hi, unfortunately not, it must be the tape.

lollo2 10-22-2022 03:19 AM

Quote:

Non-AVISynth... VDub Flaxen VHS and CCD filters, just for the exercise.
That's just a cleaning, does not remove the halos :wink2:

https://imgsli.com/MTMxMjk0

Hushpower 10-22-2022 03:34 AM

Nor does yours, Lollo, look at his right arm. Additionally, your overall image is much softer. There's some pretty severe denoising/smudging going on there.

lordsmurf 10-22-2022 03:45 AM

This is a tricky error. Different restore methods incur different (lesser/better) damage to hide the worse damage.

lollo2 10-22-2022 04:11 AM

Quote:

Nor does yours, Lollo, look at his right arm.
The right arm defect is not a real halo and it's difficult to manage. The evident halos are removed/reduced. Did you look to the images?

Quote:

Additionally, your overall image is much softer. There's some pretty severe denoising/smudging going on there.
That's a price to pay for a quick halo removal. Better tecniques will include edge masking to preserve the general image and focus on the areas where the halos are present, as I already said.
Because the direction this thread is taking, I won't show any of them here.

To the OP: in doom9 forum you had no response to your thread about this query, try to post in Videohelp Restoration forum, somebody like jagabo or poisondeathray will surely help you better than me :wink2:

banaguitar 10-22-2022 04:16 AM

Quote:


To the OP: in doom9 forum you had no response to your thread about this query, try to post in Videohelp Restoration forum, somebody like jagabo or poisondeathray will surely help you better than me :wink2:
Ok, thank you.:) But jagabo does not exist

Hushpower 10-22-2022 05:53 AM

Quote:

But jagabo does not exist
Yes they do. They posted on VideoHelp today.

banaguitar 10-22-2022 05:54 AM

Quote:

Originally Posted by Hushpower (Post 87373)
Yes they do. They posted on VideoHelp today.

On videohelp yes

Hushpower 10-22-2022 06:04 AM

Quote:

On videohelp yes
As Lollo said. :wink2:

Selur 10-28-2022 02:41 PM

1 Attachment(s)
Here's quick go from me at it:
https://www.digitalfaq.com/forum/error.gif
Code:

# Imports
import vapoursynth as vs
import os
import ctypes
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("i:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/KNLMeansCL/KNLMeansCL.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libtemporalmedian.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/ColorFilter/Grayworld/grayworld.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# Import scripts
import SpotLess
import chromashift
import adjust
import havsfunc
# source: 'C:\Users\Selur\Desktop\sample.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: bottom field first
# Loading C:\Users\Selur\Desktop\sample.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/sample.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
# Setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=5)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=1)
# setting field order to what QTGMC should assume (bottom field first)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=1)
# Deinterlacing using QTGMC
clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=False, opencl=True) # new fps: 50
# make sure content is preceived as frame based
clip = core.std.SetFieldBased(clip, 0)
# sharpening using AWarpSharp2
clip = core.warp.AWarpSharp2(clip=clip, blur=2, depth=64, chroma=True, planes=[1,2])
# Color Adjustment
clip = adjust.Tweak(clip=clip, hue=0.00, sat=0.75, cont=1.00, coring=True)
# Chroma adjustment using ChromaShiftSP
clip = chromashift.ChromaShiftSP(clip=clip, X=2.40)
# adjusting color space from YUV420P8 to RGBS for vsGrayworld
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
# Color Adjustment using Grayworld
# convert to linear color space
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
# limit to 0-1
clip = core.std.Limiter(clip, 0.0, 1.0)
clip = core.grwrld.grayworld(clip=clip, cc=0)
# undo conversion to linear color space
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", transfer_in_s="linear", range_s="limited")
# adjusting color space from RGBS to YUV444P16 for vsSpotLess
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
clip = SpotLess.SpotLess(clip=clip, radT=3, thsad=16000)
# cropping the video to 688x568
clip = core.std.CropRel(clip=clip, left=16, right=16, top=4, bottom=4)
# denoising using KNLMeansCL
clip = havsfunc.KNLMeansCL(clip=clip, d=3)
# contrast sharpening using CAS
clip = core.cas.CAS(clip=clip, sharpness=0.600)
# applying dehalo using YAHR
clip = havsfunc.YAHR(clip, blur=4, depth=96)
clip = havsfunc.DeHalo_alpha(clip)
# Resizing using 10 - bicubic spline
clip = core.fmtc.resample(clip=clip, kernel="spline16", w=704, h=546, interlaced=False, interlacedd=False) # resolution 704x546
# adjusting output color from: YUV444P16 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, dither_type="error_diffusion", format=vs.YUV420P10, range_s="limited")
# set output frame rate to 50fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
# Output
clip.set_output()

What I used:
  • QTGMC for deinterlacing
  • aWarpSharp to sharpen chroma
  • Tweak to lower saturation
  • ChromaShift to shift chroma a bit
  • Grayworld to adjust general coloring
  • SpotLess to get rid of some of the noise (could be tweaked more)
  • KNLMeansCL for some denoising (could be tweaked more)
  • CAS for some contrast sharpening
  • YAHR an DeHaloAlpha to lessen the halos (this worked better than expected)
could use some tweaking and maybe adjusting of the filter order.


Cu Selur

lollo2 11-16-2022 07:43 AM

Reel.Dell on doom9 forum developed/modified the "Dering" plugin just for this purpose. Good results were achieved:

https://forum.doom9.org/showthread.php?t=184570


All times are GMT -5. The time now is 09:04 PM

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.