Edge Detection in Images

IMAGE_EDGE, a MATLAB library which demonstrates the detection of edges in an image.

NEWS is a particularly simple edge detection scheme, which compares the North, East, West, and South neighbors of a pixel to determine if the pixel lies along an edge.

There are many sophisticated edge detection algorithms, and MATLAB has many of them built into its image processing toolbox. The purpose of these examples is simply to demonstrate how a simple version of such edge detection schemes works.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


IMAGE_EDGE is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

CELL_DETECTION_TASKS, a MATLAB program which creates modified versions of a sequence of gray-scale TIF files containing images of cells; the process of each file is carried out independently, using the "task" feature of MATLAB's parallel computing toolbox.

COLOR_REMOTE, a MATLAB program which carries out the color segmentation of an image in parallel, via SPMD commands; this includes instructions on how to run the job, via MATLAB's BATCH facility, on a remote system such as Virginia Tech's ITHACA cluster.

CONTRAST_SPMD, a MATLAB program which demonstrates the SPMD parallel programming feature for image operations; the client reads an image, the workers increase contrast over separate portions, and the client assembles and displays the results.

CONTRAST2_SPMD, a MATLAB program which demonstrates the SPMD parallel programming feature for image operations; this improves the contrast_spmd program by allowing the workers to share some data; this makes it possible to eliminate artificial "seams" in the processed image.

EDGE, a MATLAB library which defines some test functions in 1D, 2D and 3D for the detection of edges.

  • IMAGE_BOUNDARY, a MATLAB library which reports the pixels which form the boundary between the black and white regions of a simple image.
  • IMAGE_COMPONENTS, a MATLAB library which seeks the connected "nonzero" or "nonblack" components of an image or integer vector, array or 3D block.

    IMAGE_CONTRAST, a MATLAB program which applies image processing techniques to increase the contrast in an image.

    IMAGE_DECIMATE, a MATLAB library which compresses an image by dropping the even rows and columns of data.

    IMAGE_DENOISE, a MATLAB program which applies image processing techniques to remove noise from an image.

    IMAGE_DIFFUSE, a MATLAB library which uses diffusion to smooth out an image.

    IMAGE_DOUBLE, a MATLAB library which doubles the height and width of an image by repeating each row and column.


    IMAGE_MATCH_GENETIC, a MATLAB program which tries to match a 256x256 JPEG image by blending 32 colored rectangles, using ideas from genetic algorithms, based on an example by Nick Berry.

    IMAGE_NOISE, MATLAB programs which add noise to an image.

    IMAGE_QUANTIZATION, a MATLAB library which demonstrates how the KMEANS algorithm can be used to reduce the number of colors or shades of gray in an image.

    IMAGE_RGB_TO_GRAY, MATLAB programs which makes a grayscale version of an RGB image.

    IMAGE_THRESHOLD, a MATLAB library which makes a black and white version of a grayscale image by setting all pixels below or above a threshold value to black or white.

    PGMA_IO, a MATLAB library which handles the ASCII Portable Gray Map (PGM) format.


    1. Jonas Gomes, Luiz Velho,
      Image Processing for Computer Graphics,
      Springer, 1997,
      ISBN: 0387948546,
      LC: T385.G65.

    MathWorks documentation for the Image Processing Toolbox is available at

    Source Code:

    Last modified on 02 February 2019.