Detecting and Enhancing Edges and Lines

The following methods let you detect and enhance edges and lines:

EdgeDetector method

EdgeDetectorExt method

Sharpen method

SpatialFilter method

IntensityDetect method

UnsharpMask method

EdgeDetectEffect method can be used to detect the edges in a bitmap and then replace the values of the edges with calculated values.

The Sharpen method is designed specifically to emphasize the edges (shifts in intensity) in a bitmap. It is a high-level method that can be used alone for the desired effect.

The SpatialFilter method provides several predefined filters for detecting edges or lines. These filters can be used alone in applications, such as industrial inspection systems, that analyze images. They can also be used to create an image that is combined with the original to change the appearance of lines or edges.

Choosing a filter is a subjective, application-specific decision. The filters use standard algorithms, some of which have similar purposes. You may need to experiment with them to choose the appropriate filter for your application. The following is a summary of the available filters:

Filter

Purpose

Emboss

Creates an image with an embossed appearance. (This is used for artistic effect, but is listed here because it is one of the predefined filters.)

Gradient directional

Detects edges, starting from any of eight specified directions. All pixels not on the detected edges are changed to black.

Prewitt

Detects horizontal or vertical edges. All pixels not on the detected edges are changed to black.

Sobel

Detects horizontal or vertical edges. All pixels not on the detected edges are changed to black. (The usage is the same as Prewitt, but the algorithm is different.)

Shift-and-difference

Detects horizontal, vertical, or diagonal edges. All pixels not on the detected edges are changed to black.

Laplacian

Detects lines. There are three omnidirectional filters and three bi-directional ones. All pixels not on the detected lines are changed to black.

Line-segment

Detects line segments. Possible directions are horizontal, vertical, left-to-right diagonal, and right-to-left diagonal. You can use this filter to find line discontinuities in an image. All pixels not on the detected line segments are changed to black.

To overcome the directional limitations of these filters, you can combine images that have been filtered in different ways. For example, you could make three copies of a bitmap, filter each one with a different Laplacian directional filter, and use the Combine method to create a bitmap with all of the detected lines. You could then combine this resulting bitmap with the original to enhance the lines in the original. For more information on combining images, refer to Combining Images.

The IntensityDetect method does not use a filter to detect edges or lines, but for some images it is more effective than the filters in detecting lines that are lighter or darker than other parts of the image.

The Skeleton method can be used to find the skeleton of regions or objects in a binary bitmap. The white color represents the objects and the black color represents the background. If the bitmap is not 1-bit image, the threshold will be used to transform the bitmap into a binary image before finding the skeleton.

The ContourFilter method applies a contour segment filter to the bitmap, creating a "contour map" of the bitmap.

The EdgeDetectStatistical method can be used to detect the edges in a bitmap by applying a statistical filter that analyzes the variations of colors in all directions around each pixel.

The GlowFilter method can be used to make the colored edges in a bitmap shine with a neon-like glow.

The SmoothEdges method can be used to smooth the rough edges in a bitmap.

The EdgeDetectStatistical method can be used to detect the variation of colors in the specified direction using statistical indices. It is similar to EdgeDetectStatistical method, but this method allows you to specify the direction angle.

The EdgeDetectEffect method performs edge detection on the image.