DEMview Tutorial


Merging DEM Images

Usually a single DEM file will provide you with a bounty of scenic vistas to render in Bryce. Sometimes, though, the locale you're looking for sits astride two map areas (ed note: it's a cardinal rule that the most interesting features always lie at the junctions of 4 map areas!). Before you go into mourning, try merging the two DEMs! The DEMview sample DEMs are an example of an interesting pair. Mt. Richthofen rises to the east of the Fall River Pass valley. A view of the valley with the mountains looming in the background would be just the ticket... but they're in two different DEM files.

In this section of the tutorial, we'll merge the two sample DEMs into one Bryce terrain.

All maps are not created equal

When DEMview creates a gray scale image from a DEM, it computes the gray scale based on the range of elevations in that DEM. This is a problem if you're trying to put together more than one DEM, since they usually have different elevation ranges. If you tried to put them together in Bryce, you'd have to match the relative scales of the different terrains and align their altitudes (nearly impossible, given the large scale of DEM data relative to the granularity of Bryce controls). DEMview's Equalize feature is the solution. What Equalize does is map the gray scale of all open DEM images to their combined minimum and maximum elevations. The result is a group of images that can be seamlessly merged in an image editing program.

Begin by opening both sample DEMs (40105D7.dem and 40105D8.dem) in DEMview. Note the minimum and maximum elevations in the upper left hand corner of each DEM window:

The different elevation ranges are reflected in different gray scales in the two images. If you line them up side by side (Mt. Richthofen on the left, and Fall River Pass on the right), you might be able to see the slight differences. Here's what the default-scaled DEM images look like when merged in Photoshop:

After you Equalize in DEMview, you can see that both images are re-mapped to the minimum and maximum combined elevations, 2708 m from Fall River Pass, and 3944 m from Mt. Richtofen:

Now that the DEMs are equalized, you can assemble them in Photoshop and select a combined area for a Bryce terrain. It's easiest to do this rather than saving a selection from each equalized DEM and putting the two terrains side by side in Bryce. For one thing, it's difficult to align terrains precisely in Bryce. Even if you use the alignment menu, you sometimes get visible seams between the terrains. 7.5-degree DEMs are trickier still, because of the irregular borders of the DEM data.

Let's start assembling... save the equalized DEM images (I like to use ".eq" at the end of the file names to remind me that these belong to an equalized group). When you save them, you'll see the scale information dialog again. This time DEMview should tell you to use a horizontal-to-vertical scale of 8.7. The Bryce scale is the same for both images because they're both the same size and have the same range of elevations. (Somewhat silly tip: if you're like me, and you don't like to scribble down these scales all the time, just take a screen snapshot of DEMview's dialog. Or, you could bug the author to implement a log file feature to save this information for you. Somewhat less silly sub-tip: one great way to do quicky screen-shots is to use Flash-It by Nobu Toge. It's a shareware utility that lets you marquee part of the screen to save to the clipboard, scrapbook, or a PICT file. I used it for all the screen shots in the DEMview Guide and this tutorial. Highly recommended, and well worth the meager $15 shareware fee!)

Imerging

After opening the equalized DEM images in Photoshop, you can create a new document that's big enough to hold the combined image (I wish Photoshop had this feature built in!). Alternatively, you can set the canvas size of one image to twice its original width. I prefer making a new image, though, so that I can save a boundary mask for the DEM data in a second channel of the original image. With Photoshop 3.0, the best way to merge is to create a 512x512 image and put each DEM on a separate layer. Photoshop saves the entire layer even if parts of it fall outside the image, so you can move the combined image later if you decide to change it. Or you can go really nuts and build a humongous multi-layered multi-DEM landscape. That's what we'll do next (except for the part about going nuts).

To mask the boundaries of the DEM images, use the magic wand to select the neutral gray color on all four edges. Make sure you set the magic wand options to select only a single color without anti-aliasing:

