FixChromaBleeding: Difference between revisions

From Avisynth wiki
Jump to navigationJump to search
No edit summary
 
correct some things
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Filter|ajordan|1.0|[[Media:FixChromaBleeding.avs|FixChromaBleeding.avs]]|Chroma_correction|
{{FilterCat4|External_filters|Scripts|Restoration_filters|Chroma correction}}
* YV12
{{Filter3
|}}
|ajordan
{{Template:FuncDef|FixChromaBleeding (clip input) }}
|1.0
|
|Chroma_correction
|
|6=[http://forum.doom9.org/showthread.php?t=77074 Doom9 thread]}}


== Description ==
This is a script to fix color bleeding. The colors that bleed most are the ones that lie in the extremes of the chroma scale (the V channel): saturated blue and red. This Avisynth script, which isolates those extremes, makes a mask out of them and uses the mask to shift the chroma (and lower the saturation) only in those areas where the bleeding is more severe.


== Abstract ==
This is a script to fix color bleeding.


=== Requires Filters ===
== Requirements ==
* AviSynth 2.5.8 or [http://sourceforge.net/projects/avisynth2/ greater]
* Supported color formats: [[YV12]]
==== Required Plugins ====
* [[ChromaShift]]
* [[ChromaShift]]


== Description ==
The colors that bleed most are the ones that lie in the extremes of the chroma scale (the V channel): saturated blue and red. This Avisynth script, which isolates those extremes, makes a mask out of them and uses the mask to shift the chroma (and lower the saturation) only in those areas where the bleeding is more severe.


== Examples ==
==Script==
<pre>
<pre>
Avisource("blah.avi")
Function FixChromaBleeding (clip input) {
FixChromaBleeding()
 
  # prepare to work on the V channel and reduce to speed up and filter noise
  area = input.tweak(sat=4.0).VtoY().ReduceBy2()
 
  # select and normalize both extremes of the scale
  red = area.Levels(255,1.0,255,255,0)
  blue = area.Levels(0,1.0,0,0,255)
 
  # merge both masks
  mask = MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0)
 
  # expand to cover beyond the bleeding areas and shift to compensate the resizing
  mask = mask.ConvertToRGB32().GeneralConvolution(0,"0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0").ConvertToYV12()
 
  # back to full size and binarize (also a trick to expand)
  mask = mask.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255)
 
  # prepare a version of the image that has its chroma shifted and less saturated
  input_c = input.ChromaShift(C=-4).tweak(sat=0.8)
 
  # combine both images using the mask
  return input.overlay(input_c,mask=mask,mode="blend",opacity=1)
}
</pre>
</pre>


== Links ==
Download [[Media:FixChromaBleeding.avs | FixChromaBleeding.avs]] current known version.


[http://forum.doom9.org/showthread.php?t=77074| Doom9 thread]
== Examples ==
[[AviSource]]("blah.avi")
FixChromaBleeding()
 
 


[[Category:External filters]]
==External Links ==
*[http://forum.doom9.org/showthread.php?t=77074| Doom9 Forum] - discussion.
*[http://web.archive.org/web/20130118202943/http://avisynth.org/mediawiki/upload/f/f2/FixChromaBleeding.avs FixChromaBleeding.avs] - archived script from old wiki.
<br>
<br>
-----------------------------------------------
'''Back to [[External_filters#Chroma_correction|External Filters]] &larr;'''

Latest revision as of 23:50, 8 August 2015

Abstract
Author ajordan
Version 1.0
Download
Category Chroma_correction
License
Discussion Doom9 thread

Description

This is a script to fix color bleeding. The colors that bleed most are the ones that lie in the extremes of the chroma scale (the V channel): saturated blue and red. This Avisynth script, which isolates those extremes, makes a mask out of them and uses the mask to shift the chroma (and lower the saturation) only in those areas where the bleeding is more severe.


Requirements

  • AviSynth 2.5.8 or greater
  • Supported color formats: YV12

Required Plugins


Script

Function FixChromaBleeding (clip input) {

  # prepare to work on the V channel and reduce to speed up and filter noise
  area = input.tweak(sat=4.0).VtoY().ReduceBy2()

  # select and normalize both extremes of the scale
  red = area.Levels(255,1.0,255,255,0)
  blue = area.Levels(0,1.0,0,0,255)

  # merge both masks
  mask = MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0)

  # expand to cover beyond the bleeding areas and shift to compensate the resizing
  mask = mask.ConvertToRGB32().GeneralConvolution(0,"0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0").ConvertToYV12()

  # back to full size and binarize (also a trick to expand)
  mask = mask.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255)

  # prepare a version of the image that has its chroma shifted and less saturated
  input_c = input.ChromaShift(C=-4).tweak(sat=0.8)

  # combine both images using the mask
  return input.overlay(input_c,mask=mask,mode="blend",opacity=1)
}


Examples

AviSource("blah.avi")
FixChromaBleeding()





Back to External Filters