DStretch is a digital imaging tool created for the enhancement of rock art images. It can make pictographs visible that are nearly invisible to the naked eye. It needs a hue difference to do its enhancement and so works best on pictographs, especially faint red or yellow pictographs. It can in some cases work well on petroglyphs. It works on color RGB digital images, the format used by consumer digital cameras. It is based on Java and will run on PC’s, Mac’s and Linux.
DStretch is a plugin to the imaging program ImageJ (available for free from http://rsb.info.nih.gov/ij/). Install ImageJ first then get the DStretch plugin file DStretch_.zip (this used to be called DStretch_.jar) by email from email@example.com (also free but contributions are welcome and help me to make DStretch better). Put the plugin file into the ImageJ Plugins directory. When you next start ImageJ DStretch menu items will appear in the Plugins menu. To start DStretch choose Plugins->DStretch->DStretch…Run.
Get a program to use for browsing your images. For PC's I recommend Irfanview (www.irfanview.com) or
They are small and fast and allow you to easily browse images in a
directory. They are also free. It is possible to make ImageJ the
default editor for these programs. For
uses beyond browsing (i.e. for color cast corrections) PhotoShop
is the standard, but is expensive.
DStretch has color cast corrections in the Adj Col button.
DStretch does its enhancement using colorspaces. It names the enhancements after the colorspace used. The colorspaces have names like RGB, LAB, YDS, YBK, LDS, and others. Different colorspaces produce different results. The alphabet soup can be confusing at first, but there are tool tips for each button that give suggestions for use.
Start ImageJ. Open the image file using the File->Open menu item or (on a PC) drag the file onto ImageJ. Then choose the Plugins->DStretch->DStretch…run menu item. A copy of the image will appear with the DStretch panel underneath. That panel has a scale field, a number of colored buttons with colorspace names, plus some other buttons. To do an enhancement first choose a scale then click on a colorspace button. The default scale (15) and the YDS button are good starting points. For red pictographs the CRGB button works well. LDS and LRE (for reds) give more pleasing colors, but are slower.
The Plugins->DStretch->DStretch…one menu item is similar to the …run menu item, but puts the DStretch panel under the image without making a copy.
Before or after doing an enhancement the Auto Contrast button can be used to optimize the image contrast. This sometimes improves the image, sometimes not. Press the Reset button to get back to the original image. Save the result by clicking on the Save button. This saves the enhancement as a jpeg file. To save as a tiff file use the ImageJ File->Save menu command. DStretch names the saved image by adding the colorspace name. You can change this name in the save dialog.
The buttons in the top row give fast enhancements. YDS gives good all-around enhancements and works well on yellow pigments. CRGB does very well on faint red pictographs, but produces some wild colors. YBK can do well on black pigments. YBR sometimes gives better red colors than YDS. The “L” enhancements are slower, but are less affected by noise and jpeg artifacts and can give sharper looking results with more pleasing colors. LAB and LDS are good all-around enhancements with LDS enhancing yellows better. LRE works very well on reds. RGB is the colorspace used by the original decorrelation stretch algorithm.
I have put other DStretch enhancements that I
have found helpful into the More button. When
you press this button a new set of colorspace buttons appear. Each
colorspace button has a tool tip that gives a short description
that suggests uses. The YXX, LXX and
Xplor buttons (see below) are here. Hit the Back button to
go back to the original panel.
I created most of the built-in enhancements by manipulating colorspaces. You can do this yourself by adjusting the multipliers in the panel displayed by the YXX or LXX buttons. The panel includes standard colorspaces on the left. When you press one of these buttons the enhancement is done on your image and the Y or L parameters are set to those for that colorspace. You can then use the orange buttons on the right to optimize the parameters for your image. Once you get an enhancement that you like be sure to save the matrix (when you save the image in YXX or LXX mode there is a second dialog to save the matrix). Reading that matrix before a new stretch will set the multipliers to those you chose previously.
This button gives another way (besides YXX and
LXX) for creating a custom enhancement optimized for a specific
image. Use the sliders to interpolate between YRD, YBK, YRD,
This button accesses a routine that flattens the illumination across an image. It can be useful in images where the rock art is partly in shadow. It can also flatten out non-uniform flash illumination.
This button saves the current image as a jpeg. Quality is determined by the ImageJ jpeg quality default. This number appears at the top of the save dialogue. To change it use the ImageJ Edit->Options->Input/Output… menu item. If you switch to Expert mode and use the Save Jpeg button in that mode there is a dialogue that asks for the number. I use 80 for jpeg quality when saving enhancements that will not need to be further enhanced.
This button can be used to make adjustments to the colors in the image. It can turn Grayscale mode on or off. This mode converts an enhancements to grayscale. this can be very useful in some cases. The button also can change the color cast, alter the saturation, reduce cyan color (all these are in the Adj Colors choice), or smooth the colors. Reducing the saturation (by say .5) and setting cyan to 0 can tame the sometimes wild colors produced by DStretch. Do this after a stretch. Smoothing the colors can help visualization in noisy images. Use smoothing before the stretch.
This button performs a color balance routine that can help when color in the background of the paintings interferes with visualization or with DStretch enhancements. Hit this button before you do a stretch.
After doing a stretch use the Matrix button to save the matrix and colorspace in a text file for future use. This can be used to apply the same DStretch to several images for more consistent color enhancement. I also use it to remember which YXX or LXX multipliers I chose. Before doing a stretch use the Matrix button to read in a previously saved matrix and do an enhancement based on that matrix.
Viewing different enhancements sequentially can help uncover faint paintings. This button cycles through the enhancements that you choose using the check boxes. You must hit the red Stop button to exit.
DStretch originally came with a rather complicated user interface that I used when developing the program. It has many special tools that I have found useful in enhancing rock art images. To switch to Expert mode just click the button. This can be done at any time. To go back to the main panel mode click on the Main Panel button. More colorspaces and more types of enhancement are available in Expert mode. There are two panels available: Expert and Hue Mask. For more information on the Expert panel and the Hue Mask panel use the help button. A special Hue Mask help message is given when the Hue Mask panel is up. Many of the buttons (scale, auto contrast, help, CRGB) are the same in Expert mode as in Simple mode. In Expert mode to do a stretch choose the scale, colorspace, and matrix then hit the DStretch button.
You can perform DStretch enhancements without going through the DStretch user interface. Open an image in ImageJ then under the Plugins->DStretch Direct menu choose one of the DStretch…YDS, etc. menu items. DStretch will perform the enhancement on the image. If you don’t like it choose “Edit->Undo”. To change the scale select Plugins->DStretch Direct->DStretch…Set Scale. Other useful routines are available under the DStretch Menu. They include flatten, invert, auto contrast, color balance, adjust saturation, hue shift, and CSmooth (smooth colors).
ImageJ has the ability to draw an area selection on the image using rectangles, ellipses, and freehand drawing. If an area selection is present the decorrelation stretch will be based on that area, but applied to the entire image. Use this to exclude extraneous parts of the image (say green bushes near a panel) that can affect the enhancement.
Choose this DStretch menu item to run DStretch on all the files in a directory. The output will go to a second directory. After you choose the two directories you get to choose the enhancements and output format. There is room for 4 different enhancements, or 8 if you check the box. Only one should be a colorspace, the others can be Auto Contrast, CB, Adj Color, etc. The output file names will reflect the enhancements chosen.