Selur's Little Message Board
Deoldify Vapoursynth filter - Printable Version

+- Selur's Little Message Board (https://forum.selur.net)
+-- Forum: Talk, Talk, Talk (https://forum.selur.net/forum-5.html)
+--- Forum: Small Talk (https://forum.selur.net/forum-7.html)
+--- Thread: Deoldify Vapoursynth filter (/thread-3595.html)



RE: Deoldify Vapoursynth filter - Selur - 26.01.2026

Feeding a 1250x833 image into HAVC, I get:
clip = havc.HAVC_main(clip, ColorFix="none", BlackWhiteTune="none")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsdeoldify\__init__.py", line 325, in HAVC_main
return HAVC_main_presets(clip, Preset, FrameInterp, ColorModel, CombMethod, VideoTune, ColorFix,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsdeoldify\__init__.py", line 532, in HAVC_main_presets
return restore_format(clip_final, orig_fmt)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsdeoldify\havc_utils.py", line 174, in restore_format
clip = vsresize.resize_to_chroma(clip_info.clip_orig, clip)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsdeoldify\vsslib\vsresize.py", line 122, in resize_to_chroma
clip_yuv = vs.core.std.ShufflePlanes(clips=[clip_bw, clip_color, clip_color], planes=[0, 1, 2], colorfamily=vs.YUV)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src/cython/vapoursynth.pyx", line 3129, in vapoursynth.Function.__call__
vapoursynth.Error: ShufflePlanes: plane 1 and 2 are not subsampled multiples of first plane
=> seems like mod2 is required.
Should I adjust Hybrid to take this into account, or should this be fixed in HAVC?

Cu Selur

Ps.: Added a dev which adds mod2 requirement for HAVC and ColorAdjust(HAVC).


RE: Deoldify Vapoursynth filter - Dan64 - 26.01.2026

I think that the division by 2 is a requirement for a lot of filters, not only HAVC.

Probably is better to add this check at the beginning of the script. 

I will check your dev. version.

Thanks,
Dan


RE: Deoldify Vapoursynth filter - Selur - 26.01.2026

Now that I think about it,.. at the moment Hybrid would add black borders,.. which will cause problems when Retinex is used.
Problem is that you are using YUV color space in your scripts and seemingly don't use 4:4:4 color sampling,... (mod2 usually is required for 4:2:0 or 4:1:1)
Will be afk. tomorrow, but I'll think about an option for Hybrid to use https://github.com/dubhater/vapoursynth-fillborders instead of addborders, which should work with Retinex.

Cu Selur


RE: Deoldify Vapoursynth filter - domb84 - 29.01.2026

I've got an issue with a cheap super 8mm film scanner that on certain scenes sets the auto white balance so that there is a horrific blue cast across the entire frame. It's scene dependent and no way to disable it in the firmware (unless its de compiled and reverse engineered). It's so bad on some scenes that I can't correct it. The best I've found at correcting it is deoldify, except of course it treats it as though there is no colour information at all, so what is there is lost. I've tried to merge the original and deoldified frames with limited success. 

I cannot find a function within deoldify to attempt to restore badly calibrated frames as opposed to colouring b&w. does anybody know of a way I can achieve this?

This is what i have currently with an example of the worst scenes.

https://mega.nz/file/4KIjibYa#wISHeTNwA4ntTq3x_27SaFy0EZqDoXC_bxW_taUju0A

The above is not too bad considering, but when compared with another scene from the same scan, we lose a lot of what was good. of course this frame doesn't actually need anything done at all, but that's where I would like to get back to.

https://mega.nz/file/9ShRHRDJ#EmWvPeF5X-J_FkaPFXHJ9V3kAFft4kS0s83xbXo-OVg

I'm sure is there a much better method to remove the blue cast, but I'm unable to land on a method of white balancing across the entire film scan that resolves the worst parts, and 90% of the scan only needs a simple adjustment.

Any help appreciated!


RE: Deoldify Vapoursynth filter - Selur - 29.01.2026

Got an unprocessed video sample of the source?


RE: Deoldify Vapoursynth filter - Dan64 - 29.01.2026

(7 hours ago)domb84 Wrote: I'm sure is there a much better method to remove the blue cast, but I'm unable to land on a method of white balancing across the entire film scan that resolves the worst parts, and 90% of the scan only needs a simple adjustment.

Any help appreciated!

In Hybrid there is the filter "Auto white" (see picture)

[Image: attachment.php?aid=3482]

You should apply it to the orginal clip before merging the clip with the HAVC colored clip.

Otherwise you can try the Example 6: Direct application of filter B&W tune with some colors final adjustment
You can find it at page 114 of HAVC User Guide.

Try to play with the parameters strength and gamma of function HAVC_adjust_rgb().

Dan


RE: Deoldify Vapoursynth filter - domb84 - 29.01.2026

I'm using native vapoursynth rather than hybrid but I'm already using grayworld to perform a whitebalance that removes the cast before merging. of course the destroyed skintones still remain which the merge doesn't do enough to resolve, but also takes out the colour that remains.

Sure here's an "uncompressed" sample. I have no idea what is throwing the white balance across these scenes but you can see how severe it is in the cut.

https://mega.nz/file/1bIjFIDI#aS6qoviWz-HMaI5DNLm_cTkRIV-JFhoOnC8qUp8RBrc

Here's the vs script. I saw some information regarding Softlight, but I cannot understand from the docs how to utilise that to eliminate the colour cast.

# Imports
import vapoursynth as vs
from vapoursynth import core

# loading plugins
import havsfunc as haf
import lostfunc as lof
import muvsfunc as muf
import CropResize as cr
import adjust
import G41Fun
import adjust
import vsdeoldify as havc
import vs_colorfix

# source
src = r"xxx.MP4"

# Load source
src = core.ffms2.Source(source=src)
src = core.std.AssumeFPS(src, fpsnum=18, fpsden=1)
# convert to YUV
src = core.resize.Bicubic(src, 1440, 1080, format=vs.YUV444P16, matrix_in_s="709")
# make a new source
clip = src

### deoldify ###
# changing range from limited to full range for HAVC
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full")
# DeOldify only model
color = havc.HAVC_colorizer(clip, method=0)
#
# merge
clip = core.fmtc.bitdepth (clip, bits=32)
clip = core.grwrld.grayworld(clip)
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full")
clip = core.std.Merge(color,clip,weight=[0.33,0.33,0.33])

# retinex or grayworld
#clip = core.retinex.MSRCP(clip)

# softlight
#clip = core.Argaricolm.Softlight(clip, mode=10)
#
# render for comparison
clip = core.resize.Bicubic(clip, 1440, 1080, format=vs.YUV444P16, matrix_s="709")

clip = muf.DisplayHistogram(clip)
clip = core.text.Text(clip, 'output')
src = muf.DisplayHistogram(src)
src = core.text.Text(src, 'source')

clip = core.std.StackHorizontal([src,clip])

# output
clip.set_output(0)