VideoHelp Forum
+ Reply to Thread
Results 1 to 17 of 17
Thread
  1. Is there an easy way (ideally through the use of automatic software) to align two versions of the same frame that have different framing and/or sizes? I can't afford Photoshop, and I've never been able to figure out how to use Avisynth.

    I've been trying to manually crop and resize some versions of such frames to match different versions, but I can never get them to quite line up. I need an automatic solution.

    Here is an example of what I mean by two versions of the same frame (I'd like to be able to resize and crop the former one to perfectly match the latter.):



    Quote Quote  
  2. Originally Posted by hbenthow View Post
    Is there an easy way (ideally through the use of automatic software) to align two versions of the same frame that have different framing and/or sizes? I can't afford Photoshop, and I've never been able to figure out how to use Avisynth.
    "easy and automatic"??? - Not really, or not any that ensures "good" results everytime. The reason is there are many different types of cases. But the main categories are linear scaling and manipulations vs. non linear scaling or distortions/warping

    Cases can be more difficult when there issues like slight warping, non linear resizing. eg. Maybe one version warped when going slightly off through a scanner, or one has lens distortion etc...). Those require photoshop or some manual control point alignment like hugin, and need to be done per scene or even more frequently

    PS can (automatically) handle some types distortions, and there are manual/semi manual methods with hugin and manual control points

    avisynth has an almost pure automatic with the autooverlay plugin. But it does not handle distortions . It should have worked here, but it was a bit off in your example, even though it was linear scaling (see below). It might be I didn't use the correct settings, there are many settings.
    https://forum.doom9.org/showthread.php?t=175247
    https://github.com/introspected/AutoOverlay

    avisynth can make use of hugin with a plugin called warp . In the tutorial you can see David match the DVD and BD version of a scene.
    https://forum.doom9.org/showthread.php?t=176031
    https://www.youtube.com/watch?v=SG1eex7HmLM




    I've been trying to manually crop and resize some versions of such frames to match different versions, but I can never get them to quite line up. I need an automatic solution.

    Here is an example of what I mean by two versions of the same frame (I'd like to be able to resize and crop the former one to perfectly match the latter.):
    Yes, in all cases, I would try to match it manually first. Because it's actually the easiest to get a good match if linear scaling was used.

    And the example you posted is just linear scaling. From the scaling center. It's 104.7% width, 104.7% height, and you can crop and add or overlay borders if you want

    In the grand scheme of things, this example is "easy". If your shots were done the same way in post, you can set one number and you're done

    It's easier to do with a GUI, such as the free versions of hitfilm, resolve etc... or natron - because you can toggle on/off the layer and see if it matches and how well it is superimposed. You can easily check different parts of movie, different scenes

    104.7% width, 104.7 height
    Image
    [Attachment 51106 - Click to enlarge]


    132px borders top and bottom
    Image
    [Attachment 51107 - Click to enlarge]
    Last edited by poisondeathray; 15th Dec 2019 at 22:48.
    Quote Quote  
  3. pretty close:

    Code:
    bg = ImageSource("a.jpg", start=0, end=23, fps=23.976) 
    ov = ImageSource("b.jpg", start=0, end=23, fps=23.976).Crop(0,132,-0,-132).Spline36Resize(1836, 780)
    
    Overlay(bg, ov, x=42, y=150)
    
    Interleave(bg,last)
    Quote Quote  
  4. Originally Posted by poisondeathray View Post
    And the example you posted is just linear scaling. From the scaling center. It's 104.7% width, 104.7% height, and you can crop and add or overlay borders if you want
    Thank you.


    Originally Posted by jagabo View Post
    pretty close:

    Code:
    bg = ImageSource("a.jpg", start=0, end=23, fps=23.976) 
    ov = ImageSource("b.jpg", start=0, end=23, fps=23.976).Crop(0,132,-0,-132).Spline36Resize(1836, 780)
    
    Overlay(bg, ov, x=42, y=150)
    
    Interleave(bg,last)
    What program is this code for?
    Quote Quote  
  5. Originally Posted by hbenthow View Post
    Originally Posted by poisondeathray View Post
    And the example you posted is just linear scaling. From the scaling center. It's 104.7% width, 104.7% height, and you can crop and add or overlay borders if you want
    Thank you.


    Originally Posted by jagabo View Post
    pretty close:

    Code:
    bg = ImageSource("a.jpg", start=0, end=23, fps=23.976) 
    ov = ImageSource("b.jpg", start=0, end=23, fps=23.976).Crop(0,132,-0,-132).Spline36Resize(1836, 780)
    
    Overlay(bg, ov, x=42, y=150)
    
    Interleave(bg,last)
    What program is this code for?
    The one you can't figure out, AviSynth.
    Quote Quote  
  6. Originally Posted by jagabo View Post
    The one you can't figure out, AviSynth.
    Some day, I might take another crack at Avisynth, but I've never been able to successfully use it yet. Thank you for the code, though. I might be able to use it if I ever successfully learn how to use Avisynth.
    Quote Quote  
  7. Originally Posted by hbenthow View Post
    Originally Posted by jagabo View Post
    The one you can't figure out, AviSynth.
    Some day, I might take another crack at Avisynth, but I've never been able to successfully use it yet. Thank you for the code, though. I might be able to use it if I ever successfully learn how to use Avisynth.
    Here's what the result looked like. I only scaled and overlaid the smaller image. I made no attempt to adjust levels, colors, etc.

    Image
    [Attachment 51109 - Click to enlarge]


    Buy the way, using this script is trivial. Install AviSynth. Put the script (use Notepad to create it, specify .AVS as the extension when you save) and the two images in the same folder (I renamed them a.jpg and b.jpg when I downloaded them). Open the AVS script in an editor that supports AviSynth -- like VirtualDub2.
    Last edited by jagabo; 16th Dec 2019 at 13:21.
    Quote Quote  
  8. Originally Posted by jagabo View Post
    Here's what the result looked like. I only scaled and overlaid the smaller image. I made no attempt to adjust levels, colors, etc.

    Image
    [Attachment 51109 - Click to enlarge]
    That's not what I'm trying to do, though. The results that poisondeathray achieved (resizing the first image to match the second) are what I've been trying to achieve.
    Quote Quote  
  9. Inverting the script to do the opposite is pretty simple:

    Code:
    bg = ImageSource("C:\Users\John\Desktop\a.jpg", start=0, end=23, fps=23.976) 
    ov = ImageSource("C:\Users\John\Desktop\b.jpg", start=0, end=23, fps=23.976)
    
    bg.Crop(42,150,1836,780).Spline36Resize(1920,816).AddBorders(0,132,0,132)
    Interleave(ov,last)
    Last edited by jagabo; 16th Dec 2019 at 18:54.
    Quote Quote  
  10. Originally Posted by jagabo View Post
    Inverting the script to do the opposite is pretty simple:

    Code:
    bg = ImageSource("C:\Users\John\Desktop\a.jpg", start=0, end=23, fps=23.976) 
    ov = ImageSource("C:\Users\John\Desktop\b.jpg", start=0, end=23, fps=23.976)
    
    bg.Crop(42,150,1836,780).Spline36Resize(1920,816).AddBorders(0,132,0,132)
    Interleave(ov,last)
    That would achieve the results that poisondeathray was able to get?
    Quote Quote  
  11. I think the width is a bit off in jagabo's script. A bit too skinny, horizontally compressed

    This is a bit closer for avisynth, almost as close as the 104.7% . calculated the numbers for avisynth's resize using the same multiplier: 1920*1.047 = 2010.24 , 1080*1.047 = 1130.76 . But they are rounded to whole numbers (2010,1130). It has to be RGB or YUV444 because of the 1px crops, and it's rounded

    Code:
    ImageSource("u6rvG6i6_o.jpg")
    b=157
    spline36resize(2010,1130)
    crop(0,b,0,-b,true)
    addborders(0,b,0,b)
    crop(45,25,-45,-25,true)
    I don't know how to do the exactly equivalent sort of decimal place subpixel sizes and shifting in avisynth, instead of rounding. I think that's where the slight errors are from

    EDIT: but it should be possible , because the avisynth resizers have src_left, src_top, src_width, src_height parameters that can take decimal values for subpixel shifting
    Last edited by poisondeathray; 16th Dec 2019 at 20:46.
    Quote Quote  
  12. Originally Posted by poisondeathray View Post
    I think the width is a bit off in jagabo's script. A bit too skinny, horizontally compressed

    This is a bit closer for avisynth, almost as close as the 104.7% . calculated the numbers for avisynth's resize using the same multiplier: 1920*1.047 = 2010.24 , 1080*1.047 = 1130.76 . But they are rounded to whole numbers (2010,1130). It has to be RGB or YUV444 because of the 1px crops, and it's rounded

    Code:
    ImageSource("u6rvG6i6_o.jpg")
    b=157
    spline36resize(2010,1130)
    crop(0,b,0,-b,true)
    addborders(0,b,0,b)
    crop(45,25,-45,-25,true)
    I don't know how to do the exactly equivalent sort of decimal place subpixel sizes and shifting in avisynth, instead of rounding. I think that's where the slight errors are from
    Thank you. I'm not very well-versed in using Avisynth, so I don't understand any of this very well. But if I get the hang of using Avisynth, it will hopefully be useful.
    Quote Quote  
  13. I made an edit above; it should be possible to get a match in avisynth similar to that 104.7 result, because of the src_left, src_top, src_width, src_height parameters can take decimal values . I don't find it "easy" to play around with those four values, it's not very intuitive for me.

    For me, this sort of thing is way easier in a GUI, where you can toggle visibility easily, make changes easily. You can do a more accurate check by setting the layer mode to "difference". This makes it easier to see differences. So that will show you how to change it, eg. if you increase it by +0.1% scale for width over a certain value, but differences become larger, you are going the wrong way. You can do similar in avisynth with layer modes and avspmod and tabs (pusing the number keys can be setup like toggling visibility for that layer), or jagabo used interleave (advancing the frames will alternate versions), but changing values in avisynth is more of a pain; the feedback isn't as instant as some GUI
    Quote Quote  
  14. Originally Posted by poisondeathray View Post
    For me, this sort of thing is way easier in a GUI, where you can toggle visibility easily, make changes easily. You can do a more accurate check by setting the layer mode to "difference". This makes it easier to see differences. So that will show you how to change it, eg. if you increase it by +0.1% scale for width over a certain value, but differences become larger, you are going the wrong way.
    I have Vegas Pro 15. Is this possible in it?

    And can it be done in GIMP?
    Quote Quote  
  15. Originally Posted by poisondeathray View Post
    changing values in avisynth is more of a pain; the feedback isn't as instant as some GUI
    Yes a full fledged GUI is easier. Sometimes I use Animate() in AviSynth to check a range of values to find which works best.
    Quote Quote  
  16. Originally Posted by hbenthow View Post
    Originally Posted by poisondeathray View Post
    For me, this sort of thing is way easier in a GUI, where you can toggle visibility easily, make changes easily. You can do a more accurate check by setting the layer mode to "difference". This makes it easier to see differences. So that will show you how to change it, eg. if you increase it by +0.1% scale for width over a certain value, but differences become larger, you are going the wrong way.
    I have Vegas Pro 15. Is this possible in it?

    And can it be done in GIMP?


    vegas for sure, basically any NLE or compositing application. Even free versions like the ones listed above

    Yes, in vegas, you can solo layer, or toggle visibility etc... change layer mode to difference or others to help align

    But the scaling is slightly different in vegas . You use the Event Pan/Crop and either enter the width/height, or just drag the handles or corners in the Event Pan/Crop GUI to do it manually. The difference here is it gives the final width and height. So the values will actually be smaller. They actually work out by dividing, and it gives same results

    1920 / 1.047 =~ 1833.8 width
    1080 / 1.047 =~ 1031.5 height

    The difference with most NLE's / compositing applications, is the project settings can be thought of sort of like a "window" that you're looking through . So if you upscale the dimensions, the layer becomes larger, but you're only "looking through" a 1920x1080 sized (or whatever project settings) window . That window only shows that view, the stuff outside isn't shown in the final render. But in avisynth, if you upscale (or downscale), the "window" becomes that same size too (until you crop or farther resize it)

    But how did I figure out that 1.047? Just manually. It's not too bad when you get used to it, you toggle visibility, make adjustment, check again. Check with difference mode if you want if you have bad eyes or difficult to see differences. Rinse/repeat. Everyone has their own preferences, but for me, the easiest GUI to do these types of things is after effects. Hitfilm is like a clone of AE, and there is a free Hitfilm version . When you get the procedure down, you can tell pretty easily in a minute or so if it fall into category (A) linear or (B) non linear / warping . (B) can be terrible and a nightmare to fix properly. Lots of work

    I'm not a big GIMP user, but it should be possible there too
    Quote Quote  
  17. Originally Posted by poisondeathray View Post
    vegas for sure, basically any NLE or compositing application. Even free versions like the ones listed above

    Yes, in vegas, you can solo layer, or toggle visibility etc... change layer mode to difference or others to help align

    But the scaling is slightly different in vegas . You use the Event Pan/Crop and either enter the width/height, or just drag the handles or corners in the Event Pan/Crop GUI to do it manually. The difference here is it gives the final width and height. So the values will actually be smaller. They actually work out by dividing, and it gives same results

    1920 / 1.047 =~ 1833.8 width
    1080 / 1.047 =~ 1031.5 height

    The difference with most NLE's / compositing applications, is the project settings can be thought of sort of like a "window" that you're looking through . So if you upscale the dimensions, the layer becomes larger, but you're only "looking through" a 1920x1080 sized (or whatever project settings) window . That window only shows that view, the stuff outside isn't shown in the final render. But in avisynth, if you upscale (or downscale), the "window" becomes that same size too (until you crop or farther resize it)

    But how did I figure out that 1.047? Just manually. It's not too bad when you get used to it, you toggle visibility, make adjustment, check again. Check with difference mode if you want if you have bad eyes or difficult to see differences. Rinse/repeat. Everyone has their own preferences, but for me, the easiest GUI to do these types of things is after effects. Hitfilm is like a clone of AE, and there is a free Hitfilm version . When you get the procedure down, you can tell pretty easily in a minute or so if it fall into category (A) linear or (B) non linear / warping . (B) can be terrible and a nightmare to fix properly. Lots of work

    I'm not a big GIMP user, but it should be possible there too
    Thank you.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!