D-Stretch in Photoshop

D-Stretch is an image enhancement technique that I first learned about when I saw it applied to prehistoric pictographs. There is a plugin to the software ImageJ which will handle an image and produce a d-stretched version of it that can be found here. However, as someone who is comfortable working with digital images in Photoshop, I wondered if there was a way to replicate the effect in house. Here I present to you what I learned, and some thoughts on the process.

Let's start with a photograph of the Horned Dog, a particularly well preserved red ocre pictograph in Tennessee. The photograph was shot as raw, and processed for optimal display. White balance was adjusted based on the scale present in the image.

We will want to convert the image to the Lab color space to proceed (Image > Mode > Lab Color).

Check your channels tab, you should see these three channels present: Lightness, A, and B. We'll be individually adjusting these channels so keep this handy.

For each of the color channels you will want to do an auto-contrast (Image > Auto-contrast | Alt+Shift+Ctrl+l). This process will most dramatically affect the A and B color channels.

Above is the lightness channel.

Above is the A channel.

Above is the B channel.

Above is what the image looks like when all channels are active. This is the d-stretched image.

Photoshop is powerful software, is there anything more that we can do? Perhaps. Individually editing the A and B color channels in the raw dialog could be very powerful. Adjusting highs and lows through the whites, blacks, shadows, and lightlights sliders as well as contrast could be useful to elucidate meaningful data from the image. Texture is useful for bringing detail out in small areas, and clarity useful for bringing detail to larger areas. Dehaze as I have discovered is often a very powerful contrast, but has some preferences based on regions of application. In the next few steps I use dehaze and clarity to work on the A and B channels and provide an alternative final d-stretch image.

Channel A with clarity and dehaze maxed out.

Channel B with clarity and dehaze maxed out.

An alternative d-stretch image. Note that red is much more tightly aggregated on the subject. Obviously this won't work on all images equally, but perhaps provide some creative thoughts in dealing with d-stretch imaging situations.

Methods for Digitizing Large Format Images and Prints

Broadly the process of digitizing large format images with a camera can be broken down into two components: imaging, and image processing. The following steps work well for an image which would be processed as a black and white line map with the goal of eventually georeferencing the map.



Mount the map on a sturdy board to keep it flat. Use clips where you are able to keep the document flat against the board. Alternatively one could lay the document behind glass, or plexiglass, though this introduces the possibility of glare. This is discussed more later.

Camera settings

Obviously using a camera with a high resolution (measured in megapixels) is better than using one with a low resolution. The camera will need to be mounted with with a medium focal length lens. For this exercise I used my 50mm (the crop factor on my camera puts that around 70mm). If you photograph regularly you'll be aware that every camera has a "sweet spot" f/stop which maximizes sharpness. If you are unsure, you can always Google your lens or you can just do some basic tests yourself. For my lens I shot at f/7.1. Make sure you are set to photograph in camera RAW. Keep your ISO as low as possible as with all landscape style photography. Use the Tv camera setting and dial all the settings in, letting your camera make its own decisions about exposure length. In an area with low lighting this could mean your exposure may be up to 2 seconds, therefore use a tripod and a 2 second timer to reduce camera shake.

If color preservation is a consideration, then you will want to make sure all light falling on it shares the same temperature. Color calibration tools can be used to fine tune even further. For my project, color doesn't matter.

Other final considerations may include if the surface your are imaging is reflective. If so, minimize reflections by re-positioning lights and / or using a polarizing filter. For some work it may be impractical to remove glass or cover from the subject, but if it is then it is suggested. Shooting through less glass is preferable.

Generic camera settings:
• Camera Mode: Tv
• Focal length: between 50mm - 100mm
• ISO: Lowest available setting
• F/stop: Sweet spot
• Tripod: Yes
• Two second timer or remote camera trigger: Yes

Image processing


Lens distortion as well as minor imperfections in the quality of your document may cause the image to not appear correctly. By the process of orthorectification one can remove some of these errors.

Open your raw image in Adobe Photoshop CS. In the raw camera dialog access the transform panel. If your document has neatlines around it, those work great to trace out edges. Where no neatlines are available, the document's corners will suffice.

Use the crop tool to remove any unnecessary portions of the document.

Image improvement and clarification

The next steps are intended to bring the document back to its original state. If you are working with a different style of document you may find your workflow differs. Some of the key concepts may remain however.

For my image color data is unnecessary. I will convert the color space to Adobe Monochrome.

Use the sliders to optimize the images appearance. Give consideration to necessary contrast. For all intents this image may as well be only black and white, but I will retain some of the greyscale data to preserve quality. You can see that I've maxed many of the sliders out to that end.

Open the image now to bring it into Photoshop's standard editor. It's always a good idea to keep an eye on the image's histogram as one makes edits. I can see there is a gap on the high end of this histogram. I will correct that by using the auto-contrast tool (Alt+Shift+Ctrl+L) to bring the highs up to white, the lows down to black, and balance the mid-tones.

This looks good, but I think we can get it looking better. In the lower right I see some wrinkles and paper texture. Let's remove that.

I'll duplicate the layer first.

Use the threshold tool (Image > Adjustments > Threshold) to get an idea of the area you should focus on. Do not apply the threshold tool however.

Bring the image back into the raw dialog tool (Filter > Camera Raw Filter | Shift+Ctrl+A) and apply exposure adjustment to the areas in need. The red mask on the above image shows where I applied the exposure adjustments tool with a soft edge. Click OK when done.

Return to the threshold tool (Image > Adjustments > Threshold) and find the sweet spot to remove all the paper texture while not losing information on your document. You may have to go back to the raw dialog a few times to get this part right.

While still working on the background copy layer use the pencil tool to do touch ups and remove minor blemishes.

