View Full Version : Script to correct colour artefacts


alexh110
13th January 2025, 00:12
Hi to all you AviSynth geniuses!

I have another problem for you, and it's a tricky one!

Assume you have some footage sourced from an old PAL videotape, that includes an area of pale blue sky.

Most of the colouration is correct; but there are a few blotches with chroma-phase error, where the blue has been replaced by the wrong hue.
These errors have the correct U and V magnitude; but the wrong sign for either or both.

Could I make a mask to automatically identify and encompass the pale blue sky. Then automatically detect the blotches, and flip the U and/or V sign to give the correct colour?

The script could, if necessary, allow the user to specify which PAL quadrant contains the correct colour. (For blue sky this would very likely correspond to negative V and positive U.)

Alternatively it could allow the user to point to the correct colour with a mouse.

The script would then need to use the same user-provided information across a number of frames, so the whole scene can be repaired as a batch job.

This user input should make the problem easier to solve; but it still remains a challenging conundrum.

Would want to apply the same script to other similar situations with problem colours; not just blue sky.

alexh110
14th January 2025, 19:34
If this problem is too hard, perhaps I could just ask about the first part. I.e. How to make a mask encompassing a particular area, based on colour? (Pale blue sky being a good example.)

Selur
14th January 2025, 20:19
Got a sample of such a clip?
It's probably easier to start with a sample so it's clear what the problem is and then work on a more general solution,...

poisondeathray
14th January 2025, 21:35
You can try maskhs to make a selection based on hue, saturation
http://avisynth.nl/index.php/MaskHS

Avisynth results based on hue/saturation masking tend not be as good or clean as dedicated tools such as chroma keyers, NLE's. You can interactively select the colors and add/subtract various ranges with the mouse with editors - that solves your user input requirement.

alexh110
15th January 2025, 16:09
Thanks! Will give that a try.