Notebook
"scikit-image(http://scikit-image.org/) is a collection of algorithms for image processing. It is available free of charge and free of restriction. We pride ourselves on high-quality, peer-reviewed code, written by an active community of volunteers." This document is aimed to serve as a supplement the already existing documentation. It is aimed at people new to open software development and more specifically, to IP using scikit-image and numpy. This document explains the various basic functions found in scikit-image library using Morphological techniques and illustrates each by showing the results on an image followed by some comments to provide an intuitive understanding of the techniques. You can check out the documentaion for individual modules using the help feature in python or '?' in ipython or directly browse through the files to see module specific information. Additional Resources : 1. http://scikit-image.org/docs/dev/ is the official site for documentation regarding the latest version. And of course google always to the rescue. 2. http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-14379 - provides a nice understanding of the most basic operations involved in morphological processing, i.e. erosion and dilation. This tutorial was developed using iPython Notebook. For best viewing experience install iPython, download the .ipynb file and view it as a notebook.
Usage : erosion(image, selem, out=None, shift_x=False, shift_y=False) Return greyscale morphological erosion of an image. Morphological erosion sets a pixel at (i,j) to the **minimum over all pixels in the neighborhood centered at (i,j)**. Erosion shrinks bright regions and enlarges dark regions. Parameters ---------- image : ndarray Image array. selem : ndarray The neighborhood expressed as a 2-D array of 1's and 0's. out : ndarray The array to store the result of the morphology. If None is passed, a new array will be allocated. shift_x, shift_y : bool shift structuring element about center point. This only affects eccentric structuring elements (i.e. selem with even numbered sides). Returns ------- eroded : uint8 array The result of the morphological erosion.
Documentation : Definition: dilation(image, selem, out=None, shift_x=False, shift_y=False) Docstring: Return greyscale morphological dilation of an image. Morphological dilation sets a pixel at (i,j) to the **maximum over all pixels in the neighborhood centered at (i,j)**. Dilation enlarges bright regions and shrinks dark regions. Parameters ---------- image : ndarray Image array. selem : ndarray The neighborhood expressed as a 2-D array of 1's and 0's. out : ndarray The array to store the result of the morphology. If None, is passed, a new array will be allocated. shift_x, shift_y : bool shift structuring element about center point. This only affects eccentric structuring elements (i.e. selem with even numbered sides). Returns ------- dilated : uint8 array The result of the morphological dilation.
Documentation : Definition: opening(image, selem, out=None) Docstring: Return greyscale morphological opening of an image. The morphological opening on an image is defined as an **erosion followed by a dilation**. Opening can remove small bright spots (i.e. "salt") and connect small dark cracks. This tends to "open" up (dark) gaps between (bright) features. Parameters ---------- image : ndarray Image array. selem : ndarray The neighborhood expressed as a 2-D array of 1's and 0's. out : ndarray The array to store the result of the morphology. If None is passed, a new array will be allocated. Returns ------- opening : uint8 array The result of the morphological opening.
Documentation : Definition: closing(image, selem, out=None) Docstring: Return greyscale morphological closing of an image. The morphological closing on an image is defined as a **dilation followed by an erosion**. Closing can remove small dark spots (i.e. "pepper") and connect small bright cracks. This tends to "close" up (dark) gaps between (bright) features. Parameters ---------- image : ndarray Image array. selem : ndarray The neighborhood expressed as a 2-D array of 1's and 0's. out : ndarray The array to store the result of the morphology. If None, is passed, a new array will be allocated. Returns ------- closing : uint8 array The result of the morphological closing.
Documentation : Definition: white_tophat(image, selem, out=None) Docstring: Return white top hat of an image. The white top hat of an image is defined as the **image minus its morphological opening**. This operation returns the bright spots of the image that are smaller than the structuring element. Parameters ---------- image : ndarray Image array. selem : ndarray The neighborhood expressed as a 2-D array of 1's and 0's. out : ndarray The array to store the result of the morphology. If None is passed, a new array will be allocated. Returns ------- opening : uint8 array The result of the morphological white top hat.
Documentation : Definition: black_tophat(image, selem, out=None) Docstring: Return black top hat of an image. The black top hat of an image is defined as its morphological **closing minus the original image**. This operation returns the *dark spots of the image that are smaller than the structuring element*. Note that dark spots in the original image are bright spots after the black top hat. Parameters ---------- image : ndarray Image array. selem : ndarray The neighborhood expressed as a 2-D array of 1's and 0's. out : ndarray The array to store the result of the morphology. If None is passed, a new array will be allocated. Returns ------- opening : uint8 array The result of the black top filter.
Documentation : Definition: skeletonize(image) Docstring: Return the skeleton of a **binary image**. Thinning is used to reduce each connected component in a binary image to a **single-pixel wide skeleton**. Parameters ---------- image : numpy.ndarray A binary image containing the objects to be skeletonized. '1' represents foreground, and '0' represents background. It also accepts arrays of boolean values where True is foreground. Returns ------- skeleton : ndarray A matrix containing the thinned image. See also -------- medial_axis Notes ----- The algorithm [1] works by making successive passes of the image, removing pixels on object borders. This continues until no more pixels can be removed. The image is correlated with a mask that assigns each pixel a number in the range [0...255] corresponding to each possible pattern of its 8 neighbouring pixels. A look up table is then used to assign the pixels a value of 0, 1, 2 or 3, which are selectively removed during the iterations. Note that this algorithm will give different results than a medial axis transform, which is also often referred to as "skeletonization". References ---------- .. [1] A fast parallel algorithm for thinning digital patterns, T. Y. ZHANG and C. Y. SUEN, Communications of the ACM, March 1984, Volume 27, Number 3
Documentation : Definition: convex_hull_image(image) Docstring: Compute the convex hull image of a **binary image**. The convex hull is the **set of pixels included in the smallest convex polygon that surround all white pixels in the input image**. Parameters ---------- image : ndarray Binary input image. This array is cast to bool before processing. Returns ------- hull : ndarray of uint8 Binary image with pixels in convex hull set to 255. References ---------- .. [1] http://blogs.mathworks.com/steve/2011/10/04/binary-image-convex-hull-algorithm-notes/