DStretch Help

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 works on color RGB images, the format used by consumer digital cameras.  It is based on Java and will run on PC’s, Mac’s and Linux.

Installation

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 dstretch@prodigy.net (also free but donations are welcome).  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.

Digital photography tips

  1. Camera: Bigger sensor is better, DSLR’s are good. Lens makes a difference.
  2. Megapixels: Higher is not necessarily better, but use all you have (See 6.)
  3. Best format is tiff or raw.  If you use jpeg use the highest quality setting.
  4. Use the lowest ISO setting available on your camera. Don’t use auto ISO.
  5. Use flash in low light settings (rockshelters).  Avoid direct sun.
  6. If shooting jpegs use the highest camera resolution setting (highest megapixels).

Digital Imaging Tools

Get a program to use for browsing your images.  I recommend Irfanview

(www.irfanview.com) or FastStone (www.faststone.org). 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.  I mostly use DStretch to do enhancements and don’t own PhotoShop, although I do have an old version of Photoshop Elements that I sometimes use.  I also use PaintShop Pro.


Using DStretch

Enhancement Names

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 so this handout explains which colorspaces give best results on which types of rock art.

Running the Plugin

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.

Choosing DStretch Enhancements

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.

More Enhancements

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.  These choices used to be called built-in enhancements.  They used to be numbered, but I gave them colorspace names starting in Version 7.0.  Each colorspace button has a tool tip that gives a short description that suggests uses.  I have found many of these colorspaces to be especially useful.  The ones I use the most are RGB0, YRE, and YRD for reds, YYE for yellows.  Hit the Back button to go back to the original panel.

YXX and LXX Buttons

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.

Flat Button

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.

Save Button

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 75 for jpeg quality when saving enhancements that will not need to be further enhanced. 

Adj Col Button

This button can be used to make adjustments to the colors in the image. It can either alter the saturation or smooth the colors.  Reducing the saturation (by say .5) 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.

CB Button

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.

Matrix Button

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.

Cycle Button

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.

HCycle Button

Changing the hue of an enhancement can improve contrast.  Expert mode has a nice slider that allows you to change hue.  For Simple mode I have implemented an automatic hue change cycle button which cycles through different hue changes.  You choose the hue increment to use.  To exit hit the red Stop button.

Expert

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 Simple mode click on the Simple 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. 

Direct Enhancement

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).

Area Selection

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.

Batch Mode

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 enhancement, matrix, and output format.  Under the matrix chooser you can access Expert mode choices, but usually this should be covariance.  You can also do an auto contrast after the enhancement by checking the box.  The ‘map back’ check box is another Expert option.  Usually it should be checked.  The output file names will reflect the enhancement chosen.

 


Examples   DStretch Home