Swap

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (added category)
(add link to avs+ documentation)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:Func4Def|SwapUV(clip ''clip'')|UToY(clip ''clip'')|VToY(clip ''clip'')|YToUV(clip ''clipU'', clip ''clipV'' [, clip ''clipY''])}}<br/>
+
<div {{BlueBox2|40|0|3px solid purple}} >
{{Template:Func2Def|UToY8(clip ''clip'')|VToY8(clip ''clip'')}}
+
{{AvsPlusFullname}}<br>
 +
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/swap.html https://avisynthplus.readthedocs.io]
 +
</div>
  
The first four of the above filters are available starting from v2.5. The last two from v2.60.
+
Swaps chroma channels in [[YUV]] clips.
 +
__TOC__
  
'''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.
+
<!-- ==== Syntax and Parameters ==== -->
 +
<div style="max-width:62em" >
  
'''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 />
+
{{FuncDefH4|SwapUV}}
 +
{{FuncDef
 +
|SwapUV(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 />
+
:Swaps ''U'' and ''V'' (chroma) channels. Corrects certain decoding errors &ndash; faces blue instead of red, etc.
  
'''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.
+
{{FuncDefH4|UToY, VToY}}
 +
{{Func2Def
 +
|UToY(clip ''clip'')
 +
|VToY(clip ''clip'')
 +
}}
  
Starting from v2.53, YUY2 is supported. Starting from v2.60, Y8, YV411, YV16, YV24 are supported.
+
: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.
  
'''Example:'''
 
  
# Blurs the U chroma channel:
+
{{FuncDefH4|UToY8, VToY8}}
video = Colorbars(512, 512).ConvertToYV12
+
{{Func2Def
u_chroma = UToY(video).Blur(1.5)
+
|UToY8(clip ''clip'')
YToUV(u_chroma, video.VToY)
+
|VToY8(clip ''clip'')
MergeLuma(video)
+
}}
  
 +
:Shorthand for '''UToY.'''[[ConvertToY8]] and '''VToY.'''[[ConvertToY8]], but faster.
 +
 +
 +
{{FuncDefH4|YToUV}}
 +
{{FuncDef
 +
|YToUV(clip ''clipU'', clip ''clipV'' [, clip ''clipY'' [, clip ''clipA'' ] ] )
 +
}}
 +
 +
:Copies the ''Y'' (luma channel) of {{FuncArg|clipU}} to the ''U'' channel of the output clip and the ''Y'' (luma channel) of {{FuncArg|clipV}} to the ''V'' channel of the output clip.
 +
:If {{FuncArg|clipY}} is given, copies the ''Y'' (luma channel) of {{FuncArg|clipY}} to the ''Y'' channel of the output clip.
 +
:{{AvsPluscon}} And if {{FuncArg|clipA}} is given too, copies the ''Y'' (luma channel) of {{FuncArg|clipA}} to the ''A'' channel of the output clip.
 +
:Depending on the color format, the image resolution can be changed.
 +
</div>
 +
 +
 +
==== See Also ====
 +
*Show [[RGB]] channels with [[ShowAlpha|ShowAlpha/Red/Green/Blue]].
 +
*{{AvsPluscon}} [[Extract]] for {{Deep_color}} support.
 +
 +
 +
==== Examples ====
 +
<div style="max-width:62em" >
 +
* Blur the U chroma channel
 +
<div {{BoxWidthIndent|32|2}} >
 +
video = [[ColorBars]](512, 512).[[ConvertToYV12]]
 +
u_chroma = '''UToY'''(video).[[Blur]](1.5)
 +
'''YToUV'''(u_chroma, video.'''VToY''')
 +
[[MergeLuma]](video)
 +
</div>
 +
 +
* Show ''U'' and ''V'' channels stacked for illustration purposes.
 +
** Note that with a [[YV12]] source (like the one below), the ''U'' and ''V'' images will be half the size of the original.
 +
** In the ''U'' and ''V'' images, gray will be at 128{{D}} and saturated colors will appear brighter or darker.
 +
{{HalfBreak}}
 +
:[[File:SwapEx-Sintel9150.jpg]]
 +
<div {{BoxWidthIndent|32|2}} >
 +
[[StackVertical]](
 +
\  [[Subtitle]]("YV12 original", align=2),
 +
\  [[StackHorizontal]](
 +
\      '''UtoY'''.Subtitle("UtoY", align=2),
 +
\      '''VtoY'''.Subtitle("VtoY", align=2)
 +
\  )
 +
\ )
 +
</div>
 +
</div>
 +
 +
 +
==== Changes ====
 +
{| border="1"
 +
|-
 +
| v2.60
 +
| Added UToY8, VToY8.
 +
|-
 +
| v2.60
 +
| Added new color formats [[Y8]], [[YV411]], [[YV16]] and [[YV24]].
 +
|}
  
 
[[Category:Internal_filters]]
 
[[Category:Internal_filters]]
 
[[Category:Levels_and_Chroma_filters]]
 
[[Category:Levels_and_Chroma_filters]]

Latest revision as of 05:24, 17 September 2022

AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io

Swaps chroma channels in YUV clips.

Contents


SwapUV

SwapUV(clip clip)

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


UToY, VToY

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, VToY8

UToY8(clip clip)
VToY8(clip clip)

Shorthand for UToY.ConvertToY8 and VToY.ConvertToY8, but faster.


YToUV

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

Copies the Y (luma channel) of clipU to the U channel of the output clip and the Y (luma channel) of clipV to the V channel of the output clip.
If clipY is given, copies the Y (luma channel) of clipY to the Y channel of the output clip.
AVS+ And if clipA is given too, copies the Y (luma channel) of clipA to the A channel of the output clip.
Depending on the color format, the image resolution can be changed.


[edit] See Also


[edit] Examples

  • Blur the U chroma channel
video = ColorBars(512, 512).ConvertToYV12
u_chroma = UToY(video).Blur(1.5)
YToUV(u_chroma, video.VToY)
MergeLuma(video)
  • Show U and V channels stacked for illustration purposes.
    • Note that with a YV12 source (like the one below), the U and V images will be half the size of the original.
    • In the U and V images, gray will be at 128d and saturated colors will appear brighter or darker.
 
SwapEx-Sintel9150.jpg
StackVertical(
\  Subtitle("YV12 original", align=2),
\  StackHorizontal(
\       UtoY.Subtitle("UtoY", align=2), 
\       VtoY.Subtitle("VtoY", align=2)
\  )
\ )


[edit] Changes

v2.60 Added UToY8, VToY8.
v2.60 Added new color formats Y8, YV411, YV16 and YV24.
Personal tools