5088
How ENVI selects pixels within an ROI
This Help Article discusses the method ENVI uses to select pixels contained in an ROI (region of interest).
It is often desirable to select regions of interest (ROIs) in an image scene to isolate areas in which further processing is intended, to select training sites for classification, and for many other image processing tasks. Many users ask exactly how ENVI selects which pixels are included in an ROI, especially when the ROI is based on a user-drawn vector which might include partial pixels.
A ROI in ENVI is a raster-based group of pixels. This means that entire pixels, and not partial pixels, are selected within an ROI. However, some elements of ROIs (like user-drawn polygons and polylines) are stored as vector shapes. Often, these polygons and polylines will 'cut through' a pixel and only show a partial pixel within the drawn ROI. In these cases, ENVI must determine which pixels are contained within the given shape. But remember, even though some ROIs are defined by vectors, they are simply ways to determine a group of raster pixels.
ROI polygons, polylines and points are each handled differently. Points are the simplest case because a point will define a single pixel in a ROI. Polylines are more complex. Although it is rare to explicitly set a number of pixels for an ROI, polylines define the pixels underneath it by using a rise-to-run method of joining two raster points.
For example:
Two points in a cartesian coordinate system lies at P1=(x1, y1) and P2=(x2, y2). The rise is calculated as (y2 - y1) and the run is calculated as (x2 - x1). Pixels along this line are included in the ROI.
ROIs defined using a polygon use the IDL routine POLYFILLV to figure out which pixels are contained within the polygon. This is described in the IDL On-Line Help for POLYFILLV:
The scan line coordinate system defined by Rogers in Procedural Elements for Computer Graphics, McGraw-Hill, 1985, page 71, is used. In this system, the scan lines are considered to pass through the center of each row of pixels. Pixels are activated if the center of the pixel is to the right of the intersection of the scan line and the polygon edge within the interval.
Sometimes, the above algorithm results in unexpected pixels contained or absent in the defined ROI. This can happen if the vector polygons are not rectangles and have a slight skew. Even slight skew in the polygon can cause inappropriate pixel selection in the filling algorithm. If this happens, you can select or de-select pixels in the polygon by first, pixelating the polygon area (using the Pixel function in the ROI Tools dialog), and then editing the pixels manually in the ROI.
NOTE: The 'Pixel' function was reinstaed in ENVI 3.6, but is absent in ENVI 3.4/3.5. If you have an earlier version of ENVI and you encounter inappropriate pixel selection in a ROI, you might consider upgrading to the latest version of ENVI or draw the ROI using Point selection to obtain greater accuracy in ROI area selection.
Review on 12/31/2013 MM