Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Jan 2025
Posts: 8
|
Кe-create anaglyph with other colors with AVIsynth
I'm trying to create anaglyph from a video stereo pair using AVIsynth capabilities.
But unfortunately I don't understand how exactly to do this. I have YUY2 binary lookup table files and ddcc.dll v1.7 About ddcc.dll I found on this forum: Code:
rgb3dlut(string lutfile, int itype, int destcs, int threads, double b, double c) PARAMETERS (rgb3dlut): lutfile - RGB lookup table file. RGB Input: The lookup table file should contain 256*256*256 3 byte entries (one for every possible rgb value) stored in binary format. The table should be stored such that the offset into the table in bytes for a given rgb value is calculated as: ((g<<16)+(b<<8)+r)*3 At that location, the new rgb values should be stored in b, g, r order (one byte for each). YUY2 Input: The lookup table file should contain 256*256*256 3 byte entries (one for every possible yuv value) stored in binary format. The table should be stored such that the offset into the table in bytes for a given yuv value is calculated as: ((v<<16)+(u<<8)+y)*3 At that location, the associated rgb value should be stored in b, g, r order (one byte for each). default: "" itype - For yuy2 input this sets how to compute the u/v values for the second y value in each yuyv set. Possible settings: 0 - duplicate (use u/v of first y value) 1 - linear interpolation (average u/v of first y with u/v of first y in next yuyv set) 2 - Mitchell-Netravali two-part cubic (adjustable b/c parameters to adjust blurring/ringing) default: 1 destcs- For yuy2 input, this sets the destination colorspace. Possible settings: 0 - rgb24 1 - rgb32 default: 1 threads - Sets the number of threads to use for processing. If set to 0, then threads is automatically set to the number of detected processors. Range is 0 <= threads <= 16. default: 0 b/c- Adjusts properties of cubic interpolation (itype=2). Same as Avisynth's BicubicResize filter. default: 0.0,0.75 Code:
LoadPlugin("C:\Users\user\megui\tools\avs\plugins\ddcc.dll") L = crop(0, 0, 960, 0) R = crop(960, 0, 0, 0) R = R.rgb3dlut("C:\Users\user\megui\table1.YUV") L = L.rgb3dlut("C:\Users\user\megui\table2.YUV) stackhorizontal(R,L) - Apply a separate LUT to each frame. - Make the frame 50% transparent. (Is this necessary to create an anaglyph? Or is it possible without this?) - Overlay the frame for the right eye on top of the frame for the left. - Save to a separate file. I tried to do something like this, but MeGUI gave an error when executing the "crop" command, the error text was "invalid parameter specified". Maybe I'm using the wrong version, or I should abandon MeGUI. I ask for help from experts. |
![]() |
![]() |
![]() |
#3 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,108
|
I dont see anything wrong with either of the crop lines for the OP.
What does Code:
# BlankClip(length=1,width=1920,height=1080,pixel_type="YUY2") info Also, which original line throws the error ? Additionally in future, when posting problem, try to reduce the problem space, eg Code:
# BlankClip(length=1,width=1920,height=1080,pixel_type="YUY2") L = crop(0, 0, 960, 0) R = crop(960, 0, 0, 0) stackhorizontal(R,L) EDIT: Also, if the error line is L = etc, then try Code:
# BlankClip(length=1,width=1920,height=1080,pixel_type="YUY2") crop(0, 0, 960, 0) Code:
# BlankClip(length=1,width=1920,height=1080,pixel_type="YUY2") crop(960, 0, 0, 0) EDIT: Wild guess, forgot a source filter ![]()
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 7th February 2025 at 12:02. |
![]() |
![]() |
![]() |
#4 | Link | |
Registered User
Join Date: Jan 2025
Posts: 8
|
Quote:
Here is full script Code:
LoadPlugin("C:\Users\[]\Desktop\megui\tools\lsmash\LSMASHSource.dll") LoadPlugin("C:\Users\[]\Desktop\megui\tools\avs\plugins\ddcc.dll") LWLibavVideoSource("C:\Users\[]\Desktop\megui\vid.mkv") yv12toyuy2(2, false, 0, 0.0, 0.75) L = crop(0, 0, -960, 0) R = crop(960, 0, 0, 0) L = L.rgb3dlut("C:\Users\[]\Desktop\megui\table(1).YUV", 1, 1, 0, 0.0, 0.75) R = R.rgb3dlut("C:\Users\[]\Desktop\megui\table(2).YUV", 1, 1, 0, 0.0, 0.75) Overlay(L, R, mode="blend", opacity=0.5) BilinearResize(1920, 1080) info Last edited by McRex; 9th February 2025 at 09:22. |
|
![]() |
![]() |
![]() |
#5 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,108
|
Sorry McRex, I know nothing of 3D stereo stuff, no idea what its supposed to do.
Perhaps someone else can help. {I also dont really have a working avs setup at present, and not done any real processing for at least 6 months, probably longer} ALSO, Perhaps a moderator an approve above post attachments. {or use Postimages.org for free, and post links to the images in your post, Postimage instructions:- https://forum.doom9.org/showthread.p...ge#post1959414 }
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Jan 2025
Posts: 8
|
Thanks for info. I see my attachments did not get moderator attention so here is the images:
Before ![]() After ![]() I did some tests with code above to see where the problem starts. First 6 lines of code works fine and did not change black color. Problem starts with 7th line. I also did some tests with LUT bin files (YUV and RGB), and ALL of them replace BLACK color. I really don't know what to do now... |
![]() |
![]() |
![]() |
#7 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,108
|
Well,
from Wiki (YV12To422) :- http://avisynth.nl/index.php/YV12To422 Code:
YV12To422 (clip, bool "interlaced", int "itype", int "cplace", bool "lshift", bool "yuy2", bool "avx2", bool "threads", float "b", float "c") Code:
yv12toyuy2(2, false, 0, 0.0, 0.75) YV12To422 (interlaced=false,itype=, ..., etc) and retry, and repost if probs EDIT: When giving un-named arguments to a function, they MUST be given in correct order up until the last one that you provide, you cannot just skip some that you think are unimportant. Using Named arguements, you can omit some of the named arguments where they will take default values. Optional arguments always have defaults, non optional ones DO NOT. After your first use of an NAMED Optional arg, ALL further args MUST also be named. (I dont know how/why your arguments are accepted at all, ie initially, 2,false, for bool, int.) Above mentioned YV12To422 has ALL NAMED optional args (except clip), so you can use just the NAMED ones you want to use (and in any order) and others will default. EDIT: All arguments to YV12To422 (except clip, which is NOT optional) are optional named arguements, ie are enclosed in DOUBLE QUOTES {""}. EDIT: Here the function prototype given in an alternative style including the optional arg defaults in BLUE. Code:
YV12To422 (clip, bool "interlaced"=FALSE, int "itype"=2, int "cplace"=((interlaced)?TRUE:FALSE), bool "lshift"=FALSE, bool "yuy2"=TRUE, bool "avx2"=FALSE, bool "threads"=FALSE, float "b"=0.0, float "c"=0.75) After correcting for above, if still probs I'll look at rgb3dlut stuff. EDIT: also Code:
LoadPlugin("C:\Users\[]\Desktop\megui\tools\lsmash\LSMASHSource.dll") LoadPlugin("C:\Users\[]\Desktop\megui\tools\avs\plugins\ddcc.dll") LWLibavVideoSource("C:\Users\[]\Desktop\megui\vid.mkv") yv12toyuy2(2, false, 0, 0.0, 0.75) RETURN LAST # to view output of yv12toyuy2 # ...
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 13th February 2025 at 12:45. |
![]() |
![]() |
![]() |
#9 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,108
|
Me too, but from OP
Code:
YUY2 Input: The lookup table file should contain 256*256*256 3 byte entries (one for every possible yuv value) stored in binary format. The table should be stored such that the offset into the table in bytes for a given yuv value is calculated as: ((v<<16)+(u<<8)+y)*3 At that location, the associated rgb value should be stored in b, g, r order (one byte for each). default: "" Code:
R = R.rgb3dlut("C:\Users\user\megui\table1.YUV") L = L.rgb3dlut("C:\Users\user\megui\table2.YUV)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#10 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,641
|
Try this:
Code:
function Anaglyph(clip c, float "red_weight") { red_weight = Default(red_weight, 0.5) left = c.Crop(0, 0, c.width / 2, 0).ConvertBits(32).ConvertToPlanarRGB() right = c.Crop(c.width / 2, 0, 0, 0).ConvertBits(32).ConvertToPlanarRGB() red = Expr(left.ExtractR, left.ExtractG, left.ExtractB, "x x y z + + 3 / x - " + String(1 - red_weight) + " * +") anaglyph = MergeRGB(red, right, right).BicubicResize(c.width, c.height, b = 0, c = 0.5) return anaglyph.ConvertToYUV420().ConvertBits(8) } src = LWLibavVideoSource("C:\Users\[]\Desktop\megui\vid.mkv") Anaglyph(src) You could also take out the ConvertToYUV420() if you want an RGB result, but in that case you should specify a matrix for both ConvertToPlanarRGB()s (probably rec709). Last edited by wonkey_monkey; 13th February 2025 at 16:30. |
![]() |
![]() |
![]() |
#11 | Link |
Registered User
Join Date: Jan 2025
Posts: 8
|
Thank you for the guidance, it helps me learn more.
As for yv12toyuy2 Code:
Unoptimized yv12 to yuy2 conversion, provides point/linear/adjustable cubic interpolation options. SYNTAX: yv12toyuy2(int itype, bool interlaced, int threads, double b, double c) PARAMETERS (yv12toyuy2): itype - Sets interpolation method. Possible settings: 0 - duplicate 1 - linear interpolation 2 - Mitchell-Netravali two-part cubic (adjustable b/c parameters to adjust blurring/ringing) default: 2 interlaced - Sets whether or not the input video is interlaced or progressive. default: false threads - Sets the number of threads to use for processing. If set to 0, then threads is automatically set to the number of detected processors. Range is 0 <= threads <= 16. default: 0 b/c - Adjusts properties of cubic interpolation (itype=2). Same as Avisynth's BicubicResize filter. default: 0.0,0.75 Code:
LoadPlugin("D:\megui\tools\lsmash\LSMASHSource.dll") LoadPlugin("D:\megui\tools\avs\plugins\ddcc.dll") LWLibavVideoSource("D:\megui\video2.mkv") yv12toyuy2() BilinearResize(1920, 1080) info ![]() All black colors are present and looks nice. As for rgb3dlut() I dont see any way to replace it with something similar.. I replaced the YUV lut files with RGB, but it didn't change anything in the video. Still no black. Code:
L = L.rgb3dlut("D:\megui\calibration-v2\table(1).RGB") R = R.rgb3dlut("D:\megui\calibration-v2\table(2).RGB") ![]() Last edited by McRex; 15th February 2025 at 12:18. |
![]() |
![]() |
![]() |
#13 | Link | ||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,108
|
Looks like cr3dlut is an *.Exe
https://forum.doom9.org/showthread.p...19#post1311919 Quote:
https://forum.doom9.org/showthread.p...88#post1275888 Quote:
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 15th February 2025 at 17:33. |
||
![]() |
![]() |
![]() |
#15 | Link | |
Registered User
Join Date: Jan 2025
Posts: 8
|
Quote:
But I'm curious about MergeRGB it self. Right now I learn more and try to replace Overlay() with MergeRGB in my last post script... |
|
![]() |
![]() |
![]() |
#17 | Link |
Registered User
Join Date: Jan 2025
Posts: 8
|
![]() Code:
LoadPlugin("D:\megui\tools\lsmash\LSMASHSource.dll") function Anaglyph(clip c, float "red_weight") { red_weight = Default(red_weight, 0.5) left = c.Crop(0, 0, c.width / 2, 0).ConvertBits(32).ConvertToPlanarRGB() right = c.Crop(c.width / 2, 0, 0, 0).ConvertBits(32).ConvertToPlanarRGB() red = Expr(left.ExtractR, left.ExtractG, left.ExtractB, "x x y z + + 3 / x - " + String(1 - red_weight) + " * +") anaglyph = MergeRGB(red, right, right).BicubicResize(c.width, c.height, b = 0, c = 0.5) return anaglyph.ConvertToYUV420().ConvertBits(8) } src = LWLibavVideoSource("D:\megui\video2.mkv") Anaglyph(src) |
![]() |
![]() |
![]() |
#18 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,641
|
It looks like some updates were made to MergeRGB in Avisynth+ 3.7.2 which may be why the script works for me.
Maybe adding the two lines in bold will work on earlier versions: Code:
function Anaglyph(clip c, float "red_weight") { red_weight = Default(red_weight, 0.5) left = c.Crop(0, 0, c.width / 2, 0).ConvertBits(32).ConvertToPlanarRGB right = c.Crop(c.width / 2, 0, 0, 0).ConvertBits(32).ConvertToPlanarRGB red = Expr(left.ExtractR, left.ExtractG, left.ExtractB, "x x y z + + 3 / x - " + String(1 - red_weight) + " * +") red = red.ConvertToRGB24 right = right.ConvertToRGB24 anaglyph = MergeRGB(red, right, right) return anaglyph.ConvertToYUV420.ConvertBits(8).BicubicResize(c.width, c.height, b = 0, c = 0.5) } src = LWLibavVideoSource("D:\megui\video2.mkv") Anaglyph(src) |
![]() |
![]() |
![]() |
#19 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,465
|
Quote:
https://avisynthplus.readthedocs.io/.../mergergb.html |
|
![]() |
![]() |
![]() |
#20 | Link | |
Registered User
Join Date: Jan 2025
Posts: 8
|
Quote:
|
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|