PDA

View Full Version : Correct resizing to keep aspect ratio and MeGUI results


Skylerlaughs
13th September 2008, 11:20
I would like to explained how I resize and why I have questions about MeGUI's results (great app BTW, if you helped with it thanks for your work).

Starting frame of 16x9 encoded DVD is 720x480 anamorphic.

But the actual 16x9 frame refers to a 710.85x486 frame overlaying the top and centered on the actual 720x480 frame.

For a real height of 486, the width of 710.85 would need to be resized to 864 to correctly uncompress the anamorphic squeeze.

So the width on a DVD encode needs to be multiplied by 1.215446 (width resize constant) to reach the correct aspect ratio.

Since the actual frame has EXTRA width pixels (9.15 of them), these also need to be resized by the width resize constant.

The full resize of a 16x9 DVD is thus 875.121333 (full frame corrected size)

The 480 height does not need to be touched. Although it is different then the real 486 frame, it is not a squeezed version of the 486 frame, but should be thought of as a cropped version. The aspect ratio is correct.

Therefor the correct width for our actual starting height of 480 is still 875.121334 (full frame corrected size).

This gives an aspect ratio constant of 1.823169 (correct 16x9 DVD aspect ratio)

Since we are starting with 480 pixels this is the value we must use to determine any height-width scale factor for cropping before resizing.

When calculating the effect of cropping before resizing, we must consider how many pixel we would have cropped had we done so after instead. So a crop before resize of 100 pixels is equal to a crop of 50 after if we resize the starting height by half. So if we start by cropping 100 pixels, the final image in this case would need to be 50 pixels less then the non-cropped correct final height.

The MeGUI results don't fall within the error margin set in the options screen.

----------------------------

Example resize for V FOR VENDETTA DVD.

starting frame is 720x480.
Correct frame size is 875.121334 by 480

Needed crop for this DVD is 120 pixels.

For a resized vertical of 720 (from expanded size), the correct height would be 394.916667 .

Closest mod 16 size is 400.

Since we are resizing the vertical from 480 to 394.916667 , the resize scale is 0.822743 .

Thus the cropped 120 pixels should result in a 98.729167 pixel smaller image to keep the correct aspect ratio.

Thus the correct height for a 720 width is 394.916667 - 98.729167 = 296.187500 pixels

Nearest mod 16 is 304.

Correct frame is 720x296.187500 = 2.430893 aspect ratio

mod 16 frame is 720x304, giving 2.368421 aspect ratio.

Error is 2.57 percent. This is the result MeGUI gives when set to less then 1 percent aspect error.

------------------------------

Lets try again with a different starting width, lets say 704.

Correct height is 386.140741

120 pixel crop would be 96.535185 after resize.

for a correct frame size of 289.605556

mod 16 is 288

correct aspect ratio is 2.486140

mod 16 is 2.5

error = 0.55 percent, a full 2 percent better then last options. Very good.

--------------------------------------

We can now see that 704x288 is by far the best option for a square pixel resize in this case (crop 120 top and bottom), and does gave less then 1 percent error in aspect ratio.

Since there are large differences in aspect ratio error, it would seem that the MeGUI results need to give more information to the user. May I suggest giving the calculated error amount in the actual AVS script creator resize window?

I have made a simple GUI aspect ratio calculator that does this for my personal use. Current support is for NTSC 16/9 DVDs, but PAL and 4/3 will be coming soon.

If anyone else might find it useful for themselves I have added a link.

http://www.mediafire.com/imgbnc.php/4d2e5a2dbd8e9b8c0a5eee1ee746043c6g.jpg

http://www.mediafire.com/?sharekey=a8445626afa32ccfd2db6fb9a8902bda

Included is the app with a screen shot.

If you have any questions about my methods, whether you agree or disagree, please let me know. :thanks:

Sincerely,
Christian McClelland

Nightshiver
13th September 2008, 15:21
Nice tool, but what about these:

http://www.animemusicvideos.org/guides/avtech/resizecalc.html
http://resizecalc.somestuff.org/
http://www.haku.co.uk/ARCT.html

Sharktooth
13th September 2008, 15:26
MeGUI tries always to stay within the specified error %... but that's when possible.
if the user specifies a width that doesnt permit to stay below that %, then, megui is forced to choose an height that causes a higher error.
we could add a status bar in the AVS creator to inform the user of the AR error, but please add your request to the feature request tracker on the megui project page on sourceforge.