Part 1: Practice Using Selection Techniques3

Sometimes you're interested in manipulating or analyzing entire images, but it's more common to be interested in a just part of an image. Identifying the pixels you're interested is one of the key tasks in image processing, and ImageJ provides a broad range of tools and techniques for making selections.. Another name for a selection is Region Of Interest or ROI. The phrase "select, then act" is a cornerstone of many computer applications, and image processing is no exception.

In many cases, the instructions won't tell you explicitly what to do, but we urge you to TRY EVERYTHING YOURSELF! Selection is such an important process that there are no fewer than 15 separate tools on the ImageJ toolbar and over 20 menu items dedicated to selections. Your mastery of ImageJ depends largely on your ability to make and use selections.

If you have used other graphic software, you may be frustrated that you can't draw points, lines, shapes, and text with ImageJ. That's because the process of selecting is of primary importance, and drawing is secondary. It can be done but it takes an extra step, which you'll learn about later.

Prepare a Selection Practice Image

You'll need an image to practice these selection techniques on. We'll use this image of downtown Pasadena, California for most of our selections.

  • Click this image to open it as a full-size image. Right-click (PC) or control-click (Mac) the image to download it to your computer. Then, open the image in ImageJ using any of the techniques you've learned. For orientation, North is to the right.
  • If you open the 50% reduced-resolution version below, features will be more difficult to see and the image scale will be 1 meter per pixel, not 0.5 meters per pixel (2 pixels/meter).


Colors

In ImageJ, there are three colors the user can define:

  • Foreground The foreground color is the default color for drawing, painting, and filling.
  • Background The background color is the color used for erasing and deleting.
  • Selection The selection color is the color used to display selection outlines.
  • The foreground color, not the selection color is used to draw lines and shapes on the image.

Choose a Selection Color

