About Aspect Ratio and Non-Square Pixels

Shake has several controls in the Global parameters to help you work with non-square pixel images. These images are typically video images, which have distortion in one axis, or else film anamorphic images. We use different controls for the different types, because of the nature of the data we are manipulating.

For video, our primary concern is the distinction of the fields from each other, so we correct the distortion by extending the image in the X direction and not the sensitive Y direction. For anamorphic film plates, our primary concern is the amount of data we are using, so we squeeze the image down in Y, reducing the overall frame size when working interactively. This has the consequence of not only correcting our distortion, but also of speeding up our interactive renders by a factor of two.

There are sample images in doc/pix/aspect that you can test the following notes on.

When correcting for non-square pixel images, we need to be aware of the proper aspect ratio of the image for the purposes of transformations, and corrections to the viewing process so that we can see the image without distortion. For our discussion of different aspect ratios, we will use film anamorphic plates to illustrate how to work with these frames, mostly because the squeeze is the most drastic, and therefore serves as the best example. Although the solution is specifically for film plates, and you should use a slightly different solution for video images, the principles and problems are similar.

The anamorphic process creates film frames that, when projected, offer extremely wide images. This is done by first filming the scene with a special lens that squeezes the incoming image by two only in the X direction so that the scene can fit on the physical piece of film. If you observe the negative, everything will be very thin. When the film is projected in the theater, a reverse lens is applied that expands the image by two on the X axis, returning our image to its very wide format. It is therefore important to realize that the widescreen data only exists in front of the lens when filming, and on the projection screen. Usually at all points in between, you are ideally working with the squeezed image. This is also a fundamental principle when compositing squeezed elements - the ideal image is never scaled, but we still need to see the results as unsqueezed. Shake has a toolset to help you meet this criteria.

If you load up the image doc/pix/aspect/anamorphic_2_1.iff, you will see a low resolution example of one of these frames. Its resolution is 914x778, or half of a standard 1828x1556 anamorphic plate. You can clearly see from circle that the image is squeezed on X





Viewing Squeezed Images properly

The first problem is to view the image in its unsqueezed proportions. We have two general paths to do this. We can either change the resolution of the image with a Zoom or Resize, or we can adjust the Viewer aspect ratio or script proxyRatio. The first choice would require us to zoom the image down by two in Y (or up by two in X), do our compositing, and then zoom it back to its squeezed proportions. This requires us to scale the image down and then up, which has an inherent loss of quality. Therefore, the second choice of modifying a Viewer aspect ratio or a script proxyRatio is more appealing. The script proxyRatio is better used when working with film elements, and the Viewer aspect ratio is better when dealing with video elements.

Video: To change a viewer aspect ratio, change the Globals parameter appropriately named viewerAspectRatio, setting it to 2 (since our ratio is 2:1). This will render the image at full resolution, and then double the Viewer width. This will not effect your output resolution, and will take exactly the same amount of time to render. This is the parameter you should use when working with video elements, since you change the X parameter, leaving the Y parameter, which contains the fields, at the same resolution.

Film: When working with film elements, you would probably be better served by using the proxyRatio (underneath the proxyScale subtree in the Globals tab), setting it to .5 (1/2). By using the proxy system, you reduce your rendering time for your interactive tests by half. Unlike viewerAspectRatio, this halves the Y value, rather than doubling the X value. This will, however, effect your output files, so be sure to set the proxyRatio back to 1 when you render your images to disk.

Therefore, for this anamorphic film plate, I open the proxyScale subtree and enter a proxyRatio of .5, which will correct the squeezed element:





Function aspect ratio and the defaultAspect parameter

Some functions need to be aware of aspect ratio, mainly any function dealing with circles or rotation. For example, if you put a Rotate node on our anamorphic plate, the image will be distorted.

We have included an aspectRatio parameter in the Rotate command. Set the aspectRatio to .5, and the rotation will no longer be distorted:

