View Full Version : Purple Chromatic Abberation
baka1
27th March 2021, 06:37
https://mega.nz/file/7f4CzTxA#v6n1Mb9_llKovQVrXqt-gxWs9bAgfuFvAjqx7xQOt0s
Ugly purple chromatic abberation on the edges of windows and everything on the right hand side of frame. MergeChroma while helping a little bit, still shows noticeable chroma. Is there anything that would outright remove the purple blocks/lines?
MergeChroma(aWarpSharp2(depth=127,blur=100,thresh=255,chroma=3,type=1))
https://i.slow.pics/LluYpS5q.png
https://i.slow.pics/eTLFs2JA.png
Hotte
27th March 2021, 07:32
You have a "complete" chromatic abberation here that is purple on the left and green on the right hand side. I'd say your approach is really not bad. Tried to apply it two times ?
I have experimented with http://avisynth.nl/index.php/FixChromaticAberration in the past and was also only able to reduce but never to 100% cure it.
baka1
27th March 2021, 07:50
Applying it two times shifts that really tiny purple line a few pixels across and causes more damage.
Emulgator
27th March 2021, 13:03
I would separate planes and shift these as desired.
StainlessS
27th March 2021, 20:01
This of any use ?
https://forum.doom9.org/showthread.php?p=1832121#post1832121
EDIT: I've added helper functions to apply to a range of frames, for ShiftUV() and ShiftRedBlue() funcs at above link.
RaffRiff42's Func
ShiftUV.avsi
# ShiftUV.avsi
# Must use Planar YV444 / YV24
##################################
### shift Chroma relative to Luma (YUV, YUVA) (AVS+ required)
##
function ShiftUV(clip C, float "ux", float "uy", float "vx", float "vy")
{ # RaffRiff42, https://forum.doom9.org/showthread.php?p=1832121#post1832121
Assert(C.IsYUV || C.IsYUVA,"ShiftUV: source must be YUV(A)")
Assert(C.Is444,"ShiftUV: YV24/YUV444 is required") # ssS: Added
ux = Float(Default(ux, 0))
uy = Float(Default(uy, 0))
vx = Float(Default(vx, ux))
vy = Float(Default(vy, uy))
U = C.ExtractU
V = C.ExtractV
U = U.BilinearResize(U.Width, U.Height, -ux, -uy, U.Width, U.Height)
V = V.BilinearResize(V.Width, V.Height, -vx, -vy, V.Width, V.Height)
return (C.NumComponents==3)
\ ? CombinePlanes(C.ExtractY, U, V, "YUV")
\ : CombinePlanes(C.ExtractY, U, V, C.ExtractA, "YUVA")
}
Function RangeShiftUV(clip c,Int "S", Int "E", float "ux", float "uy", float "vx", float "vy") {
/* # StainlessS, https://forum.doom9.org/showthread.php?p=1939195#post1939195
Start and End Args may not be Exactly like trim
RangeShiftUV() # Frame 0 Only, E Defaults to -1, ie 1 frame
RangeShiftUV(0,0) # Entire clip
RangeShiftUV(100,0) # Frame 100 to End of Clip
RangeShiftUV(0,-1) # Frame 0 Only
RangeShiftUV(1,1) # Frame 1 Only
RangeShiftUV(1,-1) # Frame 1 Only
RangeShiftUV(1) # Frame 1 Only
RangeShiftUV(1,-3) # Frames 1 to 3 (ie 3 frames)
RangeShiftUV(100,200) # Frames 100 to 200
RangeShiftUV(100,-50) # Frames 100 to 149 ie 50 frames
*/
c
S = Min(Max(Default(S,0),0),FrameCount-1)
E = Default(E,-1)
E = (E==0) ? FrameCount-1 : E
E = Min(((E < 0) ? S-E-1 : E),FrameCount-1)
ux = Default(ux,0).Float uy = Default(uy,0).Float
vx = Default(vx,0).Float vy = Default(vy,0).Float
ApplyRange(S,E,"ShiftUV",ux,uy,vx,vy)
}
Client
Avisource("D:\Parade.avi")
ConvertToYV24
O=Last
RangeShiftUV(S=0,E=0,ux=-24,uy=25,vx=14,vy=-24)
StackHorizontal(O,LasT)
ShiftRedBlue.avsi
# ShiftRedBlue.avsi
# Must use Planar RGB
##################################
### shift and/or resize Red and Blue relative to Green
## (RGB24, RGB32, RGB48, RGB64, RGB10/12/14/16/32, RGBA10/12/14/16/32)
##
## @ rx, ry, bx, by - ± "shift" red & blue position
## @ rxd, ryd, bxd, byd - ± "delta" width & height for advanced convergence
##
function ShiftRedBlue(clip C,
\ float "rx", float "ry",
\ float "bx", float "by",
\ float "rxd", float "ryd",
\ float "bxd", float "byd")
{ # RaffRiff42, https://forum.doom9.org/showthread.php?p=1832121#post1832121
Assert(C.IsRGB && !C.IsInterleaved, "ShiftRedBlue: source must be Planar RGB") # ssS: Modified
rx = Float(Default(rx, 0))
ry = Float(Default(ry, 0))
bx = Float(Default(bx, 0))
by = Float(Default(by, 0))
rxd = Float(Default(rxd, 0))
ryd = Float(Default(ryd, 0))
bxd = Float(Default(bxd, 0))
byd = Float(Default(byd, 0))
R=C.ExtractR.Spline64Resize(C.Width, C.Height, -rx, -ry, C.Width-rxd, C.Height-ryd)
B=C.ExtractB.Spline64Resize(C.Width, C.Height, -bx, -by, C.Width-bxd, C.Height-byd)
return (C.NumComponents==3)
\ ? CombinePlanes(R, C.ExtractG, B, "RGB")
\ : CombinePlanes(R, C.ExtractG, B, C.ExtractA, "RGBA")
}
Function RangeShiftRedBlue(clip c,Int "S", Int "E",
\ float "rx", float "ry", float "bx", float "by",
\ float "rxd", float "ryd", float "bxd", float "byd")
\ {
/* # StainlessS, https://forum.doom9.org/showthread.php?p=1939195#post1939195
Start and End Args may not be Exactly like trim
RangeShiftRedBlue() # Frame 0 Only, E Defaults to -1, ie 1 frame
RangeShiftRedBlue(0,0) # Entire clip
RangeShiftRedBlue(100,0) # Frame 100 to End of Clip
RangeShiftRedBlue(0,-1) # Frame 0 Only
RangeShiftRedBlue(1,1) # Frame 1 Only
RangeShiftRedBlue(1,-1) # Frame 1 Only
RangeShiftRedBlue(1) # Frame 1 Only
RangeShiftRedBlue(1,-3) # Frames 1 to 3 (ie 3 frames)
RangeShiftRedBlue(100,200) # Frames 100 to 200
RangeShiftRedBlue(100,-50) # Frames 100 to 149 ie 50 frames
*/
c
S = Min(Max(Default(S,0),0),FrameCount-1)
E = Default(E,-1)
E = (E==0) ? FrameCount-1 : E
E = Min(((E < 0) ? S-E-1 : E),FrameCount-1)
rx = Default(rx, 0).Float ry = Default(ry, 0).Float
bx = Default(bx, 0).Float by = Default(by, 0).Float
rxd = Default(rxd, 0).Float ryd = Default(ryd, 0).Float
bxd = Default(bxd, 0).Float byd = Default(byd, 0).Float
ApplyRange(S,E,"ShiftRedBlue",rx,ry,bx,by,rxd,ryd,bxd,byd)
}
Client
Avisource("D:\Parade.avi")
ConvertToPlanarRGB
O=Last
RangeShiftRedBlue(S=0,E=0,rx=-24,ry=25,bx=24,by=-24)
StackHorizontal(O,LasT)
The result from RGB client above.
https://i.postimg.cc/fbPh4WPZ/Shift-Red-Blue-00.jpg (https://postimages.org/)
baka1
27th March 2021, 21:56
Function RangeShiftRedBlue(clip c,Int "S", Int "E",\
\ float "rx", float "ry",
\ float "bx", float "by",
\ float "rxd", float "ryd",
\ float "bxd", float "byd")
) {
Had to remove the red bits to make it work
StainlessS
27th March 2021, 21:56
Couple of probs and caveats to above post noted, and both Range funcs tested, with RGB image result.
EDIT: Yep, sorry bout that baka1.
baka1
27th March 2021, 22:12
I'm getting 'Animate: must have two argument lists with matching type' - the error is pointing to the ApplyRange function.
ShiftUV works tho - but it shifts (which it should do) - but not remove.
StainlessS
27th March 2021, 22:16
Yep, sorry, I said was a couple of small probs fixed, copy from new script and re-test please.
StainlessS
27th March 2021, 22:30
Dont know if of use, but Vdub has VHS [flaxen VHS v1.0] fxvhs.vdf filter.
https://i.postimg.cc/Z5SbQbMX/Untitled-00.jpg (https://postimages.org/)
NO individual channel shift. (I thought there was another VD filter with individual channel shift [maybe I,Q], but cant find it).
baka1
27th March 2021, 22:41
Lanczos4Resize(848,480)
ConverttoRGB32()
ConvertToPlanarRGB()
O=Last
RangeShiftRedBlue(S=0,E=0,rx=-24,ry=25,bx=24,by=-24)
StackHorizontal(O,LasT)
I'm getting 'Input colourspace is not RGB24 or RGB32' - then Avisynth goes on an infinite error loop cycle until it crashes.
This only happens if I use Convert to PlanarRGB - not sure why this is happening. It's fine for ConverttoRGB32()
StainlessS
27th March 2021, 23:11
Lanczos4Resize(848,480)
ConverttoRGB32()
ConvertToPlanarRGB()
O=Last
RangeShiftRedBlue(S=0,E=0,rx=-24,ry=25,bx=24,by=-24)
StackHorizontal(O,LasT)
I'm getting 'Input colourspace is not RGB24 or RGB32' - then Avisynth goes on an infinite error loop cycle until it crashes.
This only happens if I use Convert to PlanarRGB - not sure why this is happening. It's fine for ConverttoRGB32()
For me it dont work with RGB32.
What is source colorspace and dimensions, and Avs version. that produces error message.
It does work [for me] even with YV12, YUY2, or YV411,
then convertToPlanarRGB.
baka1
28th March 2021, 00:39
What is source colorspace and dimensions, and Avs version. that produces error message.
Source colourspace is YV12, Dimensions 1920x1080 - cropped to 1920x1040. AvsPmod version 2.5.1.
StainlessS
28th March 2021, 11:09
I asked for Avs version not AvsPMod version.
Suggest Avs+ v3.70, also AvsPMod now v2.6.6.9
Not sure if the problem you are having is for final clip colorspace, ie use convertToRGB32 at end of script for your viewer, ie AvsPMod v2.5.1
which probably cant display Planar RGB.
EDIT: I'm using PotPlayer from 2021 Feb 09, and VDub2, which can display PlanarRGB OK.
baka1
28th March 2021, 11:44
Suggest Avs+ v3.70, also AvsPMod now v2.6.6.9
Ah yes this works now :thanks:
StainlessS
28th March 2021, 14:51
Post #5, small update/mod to RaffRiff42 functions [in BLUE],
error alert if not YV24/YV444 for ShiftUV(), or if not Planar RGB for ShiftRedBlue().
Better than error shown for other cryptic reasons.
kedautinh12
20th July 2021, 08:00
and after use shiftUV or shiftRedBlue. How remove the purple blocks/lines?
StainlessS
20th July 2021, 14:25
and after use shiftUV or shiftRedBlue. How remove the purple blocks/lines?
I'm slightly confused, the shift is intended to remove the lines.
ShiftStuff.avsi
# ShiftStuff.avsi
# ShiftUV.avsi
# Must use Planar YV444 / YV24
##################################
### shift Chroma relative to Luma (YUV, YUVA) (AVS+ required)
##
function ShiftUV(clip C, float "ux", float "uy", float "vx", float "vy")
{ # RaffRiff42, https://forum.doom9.org/showthread.p...21#post1832121
Assert(C.IsYUV || C.IsYUVA,"ShiftUV: source must be YUV(A)")
Assert(C.Is444,"ShiftUV: YV24/YUV444 is required") # ssS: Added
ux = Float(Default(ux, 0))
uy = Float(Default(uy, 0))
vx = Float(Default(vx, ux))
vy = Float(Default(vy, uy))
U = C.ExtractU
V = C.ExtractV
U = U.BilinearResize(U.Width, U.Height, -ux, -uy, U.Width, U.Height)
V = V.BilinearResize(V.Width, V.Height, -vx, -vy, V.Width, V.Height)
return (C.NumComponents==3)
\ ? CombinePlanes(C.ExtractY, U, V, "YUV")
\ : CombinePlanes(C.ExtractY, U, V, C.ExtractA, "YUVA")
}
Function RangeShiftUV(clip c,Int "S", Int "E", float "ux", float "uy", float "vx", float "vy") {
/* # StainlessS, https://forum.doom9.org/showthread.p...95#post1939195
Start and End Args may not be Exactly like trim
RangeShiftUV() # Frame 0 Only, E Defaults to -1, ie 1 frame
RangeShiftUV(0,0) # Entire clip
RangeShiftUV(100,0) # Frame 100 to End of Clip
RangeShiftUV(0,-1) # Frame 0 Only
RangeShiftUV(1,1) # Frame 1 Only
RangeShiftUV(1,-1) # Frame 1 Only
RangeShiftUV(1) # Frame 1 Only
RangeShiftUV(1,-3) # Frames 1 to 3 (ie 3 frames)
RangeShiftUV(100,200) # Frames 100 to 200
RangeShiftUV(100,-50) # Frames 100 to 149 ie 50 frames
*/
c
S = Min(Max(Default(S,0),0),FrameCount-1)
E = Default(E,-1)
E = (E==0) ? FrameCount-1 : E
E = Min(((E < 0) ? S-E-1 : E),FrameCount-1)
ux = Default(ux,0).Float uy = Default(uy,0).Float
vx = Default(vx,0).Float vy = Default(vy,0).Float
ApplyRange(S,E,"ShiftUV",ux,uy,vx,vy)
}
# ShiftRedBlue.avsi
# Must use Planar RGB
##################################
### shift and/or resize Red and Blue relative to Green
## (RGB24, RGB32, RGB48, RGB64, RGB10/12/14/16/32, RGBA10/12/14/16/32)
##
## @ rx, ry, bx, by - ± "shift" red & blue position
## @ rxd, ryd, bxd, byd - ± "delta" width & height for advanced convergence
##
function ShiftRedBlue(clip C,
\ float "rx", float "ry",
\ float "bx", float "by",
\ float "rxd", float "ryd",
\ float "bxd", float "byd")
{ # RaffRiff42, https://forum.doom9.org/showthread.p...21#post1832121
Assert(C.IsRGB && !C.IsInterleaved, "ShiftRedBlue: source must be Planar RGB") # ssS: Modified
rx = Float(Default(rx, 0))
ry = Float(Default(ry, 0))
bx = Float(Default(bx, 0))
by = Float(Default(by, 0))
rxd = Float(Default(rxd, 0))
ryd = Float(Default(ryd, 0))
bxd = Float(Default(bxd, 0))
byd = Float(Default(byd, 0))
R=C.ExtractR.Spline64Resize(C.Width, C.Height, -rx, -ry, C.Width-rxd, C.Height-ryd)
B=C.ExtractB.Spline64Resize(C.Width, C.Height, -bx, -by, C.Width-bxd, C.Height-byd)
return (C.NumComponents==3)
\ ? CombinePlanes(R, C.ExtractG, B, "RGB")
\ : CombinePlanes(R, C.ExtractG, B, C.ExtractA, "RGBA")
}
Function RangeShiftRedBlue(clip c,Int "S", Int "E",
\ float "rx", float "ry", float "bx", float "by",
\ float "rxd", float "ryd", float "bxd", float "byd")
\ {
/* # StainlessS, https://forum.doom9.org/showthread.p...95#post1939195
Start and End Args may not be Exactly like trim
RangeShiftRedBlue() # Frame 0 Only, E Defaults to -1, ie 1 frame
RangeShiftRedBlue(0,0) # Entire clip
RangeShiftRedBlue(100,0) # Frame 100 to End of Clip
RangeShiftRedBlue(0,-1) # Frame 0 Only
RangeShiftRedBlue(1,1) # Frame 1 Only
RangeShiftRedBlue(1,-1) # Frame 1 Only
RangeShiftRedBlue(1) # Frame 1 Only
RangeShiftRedBlue(1,-3) # Frames 1 to 3 (ie 3 frames)
RangeShiftRedBlue(100,200) # Frames 100 to 200
RangeShiftRedBlue(100,-50) # Frames 100 to 149 ie 50 frames
*/
c
S = Min(Max(Default(S,0),0),FrameCount-1)
E = Default(E,-1)
E = (E==0) ? FrameCount-1 : E
E = Min(((E < 0) ? S-E-1 : E),FrameCount-1)
rx = Default(rx, 0).Float ry = Default(ry, 0).Float
bx = Default(bx, 0).Float by = Default(by, 0).Float
rxd = Default(rxd, 0).Float ryd = Default(ryd, 0).Float
bxd = Default(bxd, 0).Float byd = Default(byd, 0).Float
ApplyRange(S,E,"ShiftRedBlue",rx,ry,bx,by,rxd,ryd,bxd,byd)
}
UV
Import(".\ShiftStuff.avsi")
ImageSource(".\LluYpS5q.png",End=0)
ConvertToYV24
CROP(1200,100,0,600) # just look at windows
O=Last
UX=-4.0
VX=2.0
UY=0.0
VY=0.0
ShiftUV(ux=UX,uy=UY,vx=VX,vy=VY)
StackHorizontal(O,Last)
RB
Import(".\ShiftStuff.avsi")
ImageSource(".\LluYpS5q.png",End=0)
ConvertToPlanarRGB
CROP(1200,100,0,600) # just look at windows
O=Last
RX=-2.0
BX=0.0
# no Y shift
RY=0.0
BY=0.0
# ALL Below 0.0
RXD=0.0
RYD=0.0
BXD=0.0
BYD=0.0
ShiftRedBlue(rx=RX,ry=RY,bx=BX,by=BY,rxd=RXD,ryd=RYD,bxd=BXD,byd=BYD)
StackHorizontal(O,Last)
Sorry, I dont have time to play with the numbers, thats your job. [The ones in BLUE]
StainlessS
20th July 2021, 20:45
Here a script that cycles though a number of settings, [hope I aint cocked it up, seems to work perfectly].
Import(".\ShiftStuff.avsi")
SHIFTMAX=5
PEL=4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
Z = SHIFTMAX * PEL * 2 + 1
END = Z * Z - 1
ImageSource(".\LluYpS5q.png",End=END)
ConvertToPlanarRGB
CROP(1200,100,0,600) # Windows only
O=Last
SSS="""
n = current_frame
RXI = n / Z
BXI = n % Z
RX = RXI / PEL.Float - SHIFTMAX
BX = BXI / PEL.Float - SHIFTMAX
ShiftRedBlue(rx=RX,bx=BX)
RT_Subtitle("%d] RX=%f, BX=%f",n,RX,BX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
You havta have better eyes than me to spot the best one.
EDIT: Slight change, changed FRMS to END.
EDIT: Only does horizontal shifts.
EDIT: And its UV sister
Import(".\ShiftStuff.avsi")
SHIFTMAX=5
PEL=4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
Z = SHIFTMAX * PEL * 2 + 1
END = Z * Z - 1
ImageSource(".\LluYpS5q.png",End=END)
ConvertToYV24
CROP(1200,100,0,600) # Windows only
O=Last
SSS="""
n = current_frame
UXI = n / Z
VXI = n % Z
UX = UXI / PEL.Float - SHIFTMAX
VX = VXI / PEL.Float - SHIFTMAX
ShiftUV(ux=UX,vx=VX)
RT_Subtitle("%d] UX=%f, VX=%f",n,UX,VX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
kedautinh12
21st July 2021, 10:56
Thanks for monitor script to find value
StainlessS
21st July 2021, 11:39
and versions of previous two script where you can provide min and max for shifts
[eg If you know you only want right shift Red, then avoid left shifts]
RB
Import(".\ShiftStuff.avsi")
# Next Min, Max and PEL values MUST be Type Int
RMIN = -1 RMAX = 1
BMIN = 0 BMAX = 3
PEL = 4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
RRNG = RMAX - RMIN
BRNG = BMAX - BMIN
ZR = RRNG * PEL + 1
ZB = BRNG * PEL + 1
END = ZR * ZB - 1
ImageSource(".\LluYpS5q.png",End=END)
ConvertToPlanarRGB
CROP(1200,100,0,600) # Windows only
O=Last
SSS="""
n = current_frame
RXI = n / ZB
BXI = n % ZB
RX = RXI / PEL.Float + RMIN
BX = BXI / PEL.Float + BMIN
ShiftRedBlue(rx=RX,bx=BX)
RT_Subtitle("%d] RX=%f, BX=%f",n,RX,BX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
UV
Import(".\ShiftStuff.avsi")
# Next Min, Max and PEL values MUST be Type Int
UMIN = -1 UMAX = 1
VMIN = 0 VMAX = 3
PEL = 4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
URNG = UMAX - UMIN
VRNG = VMAX - VMIN
ZU = URNG * PEL + 1
ZV = VRNG * PEL + 1
END = ZU * ZV - 1
ImageSource(".\LluYpS5q.png",End=END)
ConvertToYV24
CROP(1200,100,0,600) # Windows only
O=Last
SSS="""
n = current_frame
UXI = n / ZV
VXI = n % ZV
UX = UXI / PEL.Float + UMIN
VX = VXI / PEL.Float + VMIN
ShiftUV(ux=UX,vx=VX)
RT_Subtitle("%d] UX=%f, VX=%f",n,UX,VX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
EDIT: Min shift values must be <= Max shift values.
EDIT: For RB shift only [would not work for UV shift],
Just a thought, maybe if during scan, you convert frame to grayscale temp, and somehow find a single value for edges [would that be vertical edges when shift horizontal ???],
and choose best [greatest magnitude of edges] as being the best shift.
No idea how to do that nor if would work ok. [where is RaffRiff42 when you need him].
Suugestions for above in blue welcome.
StainlessS
21st July 2021, 13:03
OK, We added the vertical edge detection whotsit to the script
Import(".\ShiftStuff.avsi")
# Next Min, Max and PEL values MUST be Type Int
RMIN = -5 RMAX = 5
BMIN = -5 BMAX = 5
PEL = 4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
RRNG = RMAX - RMIN
BRNG = BMAX - BMIN
ZR = RRNG * PEL + 1
ZB = BRNG * PEL + 1
END = ZR * ZB - 1
ImageSource(".\LluYpS5q.png",End=END)
ConvertToPlanarRGB
CROP(1200,100,0,600) # Windows only
O=Last
BestEdge = 0.0
BestRX = 0.0
BestBX = 0.0
SSS="""
n = current_frame
RXI = n / ZB
BXI = n % ZB
RX = RXI / PEL.Float + RMIN
BX = BXI / PEL.Float + BMIN
ShiftRedBlue(rx=RX,bx=BX)
Q=GreyScale
Q=Q.GeneralConvolution(0, "1 0 -1 2 0 -2 1 0 -1 ", 8) # Vertical (Sobel) Edge Detection:
edges = Q.ConvertToYV24.AverageLuma
if(Edges > BestEdge) {
BestEdge = Edges
BestRX = RX
BestBX = BX
}
RT_Subtitle("%d] RX=%f, BX=%f Edges=%f\nBestEdge=%f BestRX=%f BestBX=%f",n,RX,BX,Edges,BestEdge,BestRX,BestBX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
It dont seem to work too well, maybe is something 'not quite right' with this clip, maybe requires RaffRiff additional args to ShiftRedBlue
to resize as well as shift.
StainlessS
21st July 2021, 13:23
Nah, my guess dont seem to work too well.
Using this image [Spider_ORG.JPG, click to view and download]:-
https://i.postimg.cc/XXDN6j2m/Spider-ORG.jpg (https://postimg.cc/XXDN6j2m)
EDIT: Script Removed
Where our test shift uses
TEST_RX = -3.75
TEST_BX = 4.25
we expect to get opposite shifts, ie
TEST_RX = 3.75
TEST_BX = -4.25
but we dont.
Sad but there you go :(
EDIT: WAS error in script, will repost without error.
StainlessS
21st July 2021, 13:55
Prev post script was in error, fixed below and works as expected.
Using this image [Spider_ORG.JPG, click to view and download full sized image]:-
https://i.postimg.cc/XXDN6j2m/Spider-ORG.jpg (https://postimg.cc/XXDN6j2m)
Where our test shift uses
TEST_RX = -3.75
TEST_BX = 4.25
we expect to get opposite shifts, ie
TEST_RX = 3.75
TEST_BX = -4.25
Import(".\ShiftStuff.avsi")
# Next Min, Max and PEL values MUST be Type Int
RMIN = -5 RMAX = 5
BMIN = -5 BMAX = 5
PEL = 4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
SHOWEDGE = False # Shows Edgemask instead of shifted result if true
RRNG = RMAX - RMIN
BRNG = BMAX - BMIN
ZR = RRNG * PEL + 1
ZB = BRNG * PEL + 1
END = ZR * ZB - 1
#ImageSource(".\LluYpS5q.png",End=END)
ImageSource(".\Spider_Org.jpg",End=END)
ConvertToPlanarRGB
#CROP(1200,100,0,600) # Windows only
TEST_RX = -3.75
TEST_BX = 4.25
ShiftRedBlue(rx=TEST_RX,bx=TEST_BX)
O=Last
BestEdge = 0.0
BestRX = 0.0
BestBX = 0.0
SSS="""
n = current_frame
RXI = n / ZB
BXI = n % ZB
RX = RXI / PEL.Float + RMIN
BX = BXI / PEL.Float + BMIN
ShiftRedBlue(rx=RX,bx=BX)
Q=GreyScale
Q=Q.GeneralConvolution(0, "1 0 -1 2 0 -2 1 0 -1 ") # Vertical (Sobel) Edge Detection:
edges = Q.ConvertToYV24.AverageLuma
if(Edges > BestEdge) {
BestEdge = Edges
BestRX = RX
BestBX = BX
}
(SHOWEDGE) ? Q : Last
RT_Subtitle("%d] RX=%f, BX=%f Edges=%f\nBestEdge=%f BestRX=%f BestBX=%f",n,RX,BX,Edges,BestEdge,BestRX,BestBX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
And it nails it exactly
With the test stuff removed,
Import(".\ShiftStuff.avsi")
# Next Min, Max and PEL values MUST be Type Int
RMIN = -5 RMAX = 5
BMIN = -5 BMAX = 5
PEL = 4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
SHOWEDGE = False # Shows Edgemask instead of shifted result if true
RRNG = RMAX - RMIN
BRNG = BMAX - BMIN
ZR = RRNG * PEL + 1
ZB = BRNG * PEL + 1
END = ZR * ZB - 1
ImageSource(".\LluYpS5q.png",End=END)
ConvertToPlanarRGB
CROP(1200,100,0,600) # Windows only
O=Last
BestEdge = 0.0
BestRX = 0.0
BestBX = 0.0
SSS="""
n = current_frame
RXI = n / ZB
BXI = n % ZB
RX = RXI / PEL.Float + RMIN
BX = BXI / PEL.Float + BMIN
ShiftRedBlue(rx=RX,bx=BX)
Q=GreyScale
Q=Q.GeneralConvolution(0, "1 0 -1 2 0 -2 1 0 -1 ") # Vertical (Sobel) Edge Detection:
edges = Q.ConvertToYV24.AverageLuma
if(Edges > BestEdge) {
BestEdge = Edges
BestRX = RX
BestBX = BX
}
(SHOWEDGE) ? Q : Last
RT_Subtitle("%d] RX=%f, BX=%f Edges=%f\nBestEdge=%f BestRX=%f BestBX=%f",n,RX,BX,Edges,BestEdge,BestRX,BestBX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
we still dont get good result on the original problem image, which could mean that is UV shift, or that there is something else a bit
peculiar about the image. [maybe resized as well as shifted].
kedautinh12
21st July 2021, 13:58
I think ShiftUV and ShiftRedBlue don't work well with tiny windows above in example image in post 1
StainlessS
21st July 2021, 14:08
That is just a thumbnail image, You need to download the image, click on it and download from the image host.
And with the prev post test script #1, it works perfectly to detect exact shift required. [try it with some other image if you like]
kedautinh12
21st July 2021, 14:24
In big windows you cropped, i used very good but in small windows above students, i seen don't work well. And i downloaded video sample
kedautinh12
21st July 2021, 14:26
Oh, the script edited i won't test. I will report after test
kedautinh12
22nd July 2021, 06:34
script work well but shiftUV still don't fix. this is best value i can try
https://i.postimg.cc/Fd5pQ4qY/Best-value.png (https://postimg.cc/Fd5pQ4qY)
script:
# Next Min, Max and PEL values MUST be Type Int
UMIN = -5 UMAX = 5
VMIN = -5 VMAX = 5
PEL = 4 # 4 = quarter pixel shifts, 1 = whole pixel shifts only
SHOWEDGE = False # Shows Edgemask instead of shifted result if true
URNG = UMAX - UMIN
VRNG = VMAX - VMIN
ZU = URNG * PEL + 1
ZV = VRNG * PEL + 1
END = ZU * ZV - 1
ImageSource("C:\Users\84945\Downloads\LluYpS5q.png",End=END)
ConvertToYV24
#CROP(1200,100,0,600) # Windows only
TEST_UX = -3.75
TEST_VX = 4.25
ShiftUV(UX=TEST_UX,VX=TEST_VX)
O=Last
BestEdge = 0.0
BestUX = 0.0
BestVX = 0.0
SSS="""
n = current_frame
UXI = n / ZV
VXI = n % ZV
UX = UXI / PEL.Float + UMIN
VX = VXI / PEL.Float + VMIN
ShiftUV(UX=UX,VX=VX)
Q=GreyScale
Q=Q.GeneralConvolution(0, "1 0 -1 2 0 -2 1 0 -1 ") # Vertical (Sobel) Edge Detection:
edges = Q.ConvertToYV24.AverageLuma
if(Edges > BestEdge) {
BestEdge = Edges
BestUX = UX
BestVX = VX
}
(SHOWEDGE) ? Q : Last
RT_Subtitle("%d] UX=%f, VX=%f Edges=%f\nBestEdge=%f BestUX=%f BestVX=%f",n,UX,VX,Edges,BestEdge,BestUX,BestVX)
Return last
"""
ScriptClip(SSS)
StackHorizontal(O,Last)
StainlessS
22nd July 2021, 10:23
EDIT: For RB shift only [would not work for UV shift],
Just a thought, maybe if during scan, you convert frame to grayscale temp, and somehow find a single value for edges [would that be vertical edges when shift horizontal ???],
and choose best [greatest magnitude of edges] as being the best shift.
No idea how to do that nor if would work ok. [where is RaffRiff42 when you need him].
Suugestions for above in blue welcome.
As in Red above.
Only works where all 3 channels of RGB are used to find edge mask, processing in YUV would handle each channel separately, ie Y edges, U edges, V edges. I even tried combining into RGB temp, and it just dont work well, only works for RGB shift.
[EDIT: I know it will not work but I'm not sure how to properley describe the reason].
EDIT: And there seems to be something more weird about that purple edges clip, does not seem to be simple RGB shift.
EDIT: If it is an RGB shift, then maybe have to also use these other RaffRiff42 args
# Must use Planar RGB
##################################
### shift and/or resize Red and Blue relative to Green
## (RGB24, RGB32, RGB48, RGB64, RGB10/12/14/16/32, RGBA10/12/14/16/32)
##
## @ rx, ry, bx, by - ± "shift" red & blue position
## @ rxd, ryd, bxd, byd - ± "delta" width & height for advanced convergence
##
count me out of that, I dont fancy playing with those argments at all :(
wonkey_monkey
22nd July 2021, 12:17
[EDIT: I know it will not work but I'm not sure how to properly describe the reason].
Because YUV doesn't separate colours by frequency, so each channel will exhibit a mix of shifts, since each channel is dependent on all three of R G and B?
EDIT: And there seems to be something more weird about that purple edges clip, does not seem to be simple RGB shift.
It's not a shift. The main distortion is that the green channel is slightly scaled down compared to red and blue (plus other distortions).
kedautinh12
22nd July 2021, 12:44
How about ShiftRBG???
StainlessS
22nd July 2021, 14:45
Thanks Wonkey, you encapsulated it nicely.
Does the RB shift Vertical Edge detect thingy meet with your approval, or have I just been fortunate on the single frame that I tried ?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.