Getting Started with Scikit-image: Image Processing in Python



Important features of scikit image:

Simple and efficient tools for image processing and computer vision techniques.
Accessible to everybody and reusable in various contexts .
Built on the top of NumPy, SciPy, and matplotlib.
Open source, commercially usable – BSD license.

Note. Make sure NumPy and SciPy are preinstalled before installing scikit-image. Now the easiest way to install scikit image — use pip :

 pip install -U scikit-image 

Most of the ski wizard`s functions are inside submodules. Images are represented as NumPy arrays, such as 2D arrays for 2D grayscale images.

Code # 1:

# Python3 processing program
# images using skikit-image

 
# import data from the ski mage

from skimage import data

 

camera = data. camera () 

 
# 512-line image
# and 512 columns

type (camera) 

 

print (camera.shape)

Output:

 numpy.ndarray (512, 512) 

Code # 2: The skimage.data submodule provides a set of functions that return sample images.

# Python3 processing program
# images using skikit-image

 
# import filters and
# data from the ski mage

from skimage import filters

from skimage import data

 
# Predefined function to retrieve data

coins = data.coins () 

 
# how to find the threshold

threshold_value = filters.threshold_otsu (coins) 

 

print (threshold_value)

Output:

 107 

Code # 3: Upload your own images as NumPy arrays from image files.

< tbody>

# Python3 processing program
# images using skikit -image

import os

 
# import from ski mage

import skimage

from skimage import io

 
# way to load car image from file

file = os.path.join (skimage.data_dir, `cc.jpg` )

 

 < / p>

cars = io.imread ( file )

 
# a way to show the input image
io.imshow (cars)
io .show ()

Output:

Applications:

  • Medical image analysis.
  • Image classification for detection.