In-depth guide to adding maps
|Pictures related to SABRE Maps|
View gallery (29)
| Start Here|
Copyright • Stitching scans • Calibrating maps • Creating map tiles
| SABRE Maps|
SABRE Maps coverage
Map layer names
Stitching is an essential part of the process of adding a new map to SABRE Maps. It is the process by which we can take a number of individual map scans, including from domestic A4 scanners, and recombine them to create the full map image.
To do so, we use software designed to create panoramic photographs called Hugin; and this article is designed as a step-by-step guide so that anyone interested in assisting with SABRE Maps can complete this process.
- 1 Installation
- 2 Hugin - First Configuration
- 3 Do the Scanning
- 4 Stitching
- 5 If your scan is misaligned
- 6 Next steps
- 7 Sample files
- 8 Links
Hugin is available for Windows, Mac, and Linux - Windows and Mac download from Sourceforge:
Typically Linux versions are available from the normal software repository, e.g. on Ubuntu
sudo apt-get install hugin
The package manager will grab a number of dependencies.
Hugin - First Configuration
- From the Interface menu, choose "Expert" - this is required to use the functionality needed to stitch scanned maps (screenshot)
- Go to the File>Preferences menu (screenshot)
- From the Assistant tab, enter "50" in the "Number of Control Points per overlap" field in the Auto align section (screenshot)
- From the Control Point Detectors tab select Hugin's CPFind (Default) and click the Edit Button (screenshot). Set the arguments to
--multirow -o %o %s --sieve2size 4 --sieve2width 30 --sieve2height 30(screenshot)
- From the Stitching tab, choose Output Format Default File Format=JPEG and JPEG Quality=95
- You may also want to increase the default memory available to Hugin on the General tab - cacheing more in the RAM may speed things up.
Finally, exit Hugin - this will guard against the interface reverting back to Simple should the application crash for any reason.
Do the Scanning
- Important to use Battleships format so that when stitching you know the row and column for each scanned segment (screenshot)
- Try and get the columns roughly in line - you'll help yourself considerably in the next step!
- Try and use the folds in the map to assist you with this.
- Try to align your scans so that they are as straight as possible - some skew is fine, but excessive scan skew can cause issues later.
- Ensure that there's lots of overlap between segments to make the stitching work as easily as possible
- Don't have the temptation to scan right up to the edges of the scanner's window - as the map is larger than the scanner, you may find that doing so affects the shading at the edges of each scan, so it can be better to crop away from the edges, particularly if there's lots of overlap anyway.
- Make sure that each scan is orientated in the same way, rotated in the image editing software before the initial save (some applications may add meta-rotation information if you do it later, rather than physically rotating the image, which may not work).
- Go to Hugin again, and right click and add images (screenshot)
- Select all the images (screenshot)
- Add HFOV of 10 to each of the images (screenshot)
- Sometimes Hugin creates new lenses for each image by default, sometimes it doesn't (I don't know why). If it doesn't, make sure that each image has its own lens by right clicking it, then choosing "New Lens" from the Lens menu (screenshot) (screenshot with all lenses added)
- Now add control points by selecting grids of four neighbouring images (ctrl click) and then choose "Create Control Points" on each, ensuring that you overlap them e.g.
By doing this, you are matching each square of four with overlap in every direction, and then repeating to try and ensure the best match between neighbouring squares while removing false positives of matches that could not be correct (e.g. between A1 and B3).
The red arrows here show the directions of control point matching that occurs, with the green box showing an example of B3 being present in four different matching activities, to ensure that it is considered against all its neighbours separately.
- You may then want to review the matches in the GL preview window to ensure that there are no false positives that might skew the exercise in any way.
- Underneath the Create Control Points part of the screen, there is an "Optimise" section. Choose "Custom Parameters" from the Geometric dropdown
- A new tab "Optimiser" will then appear. When you navigate to it, it usually defaults to having Yaw, Pitch, and Roll selected. Deselect Yaw and Pitch by right clicking the headings and choosing to Unselect them (screenshot). Click on "Reset" and select all options if Yaw and Pitch values are not all zero.
- Now ensure that roll, X, Y, and Z are selected by right clicking the headings and choosing to select them as required (screenshot)
- Note that if you have changed the anchor image, and are returning back to this screen for a second time, you will need to repeat the step of selecting all for the roll, X, Y, and Z columns and resetting to zero to ensure that optimisation as a result of the change to the anchored image would take effect.
- Next, click the "Optimise now" button and when finished, save changes (screenshot)
- Now go to the Stitcher tab, and ensure that the Projection is "Rectilinear", then click the three buttons - Calculate Field of View, Calculate Optimal Size, Fit Crop to Images (screenshot)
- This might crop things too much (we don't want to crop any data on the borders such as the map revision!) - so now click the GL Preview button to open the Fast Panorama Preview window
- You will now have an approximation of the final stitched image. Check that the image looks correct and all the scans looks to be in the correct place and well-aligned. If they are not, then follow the guide below.
- When this appears, click the "Crop" tab. Drag its boundaries outwards if anything useful is being cropped (screenshot)
- When you're finished with this, simply close the window to return to the main application.
- Now back on the Stitcher tab, click the "Stitch!" button
- It will ask you to save a PTO file for the project (screenshot)
- Next it will ask you to save the image file - please ensure it is saved as a JPG.
We try to use a consistent naming standard where possible for map source images; these are basically of the form series-sheet-revision where possible - giving examples like 7th-146-B-.jpg for OS One Inch Seventh Series, sheet number 146, revision code B/*; or qi-4-s06-1536.jpg for a Quarter Inch Fourth Series, Scotland sheet 6, revision code 1536.
The standard series prefixes are as below. Note that some prefixes are pre-assigned ready for when the maps drop out of copyright.
|7th||OS One Inch Seventh Series|
|npe||OS One Inch New Popular Edition|
|5th||OS One Inch Fifth Edition|
|pop||OS One Inch Popular Edition|
|spe||OS One Inch Scottish Popular|
|osni-pop||OSNI One Inch Popular Edition|
|osni-3rd||OSNI One Inch Third Series|
|qi-3||OS Quarter Inch Third Edition|
|qi-4||OS Quarter Inch Fourth Edition|
|qi||OS Quarter Inch Fifth Series, OSI and OSNI|
|mot||OS Ministry of Transport (England and Wales)|
|smot||OS Ministry of Transport (Scotland)|
|land2||OS Landranger (second series)|
|125||1:25k first series|
|path||OS 1:25k second series (Pathfinder)|
|expl||OS Explorer/Outdoor Leisure|
Note that some map series (for example, OS Route Planning) do not fit into that standard layout, and we usually use similar to rpm70n.jpg for the Route Planning Map 1970, North Sheet.
- It will then do the stitching to create the image... this may take some time... (screenshot)
If your scan is misaligned
If when checking the Fast Panorama Preview window your map is obviously misaligned, then there are several troubleshooting steps that can be taken.
Misalignment of Control Points
The most common issue is a misalignment of Control Points across two scans. Hugin can sometimes misidentify matching points - for example, on a small map it may try to match up grid references that are on opposite sides of the map; or mismatch sea depth contour values. Sometimes a single mismatched Control Point can cause a total misalignment.
- To check for this issue, go to the Control Points tab, and check that each Control Point matches the appropriate location in both images.
After your initial optimisation, you should also use the GL Preview window and the Control Points tab together to see mismatched points, and remove/fine-tune as appropriate and then reset and optimise the project to gain a more accurately stitched final image.
The GL Preview Window here contains an alignment view, where you can see each segment in relation to its neighbours and see how well they align. Clicking on any of the links will take you to the control points between those two images. Before you do your first optimisation, the distance values will all be far apart, but following the first optimisation, if you order the control points by distance you should find that there will be a significant number of low values (say under 10).
There is also an icon which provides an overall list of control points, which again you can order by distance. This will quickly allow you to identify any that have a significant discrepancy so that they can also be removed. It is important to note that this is a very blunt instrument, and should only be used in circumstances where you know there is generally good alignment; you could end up making things worse!
Re-check lenses and Yaw/Pitch
The next most common issue is, unfortunately, user error.
- Check that all images have different lenses assigned to them in the Photos tab.
- Check that Yaw and Pitch values within the Optimizer tab are set to zero.
- As above, make sure that your final stitching screen is set to Rectilinear, rather than the default Equirectilinear
Scans with very little detail / mostly sea!
Sometimes when a scan contains very little detail, for example, is almost entirely sea, then Hugin will automatically find few Control Points and additional points will need to be added manually within the Control Points tab. In this case, using the gridline intersections as Control Points plus the grid reference information around the edges is recommended.
Distortion on original scan
As we're dealing with paper maps of varying ages and number of folds, it is possible that Hugin is having difficulty because of an issue with one or more of the source images. To deal with this:
- Ensure that pressure is applied to the scanner's lid (or otherwise weight down the material being scanned) during the process, to flatten out the folds
- As above, resist the temptation to scan right to the edge of the scanning window - there may be distortion at the very edges as a result of the vertical distance between the scanner glass and the plastic surround which causes misalignment
- If using an A4 scanner, try and scan with one vertical map fold per scan (in the middle of the scanning window). This will decrease the impact of the fold upon the completed scan.
Insufficient overlap between scans to get a good match
It is far quicker to make a couple of additional scans to get a good level of overlap between source images than it is to mess around with fine tuning control points to try and scan something that has only a minimal overlap.
Another issue can be caused by an excessively rotated scan. The tools used within the later processes such as georeferencing and tiling can cope with a small amount of image rotation, but larger rotations can cause unexpected results and an unusable scan. Hugin defaults to using the first image added (so usually A1.jpg assuming the recommended naming is used) as its anchor for alignment, and the other images are aligned to that one. If rotation is excessive, then the Optimizer should be reset back to zero, and a different image selected as the anchor image. This is achieved by right-clicking on a different image within the Photos tab, and selecting the appropriate option.
Changing the anchor for alignment away from the default is also a good idea if image A1.jpg contains very few control points (for example, because it is mostly or entirely sea).
If all else fails
Finally, sometimes there is no obvious reason as to a poor alignment. In these cases, the best way to continue is to delete all existing Control Points via the Photos tab and to press Reset on the Optimizer tab. Then take it set by step - add Control Points to the first square of images, then move to the Optimizer tab and optimise just those four images, and complete the standard buttons on the Stitcher tab; and re-check the Fast Preview. If those images align correctly, then add the next square, optimise and check, and again only move on when the Fast Preview looks correct. Continue until all scanned images are complete.
We're now done, so the next steps are to calibrate..
Here is a sample set of scanned images for you to try out. SD69 (Warning: 13.8MB)