martin53
19th December 2012, 23:42
Hi @all,
today I worked on correcting the skin tone in a clip that was shot in a blueish shadow.
Therefore, I liked to see the U and V values (in AvsPmod).
Maybe I am too blind to see the obvious, or I miss a famous plugin, but it proved not that easy to me.
In case you are in a similar situation, I provide two small scripts here that might help with the task.
The first one uses two sliders to control a little marker. The Y, U and V values of the pixel under the marker are displayed as a subtitle. It uses the RT_Stats plugin and guarantees correct output by its method of operation.
Because it is tedious to move the marker to a specific coordinate with the 'help' of the sliders, the second script displays the frame side by side with a miscoloured frame (is that the correct term?).
The miscoloured frame receives its RED component purely from the luma Y component of the clip, its GREEN purely from U, and its BLUE purely from V.
AvsPmod shows the RGB as 'hex=$......' in the status line. This directly corresponds to luma, U and V of the original clip as the mouse pointer hovers over the miscoloured frame.
In script #2, showYUVasRGB() does the core job. It is tested with AviSynth 2.60, but no guarantee can be taken that the conversion routines work the same in all past and future versions.
Script #1
#===============================================================================
function ShowPixelYUVvalue(clip c, float X, float Y) {
c.GScriptclip(""" #"
c = last
X = int(X)
Y = int(Y)
ys = RT_Hex(c.RT_YPlaneMax(x=X, y=Y, w=1, h=1),2)
us = RT_Hex(c.UToY.RT_YPlaneMax(x=int(X/2), y=int(Y/2), w=1, h=1),2)
vs = RT_Hex(c.VToY.RT_YPlaneMax(x=int(X/2), y=int(Y/2), w=1, h=1),2)
c.Subtitle("Y="+ys+"\nU="+us+"\nV="+vs, lsp=0, align=5)
Overlay(blankclip(c, pixel_type="rgb32", color=$ffffff, width=1, height=11), x=X, y=Y-5, mode="exclusion")
Overlay(blankclip(c, pixel_type="rgb32", color=$ffffff, width=11, height=1), x=X-5, y=Y, mode="exclusion")
""", args="X,Y")
}
#===============================================================================
c = Colorbars(pixel_type="YV12")
ShowPixelYUVvalue(c, [<"XSlider", 0, 639, 567>], [<"YSlider", 0, 479, 284>])
Script #2
# See below for explanation of the script
#=====================================================================================================================
function showYUVasRGB(clip c) {
#------------------------------------------------------------------------------------------------------------------------------------
#The filter below shows the YUV components of the clip as RGB components to the right of the clip.
#Hover over the right part of the output to see the YUV components displayed as 'hex=$......' in the AvsPmod status bar.
Stackhorizontal(c.ConvertToRGB(matrix="PC.601"),
\BlankClip(c,pixel_type="RGB32",width=1,color=$ffffff),
\MergeRGB(c.GreyScale().ConvertToYUY2().ConvertToRGB(matrix="PC.601"),
\c.UToY.PointResize(c.width,c.height).ConvertToYUY2().ConvertToRGB(matrix="PC.601"),
\c.VToY.PointResize(c.width,c.height).ConvertToYUY2().ConvertToRGB(matrix="PC.601")
\)
\)
}
#=====================================================================================================================
t=BlankClip(width=46,height=160,pixel_type="YV12")
top=StackHorizontal( BlankClip(t,color_yuv=$b48080),
\BlankClip(t,color_yuv=$a22c8e),
\BlankClip(t,color_yuv=$839c2c),
\BlankClip(t,width=44,color_yuv=$70483a),
\BlankClip(t,color_yuv=$54b8c6),
\BlankClip(t,color_yuv=$4164d4),
\BlankClip(t,color_yuv=$23d472)
\)
t=BlankClip(t,height=20)
mid=StackHorizontal( BlankClip(t,color_yuv=$23d472),
\BlankClip(t,color_yuv=$108080),
\BlankClip(t,color_yuv=$54b8c6),
\BlankClip(t,width=44,color_yuv=$108080),
\BlankClip(t,color_yuv=$839c2c),
\BlankClip(t,color_yuv=$108080),
\BlankClip(t,color_yuv=$b48080)
\)
t=BlankClip(t,width=54,height=60)
low=StackHorizontal( BlankClip(t,color_yuv=$109e5f),
\BlankClip(t,color_yuv=$eb8080),
\BlankClip(t,color_yuv=$10ae95),
\BlankClip(t,width=52,color_yuv=$108080),
\BlankClip(t,width=18,color_yuv=$078080),
\BlankClip(t,width=18,color_yuv=$108080),
\BlankClip(t,width=18,color_yuv=$198080),
\BlankClip(t,width=52,color_yuv=$108080)
\)
cBars = StackVertical(top, mid, low)
# The above are the SMPTE color bars as source so you can compare the color_yuv values with your RGB readings in the right half.
# Change any of the bars to your taste to verify that the YUV components are correctly displayed as RGB components in AvsPmod.
#------------------------------------------------------------------------------------------------------------------------------------
c = cBars
# v v v v v v v v
# insert *your* clip as 'c' here instead of cBars to see its Y, U, V components as R, G, B figures in AvsPmod
# ^ ^ ^ ^ ^ ^ ^ ^
showYUVasRGB(c)
today I worked on correcting the skin tone in a clip that was shot in a blueish shadow.
Therefore, I liked to see the U and V values (in AvsPmod).
Maybe I am too blind to see the obvious, or I miss a famous plugin, but it proved not that easy to me.
In case you are in a similar situation, I provide two small scripts here that might help with the task.
The first one uses two sliders to control a little marker. The Y, U and V values of the pixel under the marker are displayed as a subtitle. It uses the RT_Stats plugin and guarantees correct output by its method of operation.
Because it is tedious to move the marker to a specific coordinate with the 'help' of the sliders, the second script displays the frame side by side with a miscoloured frame (is that the correct term?).
The miscoloured frame receives its RED component purely from the luma Y component of the clip, its GREEN purely from U, and its BLUE purely from V.
AvsPmod shows the RGB as 'hex=$......' in the status line. This directly corresponds to luma, U and V of the original clip as the mouse pointer hovers over the miscoloured frame.
In script #2, showYUVasRGB() does the core job. It is tested with AviSynth 2.60, but no guarantee can be taken that the conversion routines work the same in all past and future versions.
Script #1
#===============================================================================
function ShowPixelYUVvalue(clip c, float X, float Y) {
c.GScriptclip(""" #"
c = last
X = int(X)
Y = int(Y)
ys = RT_Hex(c.RT_YPlaneMax(x=X, y=Y, w=1, h=1),2)
us = RT_Hex(c.UToY.RT_YPlaneMax(x=int(X/2), y=int(Y/2), w=1, h=1),2)
vs = RT_Hex(c.VToY.RT_YPlaneMax(x=int(X/2), y=int(Y/2), w=1, h=1),2)
c.Subtitle("Y="+ys+"\nU="+us+"\nV="+vs, lsp=0, align=5)
Overlay(blankclip(c, pixel_type="rgb32", color=$ffffff, width=1, height=11), x=X, y=Y-5, mode="exclusion")
Overlay(blankclip(c, pixel_type="rgb32", color=$ffffff, width=11, height=1), x=X-5, y=Y, mode="exclusion")
""", args="X,Y")
}
#===============================================================================
c = Colorbars(pixel_type="YV12")
ShowPixelYUVvalue(c, [<"XSlider", 0, 639, 567>], [<"YSlider", 0, 479, 284>])
Script #2
# See below for explanation of the script
#=====================================================================================================================
function showYUVasRGB(clip c) {
#------------------------------------------------------------------------------------------------------------------------------------
#The filter below shows the YUV components of the clip as RGB components to the right of the clip.
#Hover over the right part of the output to see the YUV components displayed as 'hex=$......' in the AvsPmod status bar.
Stackhorizontal(c.ConvertToRGB(matrix="PC.601"),
\BlankClip(c,pixel_type="RGB32",width=1,color=$ffffff),
\MergeRGB(c.GreyScale().ConvertToYUY2().ConvertToRGB(matrix="PC.601"),
\c.UToY.PointResize(c.width,c.height).ConvertToYUY2().ConvertToRGB(matrix="PC.601"),
\c.VToY.PointResize(c.width,c.height).ConvertToYUY2().ConvertToRGB(matrix="PC.601")
\)
\)
}
#=====================================================================================================================
t=BlankClip(width=46,height=160,pixel_type="YV12")
top=StackHorizontal( BlankClip(t,color_yuv=$b48080),
\BlankClip(t,color_yuv=$a22c8e),
\BlankClip(t,color_yuv=$839c2c),
\BlankClip(t,width=44,color_yuv=$70483a),
\BlankClip(t,color_yuv=$54b8c6),
\BlankClip(t,color_yuv=$4164d4),
\BlankClip(t,color_yuv=$23d472)
\)
t=BlankClip(t,height=20)
mid=StackHorizontal( BlankClip(t,color_yuv=$23d472),
\BlankClip(t,color_yuv=$108080),
\BlankClip(t,color_yuv=$54b8c6),
\BlankClip(t,width=44,color_yuv=$108080),
\BlankClip(t,color_yuv=$839c2c),
\BlankClip(t,color_yuv=$108080),
\BlankClip(t,color_yuv=$b48080)
\)
t=BlankClip(t,width=54,height=60)
low=StackHorizontal( BlankClip(t,color_yuv=$109e5f),
\BlankClip(t,color_yuv=$eb8080),
\BlankClip(t,color_yuv=$10ae95),
\BlankClip(t,width=52,color_yuv=$108080),
\BlankClip(t,width=18,color_yuv=$078080),
\BlankClip(t,width=18,color_yuv=$108080),
\BlankClip(t,width=18,color_yuv=$198080),
\BlankClip(t,width=52,color_yuv=$108080)
\)
cBars = StackVertical(top, mid, low)
# The above are the SMPTE color bars as source so you can compare the color_yuv values with your RGB readings in the right half.
# Change any of the bars to your taste to verify that the YUV components are correctly displayed as RGB components in AvsPmod.
#------------------------------------------------------------------------------------------------------------------------------------
c = cBars
# v v v v v v v v
# insert *your* clip as 'c' here instead of cBars to see its Y, U, V components as R, G, B figures in AvsPmod
# ^ ^ ^ ^ ^ ^ ^ ^
showYUVasRGB(c)