A parameter to help you in this is the Global defaultAspect. The aspectRatio of Rotate and other functions gets set to this automatically when the node is created. Changing the defaultAspect will not change preexisting nodes - it only effects nodes that are created after you set the defaultAspect.

The one function that is backwards from the others (and I don't know why, but I was assured it was correct. Go figure) is the RGrad command. The aspectRatio for this should be 1/defaultAspect (which is what it uses as it's creation rule). Here, I composite in an RGrad with an aspectRatio of 1:

Seeing that it is distorted, I change the aspectRatio of the RGrad to 2:




Compositing Square Pixel images on Squeezed images

In the doc/pix/aspect directory is a rather complex image called square.iff: We will use this image to represent square pixel renders, which are typical of CG-generated images

Compositing it over our image, we see that there is distortion in this as well:

To correct this, we have two options. We can either scale the X by 1/2, or increase the Y by 2. The first method will ensure the highest quality, but means you have to render at twice the resolution of the second choice. Here, I have scaled the Y by 2:



Tuning Parameters in Squeezed space

Other functions besides Rotate and RGrad also should be tuned with a squeezed aspect ratio in mind. For example, here I have placed a Blur on our image.

Because the default yPixel value is set to the xPixel value, we get a twice the blur on the X parameter in the squeezed space. To correct this problem, we double the Y value (or if you wish, half the X value) with an expression in the yPixels parameter:

xPixels*2

Now the blur looks proportionately correct:




Rendering Squeezed Images

Once you are finished with your composite, you reset the proxyRatio back to 1, and then render. Do not change any other parameters. The resulting image will appear squeezed on the X axis, but this distortion is corrected in the film projection process in the theater.

Even though we worked on the image in a squeezed state, all elements are properly positioned when returning the proxyRatio to 1. By using the proxy system, we never actually squeeze the image down and back up.



Handling Video Elements

Video elements also have a built-in squeeze. To make things extra tasty, each video format has its own aspect ratio. Using the proxyRatio parameter is not recommended for video elements because proxyRatio squeezes the image in Y. This will almost certainly obscure your field separation. Instead, we recommend using the viewerAspectRatio parameter, and setting it to the aspect ratio of the video element. This will stretch the Viewer in X, leaving the Y untouched. This will also only effect the Viewer - you will have exactly the same processing time, and your images rendered to disk will not be effected.

The only other thing you have to change is the defaultAspect. However, unlike using proxyRatio, you set defaultAspect to 1/YourVideoAspectRatio. For example, PAL HD uses 1.422 as its aspect ratio. I therefore set viewerAspectRatio to 1.422, and defaultAspect to 1/1.422. Shake will resolve the expression of 1 divided by 1.422 to become 0.703235. All other principles of manipulating your images apply.



Table of Common Aspect Ratios

This is a table (hopefully to expand in the future - feel free to submit more video aspect ratios...) of common aspect ratios, and the values you should place in specific parameters. Note that for nodes, the aspectRatio parameter will be taken from the defaultAspect value at the time the node is created. It will not be changed if you later change defaultAspect. Additionally, RGrad is the inverse of the other aspectRatio parameters, i.e., 1/defaultAspect, which accounts for its own column in the table. Initially setting the defaultAspect will guarantee that all nodes will automatically get the proper aspect ratio. Finally, following the guidelines in Customize Shake and by saving your Interface Settings, you can set default values for these parameters.

Format
a
aspect ratio
proxyRatio
viewerAspectRatio defaultAspect aspectRatio (common nodes) aspectRatio (RGrad)
2:1 Anamorphic Film 2 .5 NA .5 .5 2

4:3 NTSC D1
720x486,
720x480

.9 NA .9 1/.9 = 1.1111 1.11111 .9
16:9 NTSC 720x486 1.2 NA 1.2 1/1.2 = .83333 .8333 1.2
4:3 PAL
720x576
1.066 NA 1.066 1/1.066 =
0.938086
0.938086 1.066
16:9 PAL
720x576
1.422 NA 1.422 1/1.422 .703235 1.422