Change the blending mode for background copy to lighten. This will only allow high luminosity pixel values to pass through. It should leave the background white, and soften the lines if you're working with an image like mine. Zoom and pan around the image while toggling the background copy layer off and on a few times to get an idea of what happens.

Flatten the layers (Layer > Flatten image).

Some of the lines seemed a little light, so I'm using the curve tool (Image > Adjustments > Curve) to darken them.

Before my next steps I will need to rotate the image to get the arrow as close to north up as possible. This will make georeferencing the map much easier. Further, I rotated some of the text to read better with the north up orientation. Since this is a historic document, I made no changes to my original. All changes were made in a copy, and where I was able, I kept all the writing in tact so that it "speaks" from the same voice.


Roads of Tennessee - A Collection of Top Ten Lists

Highway 30, Van Buren County, Tennessee I found myself on a long, lonely road a few weeks ago. It was River Canyon Road that crosses from Marion County to Hamilton county as it follows the course of the Tennessee River through the Tennessee River Gorge. As I drove this road, I wondered, "Is this the longest segment of road without any intersections in the state?" I have the data and tools to solve this problem.

First, let's look at River Canyon Road. As I look at my data, I can see that it is broken up with several named and unnamed smaller roads that lead off from it. However, my intuition wasn't far off base. It's combined segment lengths between intersections (not spurs) is 18.93 miles. However for the purpose of this analysis, it will not appear again.

Longest Road Stretches between Intersections
1) Cold Spring Rd, Monroe County - 15.12 miles
2) Game Reserve Rd, Marion County - 11.82 miles
3) Lower Pain Creek Rd, Greene County - 10.07 miles
4) Meadow Creek Rd, Cocke County - 9.52 miles
5) Pace Gap Rd, Polk County - 9.51 miles
6) Howard Harrison Rd, Carter County - 9.22 miles
7) Richland Coal County Rd, Scott County, 8.88 miles
8) Big Sycamore Creek Rd & Snake Hollow Rd, Claiborne & Hancock Counties, 8.79 miles
9) Miss Kelly Loop, Dyer County - 8.40 miles
10) River Rd, Monroe County - 8.04 miles

Longest Stretch of Road under the Same Name
1) Interstate 40, 911.61 miles
2) State Highway 1, 711.18 miles
3) US Highway 70, 620.47 miles
4) US Highway 64, 567.55 miles
5) Interstate 24, 363.45 miles
6) State Highway 15, 351.46 miles
7) Interstate 75, 318.17 miles
8) Lee Hwy, 302.89 miles
9) US Highway 321, 279.77 miles
10) State Highway 76, 276.87 miles


Layer Blending in Photoshop for Maps

An elevation raster, or DEM, is a great place to start with producing your own basemaps. The DEM can be cooked into a number of other products, which when used with the DEM make pleasing maps. Other layers can be produced from elevation data, depending on how detailed it is. For this tutorial I have used a canopy layer and a TPI layer. If you've not made those yet, check the tutorials I've put together on them here:
Canopy Basemap from Lidar
Topographic Position Index (TPI) as an Alternative to Hypsometric Shading

This tutorial assumes you have access to Photoshop, or GIMP, as well as GIS software to produce raster basemap images for processing.

Here is what our basic ingredients look like.





Our mixture of those results in different forms. First, let's look at basic combinations of Elevation and Hillshade.

Combinations of Elevation and Hillshade

Where elevation is set to 50% transparent, and atop a fully visible hillshade, one gets this result. This is the most basic form of hypsographic shading. It is a pleasing effect and works will with most topographic maps where the land is emphasized. This can easily be in ArcMap without invoking Photoshop.

Elevation layering type is set to multiply, and the hillshade is set to 50% transparent. Compared with the previous map, the colors are more vibrant.

Same as the above layer, except the elevation layer is now set to color burn. The hillshade remains at 50% transparency. The colors are even deeper, and the highlights are more dramatic.

Same as two above, except the elevation layer is linear burn. The hillshade remains at 50% transparency. The colors are deeper, but what above is a highlight here is a midtone.

Elevation layering type is set to color, and the hillshade is set to 50% transparent. This looks like a highly saturated version of the elevation 50% transparent atop a fully visible hillshade.

Combinations of Canopy and Hillshade

Canopy is set to 50% transparent atop a fully visible hillshade. This is a basic configuration, and can easily be done in ArcMap.

Canopy layering type is set to multiply atop a 50% transparent hillshade to get this effect. The colors are deeper.

Canopy layering type is set to color atop a 50% transparent hillshade to get this effect. The colors are more saturated.

Combinations of TPI and Hillshade

TPI is set to 50% transparent atop a fully visible hillshade. This is a basic configuration, and can easily be done in ArcMap.

TPI layering type is set to multiply atop a 50% transparent hillshade to get this effect. The colors are deeper.

TPI layering type is set to color atop a 50% transparent hillshade to get this effect. The colors are more saturated.

Combinations of TPI, Elevation, and Hillshade

TPI layering type is set to multiply, elevation is set to multiply and at 65% transparency, and hillshade is 50% transparent. This more strongly emphasizes the TPI layer without oversaturating the map.

TPI layering type is set to multiply and at 65% transparency, elevation is set to multiply, and hillshade is 50% transparent. This also ephasizes the TPI layer, but the map is oversaturated.

TPI layering type is set to color and at 65% transparency, elevation is set to color, and hillshade is 50% transparent. This is a more vibrant version of the previous two, and arguably not oversaturated.

Combinations of Canopy, Elevation, and Hillshade

Canopy layering type is set to multiply, elevation is set to color and at 50% transparency, and hillshade is at 50% transparency. This allows some of the hyposographic shading to bleed through underneath the canopy.