View Full Version : Reduce Crosstalk in 3D Stereo Pairs
Jeremy Duncan
13th December 2010, 23:16
"You can eliminate ghosting without modifying contrast by
adding ghosting in reversed or negative form.
RealD even filed a patent on that although it was published long before in public domain so the patent is useless but RealD investors do not know that.
Mathew Orman"
Link (http://www.avsforum.com/avs-vb/showthread.php?p=19640258#post19640258)
So, I made a 2D source 3D using conversion.
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
left=directshowsource("C:\Users\Jeremy\Desktop\D H.avi", audio=false, 23.976).crop(48, 0, 0, 0)
right=directshowsource("C:\Users\Jeremy\Desktop\D H.avi", audio=false, 23.976).crop(0, 0, -48, 0)
return stackhorizontal(left, right).converttoyv12()
I sed this code for my stereo pairs source for my next script below:
bad code removed.
What this script does is first it adds the stereo pairs.
Then using levels it finds the difference between the pictures.
Then using dehalo alpha it dehalos the difference it found using levels.
Then it adds back in the levels.
Then it adds this to the left and right side of the stereo pair.
Then it stacks the picture horizontally.
I'm posting this here to make sure I wrote it out correctly, and to also ask how to use dehalo alpha to do what I want it to.
I want to add the inverse effect of luma, or anti luma, to the picture where I use dehalo alpha. But I don't know how? Would I just dehalo until there is no luma left?
Also I think I added the levels back in incorrectly.
Didée
14th December 2010, 00:11
To start with, I don't see how you think to get a "3D stereo pair" from spatial offsetting of one single picture. For a 3D illusion, you need 2 pictures that are different.
Next, I'm even more lost what you are trying to achieve with dehalo_alpha.
What I do know is that theoretical effect of inverse ghosting. Par ex, some normconversion boxes use this kind of "feature". Actually, it doesn't help awfully much on reducing the observed ghosting. What it does achieve, however, is to force blend-reversal scripts ala SRestore into epic failure ... :devil:
Also I think I added the levels back in incorrectly.
Also I think that script doesn't make any sense at all.
left = [VideoSource]
3 = 1.Filter()
6 = 3.left
I.) Numbers are no valid names for clip variables
II.) Even if they were, that script would try to use an identifier [ left={videoclip} ] as an operator [ 6 = 3.left ]
/methinks you should sleep a night on it. ;)
Jeremy Duncan
14th December 2010, 07:06
Edit, Funny code removed, and some notes. The notes were moved to the post below.
Gavino
14th December 2010, 17:11
This code below was really slow.
Do you really think applying DeHalo_Alpha twenty times in succession achieves anything useful?
Jeremy Duncan
14th December 2010, 21:26
Well, I was hoping rather optimistically.
I got results using the code below. The lower the level is in layer the lighter the shade is between the layer.
loadplugin("C:\Program Files\AviSynth 2.5\plugins\DirectShowSource.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE2.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools-25.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\MT.dll")
setmtmode(2)
setmemorymax(1024)
left=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
right=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 241)
Layer(left, right, op = "darken", level = 57, use_chroma = True, threshold=50).converttoyv12()
DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
GetMTMode(false) > 0 ? distributor() : last
converttoyv12()
What do you think of this one, Gavino?
Gavino
14th December 2010, 21:47
Well, I can see that it will be faster than your previous version.
But I can't say much about your script as I don't really understand what you're trying to do.
Jeremy Duncan
17th December 2010, 07:51
What happens is the two stereo sides are layered, and the layer shows as a light halo.
This is to offset the crosstalk done by dark objects in the picture.
Updated script. December 16, 2010
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemoveGrainSSE2.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\MT.dll")
setmtmode(2)
setmemorymax(1024)
left=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
right=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
one = Layer(left, right, op = "lighten", level = 35, use_chroma = True, threshold=23).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
lefttwo=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
righttwo=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
two = Layer(lefttwo, righttwo, op = "lighten", level = 35, use_chroma = True, threshold=23).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
stackhorizontal(one, two).converttoyv12()
GetMTMode(false) > 0 ? distributor() : last
Threshold: Is what makes the overlapping picture whiter or darker. Set too low and not only is the picture overla[ very white, but you have lots of artifacts.
Level: Is the whiteness of the picture overlap.
op: is set to darken - which means the overlapping picture is a dark halo, or lighten - which means the opverlapping halo is white.
To test this script, you need to do these steps.
1.) install the sw.
2.) install the plugins (c:\program\avisynth\plugins folder), and then replace the avisynth.dll in the system32 (for 32 bit os), or syswow64 folder(for 64 bit os).
Watch youtube video for how to install the plugins (http://www.youtube.com/watch?v=FspXsD5ky5Y)
3.) demux video using TSmuxer.
4.) Now assuming your working with mp4, h.264 video. You need to run them through mkvmerge to assign a framerate to it.
So open mkvmerge and the video you demuxed, highlight the video and set the framerate in the tabs using a timecode, and set the video to mp4v.
I'll attach a Timecode file.
5.) now drag and drop the mkv video mkvmerge made into graphedit. Highlight the decoder at the end of the string of pop up boxes and delete it using the edit tab, Save as grf.
6.) Add the grf into the avs file and the location of the grf file and open the avs file in virtualdub and crop the side by side video. 'Direct Stream Copy' is what Virtual Dub terms Lossless, or Hi-Fi, video Quality.
Use this crop code below:
These codes assume the source is a squished horizontally, 1920, 1080 video.
Crop off left side of sbs video
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
directshowsource("C:\Users\Setting\Desktop\3.GRF", audio=false, 29.970).crop(960, 0, -0, -0)
converttoyv12()
Crop off right side of sbs video
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
directshowsource("C:\Users\Setting\Desktop\3.GRF", audio=false, 29.970).crop(0, 0, -960, -0)
converttoyv12()
7.) Add these avi's in the avs file, and open this avs file with Megui. Encode the file. Then mux in the audio using megui muxer.
And your done. From the megui tools tab is a muxer, choose mp4, and add the video you just encoded and the audio, enqueue, and press start and it's all done.
Link to Youtube Video that shows all the steps I took to encode. (http://www.youtube.com/watch?v=gJdgUf1kGFI)
Here is the sample Links, you need a stereo pair, a 2D to 3D pair doesn't work effectively:
Left side (http://www.mediafire.com/?545rgfber9cw29q)
right side (http://www.mediafire.com/?py3zcb17v8zhacn)
ac3 track to mux into left right side. (http://www.mediafire.com/?c88ld35puava6m2)
For windows 7 and megui windows 7 uses it's own mp4 codec, and it's not as good as the one from ffdshow.
Open windsfiltertweaker and set: h.264, mp4v, vc1 to ffdshow.
In ffdshow vfw configuration, go to the codecs tab.
Set vc1 to wmv9, and set raw video to All Supported. Click Apply and OK.
And your all set when your using Windows 7.
I made a new video that uses this script: Link to video (http://www.mediafire.com/?rr729q57v1og39f)
It's 1080p, 16:9 aspect ration, Side by Side, Left side first.
I found that using MT while cropping a stereo pair when using Virtuldub made the resulting video stutter badly.
So anytime I use virtualdub and the video it makes stutters, I remove the MT from the avs file and it runs smooth again.
The avs files in the sw kit aren't the ones in this post - they are older scripts that don't work.
Just copy and paste the new scripts into the files in the sw kit and your fine.
Edit,
I don't know why, but the above script stopped working on a test clip with 6006 frames. It worked fine on a test clip with 4001 frames - that clip used Trim to trim 6006 frames to 4001 frames.
So this new script (below) was made using the test clip with 6006 frames, the previous script (above) was made with the test clip that had 4001 frames:
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemoveGrainSSE2.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\MT.dll")
setmtmode(2)
setmemorymax(1024)
left=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
right=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
one = Layer(left, right, op = "lighten", level = 45, use_chroma = True, threshold=35).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
lefttwo=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
righttwo=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
two = Layer(lefttwo, righttwo, op = "lighten", level = 45, use_chroma = True, threshold=35).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
stackhorizontal(one, two).converttoyv12()
GetMTMode(false) > 0 ? distributor() : last
So the moral of this story is that if one script works the other may not. So try the first one and if it doesn't show a overlapping picture, use the second script.
Edit,
No, I just checked out the clip again and it barely shows any overlapping. Just when the gun barrels are showing in a close up, and one or two other places. The second script I made above is much better for showing a overlapping picture.
I would encode it but I think it's good to let you do that. It works, you can use the first one which barely works, or the second one which really shows overlapping.
Edit,
Here's that sample that uses the second code: Link (http://www.filefactory.com/file/b4becg8/n/Franklins-muxed.mp4)
16:9, SbS, left side first, 1080p squished.
virtualdub
http://virtualdub.sourceforge.net/
ffdshow
http://ffdshow-tryout.sourceforge.net/
avisynth
http://sourceforge.net/projects/avisynth2/
haali media splitter
http://haali.su/mkv/
mkvmerge
http://www.videohelp.com/tools/MKVtoolnix
graphedit
http://www.videohelp.com/tools/GraphEdit
tsmuxer
http://www.smlabs.net/tsmuxer_en.html
megui
http://sourceforge.net/projects/megui/
plugins
http://www.mediafire.com/?f2cr1rq191x2wk6
Jeremy Duncan
19th December 2010, 05:42
[QUOTE=Jeremy Duncan;1464647]What happens is the two stereo sides are layered, and the layer shows as a light halo.
This is to offset the crosstalk done by dark objects in the picture.
Updated script. December 16, 2010
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemoveGrainSSE2.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\MT.dll")
setmtmode(2)
setmemorymax(1024)
left=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
right=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
one = Layer(left, right, op = "lighten", level = 35, use_chroma = True, threshold=23).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
lefttwo=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
righttwo=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
two = Layer(lefttwo, righttwo, op = "lighten", level = 35, use_chroma = True, threshold=23).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
stackhorizontal(one, two).converttoyv12()
GetMTMode(false) > 0 ? distributor() : last
Threshold: Is what makes the overlapping picture whiter or darker. Set too low and not only is the picture overla[ very white, but you have lots of artifacts.
Level: Is the whiteness of the picture overlap.
op: is set to darken - which means the overlapping picture is a dark halo, or lighten - which means the opverlapping halo is white.
To test this script, you need to do these steps.
1.) install the sw.
2.) install the plugins (c:\program\avisynth\plugins folder), and then replace the avisynth.dll in the system32 (for 32 bit os), or syswow64 folder(for 64 bit os).
Watch youtube video for how to install the plugins (http://www.youtube.com/watch?v=FspXsD5ky5Y)
3.) demux video using TSmuxer.
4.) Now assuming your working with mp4, h.264 video. You need to run them through mkvmerge to assign a framerate to it.
So open mkvmerge and the video you demuxed, highlight the video and set the framerate in the tabs using a timecode, and set the video to mp4v.
I'll attach a Timecode file.
5.) now drag and drop the mkv video mkvmerge made into graphedit. Highlight the decoder at the end of the string of pop up boxes and delete it using the edit tab, Save as grf.
6.) Add the grf into the avs file and the location of the grf file and open the avs file in virtualdub and crop the side by side video. 'Direct Stream Copy' is what Virtual Dub terms Lossless, or Hi-Fi, video Quality.
Use this crop code below:
These codes assume the source is a squished horizontally, 1920, 1080 video.
Crop off left side of sbs video
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
directshowsource("C:\Users\Setting\Desktop\3.GRF", audio=false, 29.970).crop(960, 0, -0, -0)
converttoyv12()
Crop off right side of sbs video
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
directshowsource("C:\Users\Setting\Desktop\3.GRF", audio=false, 29.970).crop(0, 0, -960, -0)
converttoyv12()
7.) Add these avi's in the avs file, and open this avs file with Megui. Encode the file. Then mux in the audio using megui muxer.
And your done. From the megui tools tab is a muxer, choose mp4, and add the video you just encoded and the audio, enqueue, and press start and it's all done.
Link to Youtube Video that shows all the steps I took to encode. (http://www.youtube.com/watch?v=gJdgUf1kGFI)
Here is the sample Links, you need a stereo pair, a 2D to 3D pair doesn't work effectively:
Left side (http://www.mediafire.com/?545rgfber9cw29q)
right side (http://www.mediafire.com/?py3zcb17v8zhacn)
ac3 track to mux into left right side. (http://www.mediafire.com/?c88ld35puava6m2)
For windows 7 and megui windows 7 uses it's own mp4 codec, and it's not as good as the one from ffdshow.
Open windsfiltertweaker and set: h.264, mp4v, vc1 to ffdshow.
In ffdshow vfw configuration, go to the codecs tab.
Set vc1 to wmv9, and set raw video to All Supported. Click Apply and OK.
And your all set when your using Windows 7.
I made a new video that uses this script: Link to video (http://www.mediafire.com/?rr729q57v1og39f)
It's 1080p, 16:9 aspect ration, Side by Side, Left side first.
I found that using MT while cropping a stereo pair when using Virtuldub made the resulting video stutter badly.
So anytime I use virtualdub and the video it makes stutters, I remove the MT from the avs file and it runs smooth again.
The avs files in the sw kit aren't the ones in this post - they are older scripts that don't work.
Just copy and paste the new scripts into the files in the sw kit and your fine.
Edit,
I don't know why, but the above script stopped working on a test clip with 6006 frames. It worked fine on a test clip with 4001 frames - that clip used Trim to trim 6006 frames to 4001 frames.
So this new script (below) was made using the test clip with 6006 frames, the previous script (above) was made with the test clip that had 4001 frames:
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DirectShowSource.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\RemoveGrainSSE2.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\MT.dll")
setmtmode(2)
setmemorymax(1024)
left=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
right=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
one = Layer(left, right, op = "lighten", level = 45, use_chroma = True, threshold=35).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
lefttwo=directshowsource("E:\Right.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 255)
righttwo=directshowsource("E:\Left.avi", audio=false, 29.970).converttoyuy2().Levels(0, 1.0, 255, 0, 220)
two = Layer(lefttwo, righttwo, op = "lighten", level = 45, use_chroma = True, threshold=35).converttoyv12().DeHalo_alpha(rx=0.4,ry=0.4,darkstr=1.0,brightstr=1.0,lowsens=50,highsens=50, ss=1.5)
stackhorizontal(one, two).converttoyv12()
GetMTMode(false) > 0 ? distributor() : last
So the moral of this story is that if one script works the other may not. So try the first one and if it doesn't show a overlapping picture, use the second script.
Edit,
No, I just checked out the clip again and it barely shows any overlapping. Just when the gun barrels are showing in a close up, and one or two other places. The second script I made above is much better for showing a overlapping picture.
I would encode it but I think it's good to let you do that. It works, you can use the first one which barely works, or the second one which really shows overlapping.
Edit,
Here's that sample that uses the second code: Link (http://www.filefactory.com/file/b4becg8/n/Franklins-muxed.mp4)
16:9, SbS, left side first, 1080p squished.
virtualdub
http://virtualdub.sourceforge.net/
ffdshow
http://ffdshow-tryout.sourceforge.net/
avisynth
http://sourceforge.net/projects/avisynth2/
haali media splitter
http://haali.su/mkv/
mkvmerge
http://www.videohelp.com/tools/MKVtoolnix
graphedit
http://www.videohelp.com/tools/GraphEdit
tsmuxer
http://www.smlabs.net/tsmuxer_en.html
megui
http://sourceforge.net/projects/megui/
plugins
http://www.mediafire.com/?7uifdfw2zy9pp3b
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.