Swap

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (added category)
(formatting, links, phrasing)
Line 1: Line 1:
{{Template:Func4Def|SwapUV(clip ''clip'')|UToY(clip ''clip'')|VToY(clip ''clip'')|YToUV(clip ''clipU'', clip ''clipV'' [, clip ''clipY''])}}<br/>
+
{{FuncDef
{{Template:Func2Def|UToY8(clip ''clip'')|VToY8(clip ''clip'')}}
+
|SwapUV(clip ''clip'')
 +
}}
  
The first four of the above filters are available starting from v2.5. The last two from v2.60.
+
:Swaps ''U'' and ''V'' (chroma) channels. Corrects certain decoding errors &ndash; faces blue instead of red, etc.
  
'''SwapUV''' swaps chroma channels (U and V) of a clip. Sometimes the colors are distorted (faces blue instead of red, etc) when loading a [[DivX]] or [[MJPEG]] clip in AviSynth v2.5, due to a bug in the decoders. You can use this filter to correct it.
 
  
'''UToY''' copies chroma U plane to Y plane. All color (chroma) information is removed, so the image is now greyscale. Depending on the YUV format, the image resolution can be changed.<br />
+
{{Func2Def
 +
|UToY(clip ''clip'')
 +
|VToY(clip ''clip'')
 +
}}
  
'''VToY''' copies chroma V plane to Y plane. All color (chroma) information is removed, so the image is now greyscale. Depending on the YUV format, the image resolution can be changed.<br />
+
:Copies ''U'' or ''V'' chroma plane to the ''Y'' luma plane.  
 +
:All color (chroma) information is removed, so the image is now greyscale.  
 +
:Depending on the color format, the image resolution can be changed &ndash; i.e.,
 +
:with a [[YV24]] source, '''UToY''' is the same width and height as {{FuncArg|clip}}, but
 +
:with a [[YV12]] source, '''UToY''' is half {{FuncArg|clip}}'s width and height.
  
'''YToUV''' puts the luma channels of the two clips as U and V channels. Luma is now 50% grey. Starting from v2.51 there is an optional argument ''clipY'' which puts the luma channel of this clip as the Y channel. Depending on the YUV format, the image resolution can be changed.<br />
 
  
'''UToY8''' (added in v2.60) is a shorthand for UToY.ConvertToY8, and '''VToY8''' (added in v2.60) is a shorthand for VToY.ConvertToY8, but faster.
+
{{Func2Def
 +
|UToY8(clip ''clip'')
 +
|VToY8(clip ''clip'')
 +
}}
  
Starting from v2.53, YUY2 is supported. Starting from v2.60, Y8, YV411, YV16, YV24 are supported.
+
::Shorthand for '''UToY.'''[[ConvertToY8]] and '''VToY.'''[[ConvertToY8]], but faster. Added in v2.60.
 +
  
'''Example:'''
+
{{FuncDef
 +
|YToUV(clip ''clipU'', clip ''clipV'' [, clip ''clipY'' ] )
 +
}}
  
# Blurs the U chroma channel:
+
:Copies {{FuncArg|clipU}}:''Y''&nbsp; to output ''U'' and {{FuncArg|clipV}}:''Y''&nbsp; to output ''V''.
  video = Colorbars(512, 512).ConvertToYV12
+
:If {{FuncArg|clipY}} is given, copies {{FuncArg|clipY}}:''Y''&nbsp; to output ''Y''; else output ''Y'' is 50% grey.
  u_chroma = UToY(video).Blur(1.5)
+
:Depending on the color format, the image resolution can be changed.
  YToUV(u_chroma, video.VToY)
+
 
  MergeLuma(video)
+
 
 +
==== Color models ====
 +
[[YUY2]] and [[YV12]] are supported. Starting from v2.60, [[Y8]], [[YV411]], [[YV16]] and [[YV24]] are also supported.
 +
 
 +
 
 +
== Example ==
 +
* Blurs the U chroma channel
 +
<div {{BoxWidthIndent|28|1}} >
 +
  video = [[ColorBars]](512, 512).[[ConvertToYV12]]
 +
  u_chroma = '''UToY'''(video).[[Blur]](1.5)
 +
  '''YToUV'''(u_chroma, video.'''VToY''')
 +
  [[MergeLuma]](video)
 +
</div>
  
  
 
[[Category:Internal_filters]]
 
[[Category:Internal_filters]]
 
[[Category:Levels_and_Chroma_filters]]
 
[[Category:Levels_and_Chroma_filters]]

Revision as of 03:55, 28 January 2016

SwapUV(clip clip)

Swaps U and V (chroma) channels. Corrects certain decoding errors – faces blue instead of red, etc.


UToY(clip clip)
VToY(clip clip)

Copies U or V chroma plane to the Y luma plane.
All color (chroma) information is removed, so the image is now greyscale.
Depending on the color format, the image resolution can be changed – i.e.,
with a YV24 source, UToY is the same width and height as clip, but
with a YV12 source, UToY is half clip's width and height.


UToY8(clip clip)
VToY8(clip clip)

Shorthand for UToY.ConvertToY8 and VToY.ConvertToY8, but faster. Added in v2.60.


YToUV(clip clipU, clip clipV [, clip clipY ] )

Copies clipU:Y  to output U and clipV:Y  to output V.
If clipY is given, copies clipY:Y  to output Y; else output Y is 50% grey.
Depending on the color format, the image resolution can be changed.


Color models

YUY2 and YV12 are supported. Starting from v2.60, Y8, YV411, YV16 and YV24 are also supported.


Example

  • Blurs the U chroma channel
video = ColorBars(512, 512).ConvertToYV12
u_chroma = UToY(video).Blur(1.5)
YToUV(u_chroma, video.VToY)
MergeLuma(video)
Personal tools