Scikit-image Python Library for Image Processing
scikit-image is an image processing library that implements algorithms and utilities for use in research, education and industry applications. It is released under the liberal Modified BSD open source license, provides a well-documented API in the Python programming language, and is developed by an active, international team of collaborators.
This post describes scikit-image, a collection of image processing algorithms implemented in the Python programming language by an active community of volunteers and available under the liberal BSD Open Source license. The rising popularity of Python as a scientific programming language, together with the increasing availability of a large eco-system of complementary tools, makes it an ideal environment in which to produce an image processing toolkit.
scikit-mage represents images as NumPy arrays, the de facto standard for storage of multi-dimensional data in scientific Python. Each array has a dimensionality, such as 2 for a 2-D grayscale image, 3 for a 2-D multi-channel image, or 4 for a 3-D multi-channel image; a shape, such as (M, N, 3) for an RGB color image with M vertical and N horizontal pixels; and a numeric data type, such as float for continuous-valued pixels and uint8 for 8-bit pixels. Use of NumPy arrays as the fundamental data structure maximizes compatibility with the rest of the scientific Python ecosystem. Data can be passed as-is to other tools such as NumPy, SciPy, matplotlib, scikit-learn, Mahotas, OpenCV, and more.
Images of differing data-types can complicate the construction of pipelines. scikit-image follows an “Anything In, Anything Out” approach, whereby all functions are expected to allow input of an arbitrary data-type but, for efficiency, also get to choose their own output format. Data-type ranges are clearly defined. Floating point images are expected to have values between 0 and 1 (unsigned images) or −1 and 1 (signed images), while 8-bit images are expected to have values in {0, 1, 2, …, 255}. We provide utility functions, such as img_as_float, to easily convert between data-types.
Scikit Image Library overview
The scikit-image project started in August of 2009 and has received contributions from more than 100 individuals. The package can be installed on all major platforms (e.g., BSD, GNU/Linux, OS X, Windows) from, amongst other sources, the Python Package Index (PyPI), Continuum Analytics Anaconda, Enthought Canopy, Python(x,y), NeuroDebian and GNU/Linux distributions such as Ubuntu.
Sickit-image Modules
As of version 0.13, the package contains the following sub-modules:
color: Color space conversion.
data: Test images and example data.
draw: Drawing primitives (lines, text, etc.) that operate on NumPy arrays.
exposure: Image intensity adjustment, e.g., histogram equalization, etc.
feature: Feature detection and extraction, e.g., texture analysis, corners, etc.
filters: Sharpening, edge finding, rank filters, thresholding, etc.
graph: Graph-theoretic operations, e.g., shortest paths.
io: Wraps various libraries for reading, saving, and displaying images and video, such as Pillow and FreeImage.
measure: Measurement of image properties, e.g., similarity and contours.
morphology: Morphological operations, e.g., opening or skeletonization.
novice: Simplified interface for teaching purposes.
restoration: Restoration algorithms, e.g., deconvolution algorithms, denoising, etc.
segmentation: Partitioning an image into multiple regions.
util: various utiltiy functions like imgae type conversion etc.
transform: Geometric and other transforms, e.g., rotation or the Radon transform.
viewer: A simple graphical user interface for visualizing results and exploring parameters.
Getting Started with Scikit-image
scikit-image is an image processing Python package that works with numpy arrays. The package is imported as skimage:
import skimage
Most functions of skimage are found within sub-modules:
from skimage import data img = data.camera() # loading cameraman image from the sub-module data. plt.imshow(img) io.show()
result of the above code is
Of course, it is also possible to load your own images as NumPy arrays from image files, using skimage.io.imread()
from skimage import io img = io.imread('boat.tiff') #file should be in current working directory. io.imshow(img) io.show()
Source:
This article is contributed by Ram Kripal. If you like eLgo Academy and would like to contribute, you can mail your article to admin@elgoacademy.org. See your article appearing on the eLgo Academy page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.