Sometimes, DEM data at the edges of the terrain end up mapped to the same gray level as the border color. The magic wand will select these areas along with the borders. Keep an eye out for this, and clean them up with a quick command-drag of the marquee tool:

When you have a clean border selection, invert it so the DEM data is selected (Select->Inverse), and save the selection to a second channel (Select->Save Selection, new channel). Do this for both images, and save them to preserve the selection channels. (Gee, DEMview could do this for you too, couldn't it? Shaddup, we're in the middle of a tutorial here. Besides, the author has bigger plans for DEM merging...)

Finally, open a new image to hold the merged DEMs. Choose whatever size you want to use for the Bryce terrain. 512x512 is big enough for most of our 7.5-minute DEM pair, with a bit of empty space at the top and bottom. Fill the background layer of the new image with black (D, option-delete). Now here's the cool part: drag the selection from one of the DEM images onto the new image. Click the new layer icon on the Layers palette, and presto! You're halfway there. Do the same for the second DEM image.

Align the edges of the DEM layers with the move tool:

A seamy image

Now, unfortunately, you may find after aligning the DEM layers that parts of the seam are still marginally visible. In my experience, it's usually most pronounced near the jags in the DEM boundaries. I'm not sure why this happens, whether it's errors in the source data or (gasp) a bug in DEMview. Here's an example (zoomed in 10x to make it more visible) of a tiny area of the same section of a DEM boundary before and after equalization:

It's necessary to smooth over these areas before rendering, because they will be visible in Bryce, especially if you scale the terrain very large. There are several ways to do this. Depending on how pronounced the seam is, you can use the blur tool or the smudge tool to smooth things out. Or, you can take a shotgun approach, and make a copy of the seam area in a third layer, using a fractional radius Gaussian blur to smooth the entire length of the seam. For this pair, I created a 6 pixel wide mask at the seam boundary, used "Apply Image" to merge the two DEM layers, masked by the seam mask, to a third layer, and blurred the third layer with a 0.3 pixel radius Gaussian blur. However you choose, do smooth things over before handing the terrain to Bryce.

After bringing the terrain into Bryce and using the techniques described in the second part of this tutorial, here's the result I came up with:

Some minor differences between 7.5-minute and 3-degree DEMs bear mentioning, since they affect how you merge terrains. 3-degree DEMs, unlike the 7.5-minute DEMs, use geographical coordinates, so they don't have empty areas at the edges of the data. Also, 3-degree DEMs overlap map boundaries, so when you merge them in an image editing program, you need to overlap adjacent DEMs by one pixel. Other than that, the same principles apply: Equalize in DEMview, use separate layers in Photoshop to hold each DEM image, and blur or smudge if needed to smooth over any visible seams before importing the terrain into Bryce.

This part of the tutorial described how to use Photoshop to paste together two DEMs with different elevations ranges. We used DEMview's Equalize feature to equalize the gray scales of the DEMs, cropped the borders in Photoshop, and created a combined image using different layers for each DEM. We also covered some seam problems you may run into when merging DEM images.

I hope you've found this tutorial interesting, and that it will help you in the future as you explore DEM terrains in Bryce. If you have any questions or comments about the tutorial, DEMview, or using DEMs with Bryce don't hesitate to e-mail me at KenBad@aol.com.

The DEMview Tutorial was created using ClarisWorks 4.0, KPT Bryce, Kai's Power Tools, and Adobe Photoshop. Screen shots were captured with Flash-It by Nobu Toge. ClarisWorks is a registered trademark of Claris Corporation. KPT Bryce and Kai's Power Tools are trademarks of HSC Software. Photoshop is a trademark of Adobe Systems, Inc.
The DEMview Tutorial is Copyright 1995 by Ken Badertscher. All Rights Reserved.
Dedicated to AuntiAlias, without whom DEMview would never have left my disk. Thanks to Robert Hildebrand for hosting the Terraformers' Guild, and giving DEMview a home on the Web. Big thanks to all my Beta Units (you know who you are).