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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th May 2010, 01:29   #1  |  Link
RidgeShark
Registered Amatuer
 
Join Date: Feb 2007
Posts: 20
Auto-alignment?

Is there a filter for avisynth that works similarly to the auto-alignment feature in Photoshop? I'd like to take 2 video transfers of the same movie, and have one aligned to be nearly identical to the corresponding frame of the other. My intended purpose for this is to copy the chroma from one version of a film to another. Here's an example -

VidSource1 -


VidSource2 -


Auto-aligned, merged-chroma, and luma adjustment -



I've looked around and nothing's turned up. Is there anything like this yet for avisynth?

Last edited by RidgeShark; 24th May 2010 at 01:33.
RidgeShark is offline   Reply With Quote
Old 24th May 2010, 03:17   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Wouldn't it be easier to just buy the BluRay?
Guest is offline   Reply With Quote
Old 24th May 2010, 03:39   #3  |  Link
um3k
Registered User
 
Join Date: May 2007
Posts: 220
I imagine you could do it with DepanInterleave and a wee bit of trickery.
um3k is offline   Reply With Quote
Old 24th May 2010, 03:53   #4  |  Link
RidgeShark
Registered Amatuer
 
Join Date: Feb 2007
Posts: 20
Quote:
Originally Posted by neuron2 View Post
Wouldn't it be easier to just buy the BluRay?
Well this was just a fun example. And as far as I know, the 80's colorization of King Kong will never come out on Blu-ray. I'd certainly buy it if it did though. I own two VHS copies and the UK DVD (itself a NTSC->PAL transfer from an old 80's video master) of the colorized version. The quality on those are nowhere near the recently restored black and white versions though, which is just a part of the fun of this little experiment.

A filter like this would be interesting because manually aligning two separate film transfers like these is nearly impossible. There's so many little differences from different telecine equipment that a manual alignment would have to be done by sequence and sometimes frame by frame, and would take ages to do. By automatically aligning the two sources, a great deal could be done with both the luma and chroma channels.

Last edited by RidgeShark; 24th May 2010 at 04:06.
RidgeShark is offline   Reply With Quote
Old 24th May 2010, 04:09   #5  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Fair enough.

I'm not aware of any Avisynth filters that will directly do that.
Guest is offline   Reply With Quote
Old 24th May 2010, 04:46   #6  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Will try this...
May be help to you...

Code:
ColorYUV2(opt="coring", showyuv=false, analyze=false, autowhite=true, autogain=true)
Jenyok is offline   Reply With Quote
Old 24th May 2010, 06:30   #7  |  Link
WorBry
Registered User
 
Join Date: Jan 2004
Location: Here, there and everywhere
Posts: 1,197
I've not actually tried it, but apparently you can use the (absolute) Difference blend mode in Overlay to 'manually' align images with identical visual content. When perfectly aligned, the content outline should turn black. I also included a Difference blend mode in the (YV12 based) Blend_MT function that I put together.

http://forum.doom9.org/showthread.ph...34#post1400434

Again, never tried it in this context. I dont know of an 'auto' equivalent.
__________________
Nostalgia's not what it used to be

Last edited by WorBry; 24th May 2010 at 06:33.
WorBry is offline   Reply With Quote
Old 24th May 2010, 13:33   #8  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 263
Damn! I just wrote you a long detailed set of suggestions, and the damn forum engine swallowed it 'cos it decided I wasn't logged in anymore! (And just for once, I forgot to copy-paste it all into notepad before submitting it... )

If this post works OK, then I'll write it all out again.
pbristow is offline   Reply With Quote
Old 24th May 2010, 13:34   #9  |  Link
Gser
Registered User
 
Join Date: Apr 2008
Posts: 418
Why not just do it in Photoshop? It supports video.
Gser is offline   Reply With Quote
Old 24th May 2010, 13:47   #10  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 263
OK, that worked, let's try again.

Based on WorBry's suggestion, you *could* try using a chain of "?" and ":" (as a "virtual case statement") to compare the images in several different positions, and thus select the offset that works best. You can wrap that into a run-time function and evaluate it agains each frame (or pair of frames). Two problems with that: One is that the chain of comparisons will get very long and run very slowly; the other is that it won't take into account any geometry distortions within the frame. For that, you'd have to split the frame into blocks or regions (with some overlap), compare and adjust them separately, and then merge them back together.

Luckily, there's a toolset that already does these kind of things. We can "misuse" MVtools2.
- First, make the two versions identical in size, with approximately matched positions, and starting on the same frame.
- Interleave the two streams, to create a clip with colour and monochrome pairs of frames.
- Use MAnalyse (with chroma=false) to compare each frame with the one before.
- Use Mcompensate or MFlow to shift blocks/pixels from the colour frames to exactly match the positions in the monochrome frames.
- Use SelectEVen or SelectOdd to pull out just the shifted colour frames from the result.
- Use MergeChroma to add the shifted chroma to the untouched monochrome source.

Good luck!
pbristow is offline   Reply With Quote
Old 24th May 2010, 14:03   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,433
My FindFrame function from this thread, or something like it, might be useful.
Quote:
Originally Posted by pbristow View Post
Damn! I just wrote you a long detailed set of suggestions, and the damn forum engine swallowed it 'cos it decided I wasn't logged in anymore!
After logging in, use the back button on your browser to get back to the text you had.
Gavino is offline   Reply With Quote
Old 24th May 2010, 14:14   #12  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 263
Quote:
Originally Posted by Gavino View Post
My FindFrame function from this thread, or something like it, might be useful.

After logging in, use the back button on your browser to get back to the text you had.

That doesn't always work, and didn't this time (I just got a completely blank input field).
No prob though, I think I actually did a better job of explaining things second time anyway.
pbristow is offline   Reply With Quote
Old 25th May 2010, 03:33   #13  |  Link
RidgeShark
Registered Amatuer
 
Join Date: Feb 2007
Posts: 20
Thank you all for the suggestions. I've tried them all but with no usable results, though I did have some interesting results with pbristow's suggestion. The results were very blocky, but the color source did accurately align with the black and white source - however there were missing colors and lots of color fluctuation. I see a lot of potential with this, but I really don't know how to tweak it to perfection.

If anyone wants to help me experiment, here are two short clips that are frame-matched - http://www.megaupload.com/?d=GI47Y5TD
RidgeShark is offline   Reply With Quote
Old 25th May 2010, 04:24   #14  |  Link
um3k
Registered User
 
Join Date: May 2007
Posts: 220
Try this:

Code:
col = AVISource("C:\Documents and Settings\Justin (um3k)\My Documents\Downloads\experiment\SD.avi")
bw = AVISource("C:\Documents and Settings\Justin (um3k)\My Documents\Downloads\experiment\HD.avi")

colw = col.Width()
colh = col.Height()
bww = bw.Width()
bwh = bw.Height()
borw = (bww-colw)/2
borh = (bwh-colh)/2
col = col.Lanczos4Resize(1100, 756)
col = col.AddBorders((1280-col.Width)/2, (960-col.Height)/2, (1280-col.Width)/2, (960-col.Height)/2, color=$000000)
bwp = bw.AddBorders((1280-bw.Width)/2, (960-bw.Height)/2, (1280-bw.Width)/2, (960-bw.Height)/2, color=$000000)
int = Interleave(bwp,col).ConvertToYV12()
est = int.Greyscale().depanestimate(range=1,pixaspect=1.0,zoommax=1,improve=false,trust=0)
dep = int.depaninterleave(est,pixaspect=1.0,prev=0,next=1,subpixel=2,mirror=0)
acol = dep.SelectEvery(4, 1).Crop(144, 120, 992, 720)
MergeChroma(bw, acol)
It works pretty well on the sample footage, and should work fine on the rest as long as the relative scale remains constant.

EDIT: Of course, replace the clips with the full movie.

Last edited by um3k; 25th May 2010 at 04:46.
um3k is offline   Reply With Quote
Old 29th May 2010, 03:51   #15  |  Link
um3k
Registered User
 
Join Date: May 2007
Posts: 220
RidgeShark, have you tried my script? I'm curious to know whether it worked for the whole video.
um3k is offline   Reply With Quote
Old 1st June 2010, 06:05   #16  |  Link
RidgeShark
Registered Amatuer
 
Join Date: Feb 2007
Posts: 20
I've tried it on a few small sections and it seems to work great. I haven't been able to do the whole film due to lack of time for all the necessary processing.

My copy of the colorized film is from a PAL DVD that was created from an improper NTSC->PAL conversion, so I used Srestore to create 23.976FPS progressive clips to do these tests. I need to apply it to the whole colourized version and then go through both the color and b&w copies and correct any points where they go out of sync. The restored b&w version has some shots that are longer in length by a few frames than the colorized version, which throws everything off.

And being that I am not a very advanced avisynth user, could you possibly explain how your script works? I basically understand it, but not enough to modify it for other videos. Thank you so much for your help.

Last edited by RidgeShark; 1st June 2010 at 06:09.
RidgeShark is offline   Reply With Quote
Old 1st June 2010, 07:48   #17  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
judicious resizing, interleave(a,b) and mvtools will get you there.

i've done something similar with using mvtools to fix a very old (rank mkII maybe?) transfer that had inter-field wobbling such that the picture shook around unbearably.

only gotcha is that you need to make sure both clips are frame-for-frame the same edit, or it'll go pear shaped.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Reply

Tags
auto alignment

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.