Selections are indicated by a colored outline. You have control over the color of the selection outline. If you have trouble seeing the selection on top of the image (red on red, for example), you might want to change the selection color to something that is easier to see. The default selection color is yellow, but this can be changed to any of eight standard colors (black, white, red, green, blue, cyan, magenta, yellow, and orange).

  • Choose Edit > Options > Colors and choose a selection color. (The default yellow is goodwe just wanted you to see where to change it if you need to later.

Selection Tools

Accessing Selection Tools and Tool Options

At any given time, eight selection tools are visible on the ImageJ toolbar. The tool buttons marked with small red triangles contain two or more related tools. To access the other tools, right-click (PC) or control-click (Mac) the tool button and select from the pop-up tool menu.


Some selection tools have options, such as the width of line selections. There are usually two ways to access these settings:

  • Double-click the tool button itself. For example, double-clicking the straight line selection tool opens the line width dialog box. This action is contextual. Double-clicking the Arrow tool opens the Arrow Tool options dialog box.
  • Go to the Edit > Options submenu. You'll find the same options listed.

Select and de-select the entire image

The two most basic selections are to select everything and select nothing. In a strange twist of logic, both of these options usually produce the same results. When nothing is selected in an image, most operations assume that you want to use the entire image (ALL of the pixels). Operations that require a selection generally display an alert message to that effect.

  • If necessary, zoom out so you can see the entire image on your monitor. The easy way to fit your image to your monitor is to double-click the magnifying glass tool on the ImageJ toolbar. (This is important because if you can't see the edges of the image you won't see the yellow outline around the image when it's selected.)
  • Choose Edit > Selection > Select All. You should see a yellow selection outline around the outer border of the image.
  • You may know that you can cancel a selection by clicking anywhere outside the selection. When the whole image is selected, there is no "outside". The only way to cancel the selection is to de-select the image, or to "select none" of the pixels.

  • Choose Edit > Selection > Deselect All The yellow selection outline should be gone.
  • Remember, if you are zoomed in on one part of the image, there may be a selection outline somewhere that you can't see. When in doubt, use Select None to cancel all selections.

    Note that many frequently-used menu items have keyboard shortcuts. The keyboard shortcut for Select All is the A key, and the shortcut for Select None is Shift-A.

  • Try these shortcuts out. (Note: Keyboard shortcuts work except when you're entering text using the text tool, for obvious reasons.)
  • Before continuing, make sure nothing is selected.

Line Tools Straight Line Selection

Straight line selections are used for measuring length (distance) and angle, and for defining sources for profile plots.

  • Use the Straight Line selection tool to make a straight line selection anywhere in the middle of the image. As you drag your selection, the ImageJ status bar shows the length of the line and its angle measured ±180° from the 3 o'clock position (0°). Positive angles are measured counterclockwise from 0° to 180° and negative angles are measured clockwise from 0° to -180°.
  • The small white boxes at the center and ends of the line selection are handles. Drag the center handle to move the selection without changing its length or angle.
  • Drag either end handle to move that end of the selection while the other end remains fixed.
  • Straight line selections can be dragged beyond the boundaries of the image window.
      Modifier Keys

    • Shift Constrains the line selection to horizontal or vertical. (Very useful when setting the scale.)
    • Alt/Option When dragging an end handle, this keeps the line length fixed while changing the angle. (AKA "Radar" mode)
    • Ctrl/Command Drag either end of the line to rotate it about its center and change its length symmetrically. (AKA "Propeller" mode) When you are zoomed in on an image, this modifier forces the ends of the line to start and stop on whole number pixel coordinate values (try it to see what this means).
    • Arrow Keys The four arrow keys are used to "nudge" selections one pixel at a time to the left, right, up, and down. (This is the only time nudging will be mentioned, but remember that it works for ALL selections. It does not, however, let you move any part of a selection outside the boundaries of the image. When there is no active selection, the up and down arrows function as "zoom in" and "zoom out" shortcuts.)
  • Test each of these modifiers separately and in combinations. (not all combinations will work). For example, can you do both "radar" and "propeller" modes at the same time? How about all three?
  • Open the gel sample image (File > Open Samples > Gel).
  • Use the straight line selection tool to select a vertical line down the center of the third lane from the left.
  • Choose Analyze > Plot Profile.
  • Double-click the straight line selection tool button on the ImageJ toolbar to open the Line Width dialog box, and set the line width to 20.
  • Activate the gel.gif image window and make another profile plot. Compare the two plots made from different width line selections.
  • Set the line width back to 1 pixel.
  • Close the gel, plot, and Line Width windows.
  • Returning to the Pasadena aerial image, set the scale (spatial calibration) for this image using the straight line selection tool to measure the width of the freeway overpass (bottom right) at the place where it crosses the center of the freeway. The width of the overpass is 33 meters. (Tip: Zoom in to the overpass before selecting it, and use the shift key to force the line to be vertical.)
  • Check your spatial calibration by measuring the long dimension of the parking structure in the lower left quadrant of the image.
  • Do you see the remains of a helipad toward the left end of the parking structure? Standard helipad markings are a circle or square 15 meters across. Do these markings meet the standard?

Line Tools Segmented Line Selection

Segmented line selections are used for the same purposes as straight lines. Do NOT, however, use the segmented line tool to make polygon area selections. There is a different tool for that purpose.

  • Right-click (PC) or control-click (Mac) the line selection tool on the ImageJ toolbar and choose the Segmented Line selection tool from the pop-up tool menu.
  • Create a segmented line selection anywhere on the Pasadena image.
  • Each click defines a new line segment. As you are selecting, the ImageJ status bar shows the length and angle of the current segment. To end the selection, either double-click the last endpoint or click in the small box at the beginning of the line selection. (Don't worry, this won't connect the two ends of the selection.)

  • Once selected, the handles at each vertex of the line can be dragged to new locations to refine the selection. If you accidentally click too far from a vertex and the selection disappears, use the Restore Selection command.
  • To move a segmented line selection, move the cursor over the selection until it becomes an arrow, then drag. Segmented line selections can be dragged beyond the boundaries of the image window. As you drag, the status bar reports information about the bounding box of the selection (the smallest rectangle to completely contain the selection): center (x,y), size (w,h), and aspect ratio (ar). Aspect ratio is simply the ratio of the width to the height of the box. An aspect ratio of 2.5 means that the width is two and a half times the height.
      Modifier Keys

    • Shift Shift-click a handle to split it into two separate handles to add more detail to the selection.
    • Alt/Option Alt- or Option-click a handle to delete it.
  • Test each of these modifiers before continuing to the next tool.

Line Tools Freehand Line Selection

Freehand line selections are used for the same purposes as straight and segmented lines. Don't use the Freehand Line tool to make freehand area selectionsthere is a different tool for that purpose.

  • Right-click (PC) or control-click (Mac) the line tool button to select the Freehand Line selection tool.
  • To select using this tool, simply click and drag the cursor around the image.
  • To move a freehand line selection, move the cursor over the selection until it becomes an arrow, then drag.
  • Freehand line selections can be dragged beyond the boundaries of the image window. As you drag, the status bar reports information about the bounding box of the selection.
  • Modifier keys have no effect on freehand line selections.

Line Tools Arrow Tool

Arrow selections are used for annotating (marking and labeling) images. You'll learn how to draw arrows and other shapes later. For now, just practice making arrow selections.

  • Right-click (PC) or control-click (Mac) the line selection tool on the ImageJ toolbar and choose the Arrow Tool from the pop-up tool menu.
  • Double-click the Arrow Tool button to open the Arrow Tool dialog box.

  • The Arrow Tool dialog box lets you set the width (of the line), size (of the head), color, and style (of the head) of arrows. You can also choose the arrow color and options for outlined and double-headed arrows.

Rectangle Tool

The Rectangle Tool is used to select rectangular areas to measure, analyze, or crop.

  • Right-click (PC) or control-click (Mac) the Rectangle selection tool on the ImageJ toolbar and choose the Rectangle tool from the pop-up tool menu.
  • Create a rectangular selection anywhere on the Pasadena image. The normal selection mode is to drag from one corner of the rectangle to the opposite corner, in any direction.
  • As you select or modify rectangles, the status bar reports the coordinates (of the cursor), dimensions, and aspect ratio of the rectangle.
  • Once selected, the handles at each corner and side of the rectangle can be dragged to refine the selection. If you accidentally click too far from a handle and the selection disappears, use the Restore Selection command.
  • To move a rectangular selection, move the cursor over the selection until it becomes an arrow, then drag. Rectangular line selections can be dragged beyond the boundaries of the image window.
      Modifier Keys

    • Shift Constrains the selection to a square.
    • Alt/Option After selecting, hold down the Alt or Option key to change the width and height by one pixel at a time using the four arrow keys. Only the bottom and right sides of the selection move. Watch the changing height, width, and aspect ratio in the ImageJ status bar.
    • Command (Mac)/Control (PC) Draws or resizes rectangle from the center.
    • Shift Constrains the selection to a square.
    • Command-Option (Mac)/Control-Alt (PC) Maintains the current aspect ratio as the square is resized.
    • Predict what will happen if you make a rectangular selection holding down the Command-Shift (Mac) or Control-Shift (PC) keys.
    • Select and measure the area of the rectangular block containing the park and apartment buildings.
  • Test each of these modifiers before continuing to the next tool.

Rounded Rectangle Tool

The Rounded Rectangle Tool selection tool is an annotation tool, used for drawing on and labeling images. Since it is not strictly a selection tool, it appears in the foreground color, not the selection color.

  • Right-click (PC) or control-click (Mac) the Rectangle selection tool on the ImageJ toolbar and choose the Rounded Rectangle Tool from the pop-up tool menu.
  • The behavior and modifiers for the Rounded Rectangle Tool are identical to the Rectangle Tool.
  • Double-click the Rounded Rectangle Tool in the ImageJ toolbar to open the tool's options dialog box.

  • Practice making rounded rectangle selections using different corner diameters, stroke (line) widths, colors, and fills before continuing to the next tool.

Oval Selections Tool

The Oval Selections Tool and its modifier keys work like the Rectangle Selection tool to select oval regions.

  • The status bar reports the coordinates, dimensions, and aspect ratio of the oval selection's bounding box.
  • Drag the oval selection handles to refine the selection.

Elliptical Selections Tool

The Elliptical Selections Tool and its modifier keys work like the Rectangle Selection tool to select oval regions.

  • No information is reported in the status bar for elliptical selections.
  • Drag the elliptical selection handles to refine the selection. If you accidentally click too far from a handle and the selection disappears, use the Restore Selection command.
  • Use either the Oval or the Elliptical Selection Tool to measure the area of the circular parking area on the center left edge of the block containing the park. (Hint: Use the modifier keys to select a circle from the center out.)

Selection Brush Tool

The Selection Brush Tool lets you create or adjust a selection using a circular "brush". This tool is particularly useful for touching up selections and for making visual selections of regions that don't have distinctive geometric or color characteristics.

  • Moving the brush from outside an existing selection into the selection shrinks (subtracts from), moving the brush from inside the selection out expands (adds to) the selection.
  • The status bar reports any changes in the selection bounding box as you make changes.
  • The brush diameter can be adjusted by double-clicking the Brush Selection Tool button on the ImageJ toolbar.

    Modifier Keys
  • Shift Always add the brush to the selection.
  • Alt/Option Always subtract the brush from the selection.
  • Use the Selection Brush Tool to measure the largest grassy area of the park (bounded by sidewalks). Where the trees are in the way, assume there is grass under them, right up to the edges of the sidewalks.

    Polygon Selection Tool

    The Polygon Selection Tool works like the Segmented Line Tool to trace areas by clicking at vertices around the polygon. To complete a selection, either double-click the last point or click in the small box at the beginning of the first side of the polygon.

    • Vertices are handles that can be moved.
    • The status bar reports any changes in the selection bounding box as you make changes. Modifier Keys
    • Shift Clicking a point with the shift key adds a new point.
    • Alt/Option Clicking a point with the Alt/Option key deletes a point.
  • Use the Polygon Selection Tool to measure the same grassy area of the park.

    Freehand Selection Tool

    The Freehand Selection Tool works just like the Freehand line tool, except that when you finish dragging the cursor, the beginning and end of the line connect to enclose an area.

    Angle Tool

    You've seen that you can measure angles with straight line selections, but they are always measured relative to the 3 o'clock position. The Angle Tool allows you to measure angles from any position.

    • To measure, the first click defines one ray, the second the vertex, and the third the other ray.
    • As you select or modify an angle selection, the status bar normally reads the interior angle 0°90°, which is always positive.
    • To read the exterior (reflex) angle (180°360°, double-click the Angle Tool button and change the appropriate setting.

    • Questionwhat is the interior angle between the two straight paths (one at about 12 o'clock, the other at 8:30 position)

    Point Tool

    This tool selects single points. Double-clicking the Point Tool button brings up this Point Tool dialog box.


    Multi-Point Tool

    The Multi-Point Tool selects (and numbers) multiple points in the same selection. Double-clicking this tool brings up the Add to Overlay dialog box, which you'll learn more about later.



    Wand (Tracing) Tool

    The Wand Tool creates a selection by tracing objects of uniform color or thresholded objects. To trace an object, either click inside near the right edge, or outside near the left edge of the object. Double-clicking the Wand tool allows you to set the pixel value tolerance for the selections. (In other words, how close do the values of the adjacent pixels have to be to include them in the selection.)



    Your Assignment: Use Selection Techniques to Analyze an Image

    1. Go to the Earth Observatory and download an image of interest to you.
    2. Spatially calibrate the image (set a scale).
    3. Use one of the selection techniques you have learned about to investigate features in the image.
    4. Next, measure one or more significant features.
    5. When you are finished, post the image to the Part 1: Share and Discuss Page. Then describe the selection technique you used and what you analyzed.
    6. Engage in an online discussion, sharing your ideas about using selection techniques in your teaching.

    Source

    1Adapted from Earth Exploration Toolbook chapter instructions under Creative Commons license Attribution-NonCommercial-ShareAlike 1.0.
    2Adapted from Eyes in the Sky II online course materials, Copyright 2010, TERC. All rights reserved.
    3New material developed for Earth Analysis Techniques, Copyright 2011, TERC. All rights reserved.