This Annotated Reality Design for Novices project page describing how to create and adjust 360° equirectangular images with Hugin demonstrates techniques tested using Hugin version 2016.0.0 for Windows, but versions as early as 2014.0.0 have been tested and later versions and other operating systems can also be used.
We will present two useful abilities; straightening existing equirectangular images and creating an equirectangular image from a six-image cube map.
We can use Hugin to straighten existing equirectangular images by adjusting the yaw, pitch, and roll of the camera's view. You can think of yaw as turning your head around, pitch as tilting your head up or down, and roll as tilting your head left or right, all so that a different orientation in space is "forward" to your eyes. All three are expressed in degrees.
To correct an image where the camera was not level and pointing straight
ahead,
assuming there is not software that came with the camera that will
auto-correct it,
we will adjust things incrementally.
You will need to make use of image editing software such as
GIMP
to take certain measurements (unless you have a specific set of adjustments
already determined)
and identify a spot that you want to be "front and center" when
looking forward.
We will use the following image,
which was generated to represent a photo taken
with a 360° camera that wasn't positioned quite right,
for our example.
First, we will determine the desired adjustments. For the yaw, we need to determine the x coordinate of what we think should be the point directly ahead of us (in this case, using the image editing software, we find it is 1707) and the width of the image (in this case 4096). The x coordinate of the "straight-ahead" point should be at 2048 (half of 4096) so it is off by 341 (2048-1707) out of 4096 in this case. We divide that offset by the width (341/4096) to get the percentage offset out of 360° and then multiply that by 360 to get our yaw correction (29.97 in this case).
For the pitch, we need to determine the y coordinate of what we think should be the point directly ahead of us (in this case, using the image editing software, we find it is 1058) and the height of the image (in this case 2048). The y coordinate of the "straight-ahead" point should be at 1024 (half of 2048) so it is off by -34 (1024-1058) out of 2048 in this case. We divide that offset by the height (-34/2048) to get the percentage offset out of 180° (roughly 0.0166) and then multiply that by 180 to get our approximate yaw correction (-2.99 in this case).
For the roll, use the image editing software to measure how tilted things to the immediate left and right of the "center" spot in your image are relative to what "level" should be. In this example, the image editing software indicates that we would need to rotate the image 13.2° clockwise to straighten the area immediately around that black circle, so 13.2 as the roll adjustment (if it had been a counter-clockwise rotation needed, we would have used a negative roll amount).
Now that we have our target adjustment values for yaw(29.97), pitch(-2.99), and roll(13.2) we can start Hugin to make the adjustment. Start Hugin and set the interface to "Advanced" via the "Interface" menu on the menu bar. Next, drag and drop your equirectangular image into the "Photos" tab's file list area. The lens data to use here is a lens type of equirectangular and a field of view of 360°. This might be requested when you drop the image into Hugin, or you might need to double-click on the file name once it is in the file list to bring up the dialog box to enter image variable, in which case you will enter that via the "Lens" tab of that dialog box. If your version of Hugin instead asks you to enter the focal length and focal length multiplier, enter them as 6.159mm and 1x respectively. Next, double-click the file name in the file list to bring up the dialog box to enter the yaw, pitch, and roll adjustments in the "Positions" tab.
You are now ready to generate your adjusted image.
To do this, go to the "Sticher" tab of Hugin.
Make sure that the output projection is listed as equirectangular.
Click on the button to calculate the field of view
(it should set this as 360x180).
Next, click on the button to calculate the optimal size.
Finally, click on the "Stitch!" button towards the lower right-hand corner
of the application window.
This will create a TIF with the specified yaw, pitch, and roll adjustments.
You will need to load that into your image editing software to save it as
a JPG for use with VR viewers.
We can also use Hugin to create an equirectangular image from
a six-image cube.
For ease of keeping track of things, it is recommended that you name the
files back, front, left, right, down, and up.
In fact, if you have them as TIF files with those names, you can download
CubeDraw.pto
and open it with Hugin to have all of the settings discussed below set
for you to start off.
Otherwise, load all six images into Hugin via the "Photos" tab.
The field of view of the lens should be entered as 90° and
the lens type as normal (rectilinear).
If required, the focal length should be entered as 15.297
and the focal length multiplier as 1x.
Next, you'll need to set the yaw, pitch, and roll for each of the six images. You can do this by double-clicking each file name in the file list in turn. The roll value for all six is 0. The yaw and pitch values are as follows:
yaw pitch back 180 0 front 0 0 left -90 0 right 90 0 down 0 -90 up 0 90
After setting those values, you can preview the equirectangular image
by clicking on the icon.
You can then switch back to the main interface to generate the final
TIF file.
When happy with those values, go to the Sticher tab.
Set the horizontal and vertical fields of view as 360 and 180 respectively.
Set the width to be 4 times the width of the individual images.
Set the height to be 2 times the height of the individual images.
Scroll down to where the processing options are.
For the Blender, you might want to try a few variations.
You can select "builtin" for the simplest approach, but might want
to select "emblend" from the drop down list and
then click on the "Options" button next to that and enter
"-l 1"
(dash el one)
to specify minimal blending
unless you want Hugin to do some blending at the seams.
Finally, click the "Stitch!" button to create the TIF file
(which you should then convert to JPG using your image editing program
for use with VR).
The allows us to take a six-image cube map such as:
![]() | |||
![]() | ![]() | ![]() | ![]() |
![]() |
If you do have trouble with the seams, you might try using the six-image option at www.360toolkit.co/convert-cubemap-to-spherical-equirectangular.html to create your equirectangular image.
For more information about this project, please contact Evan Golub