Week10

Concept of image in Python

Images are actually numpy arrays

http://scikit-image.org/docs/dev/user_guide/data_types.html

import numpy as np
import matplotlib.pyplot as plt
Chess = np.zeros((7,7))
Chess[ ::2,1::2] = 1
Chess[1::2, ::2] = 1
plt.imshow(Chess)
plt.show()

Import and Save images in Python

  • You can both import an image from your disk, or from a URL. It can be done with the help of io library inside skimage.

  • You can import/load an image by following :

    from skimage import io
    my_image = io.imread('filename')
    # OR
    my_image = io.imread('URL')
  • And, you can save an image on your disk by following :

    from skimage import io
    io.imsave('filename', my_image)
  • Example :

    from skimage import io
    import matplotlib.pyplot as plt
    my_image = io.imread('https://homepages.cae.wisc.edu/~ece533/images/lena.png')
    plt.imshow(my_image)
    plt.show()

Rotation dev--degree

Resize

Rescale

RGB to HSV | HSV to RGB

RGB to Grey-Scale

Drawing Shapes

edge detection

An edge is a curve that follows a path of rapid change in image intensity/brightness. Edges are often associated with the boundaries of objects in a scene. The term “edge‟ accounts for a local luminance change.

Contour detection

http://scikit-image.org/docs/dev/auto_examples/edges/plot_contours.html

Active Contours: snake model

Object Detection: Template Matching

Template matching is a technique for finding areas of an image that match (are similar) to a template image (patch).

Denoising

Three popular methods for filtering the noise:

  • Wavelet

  • Total Variation (TV)

  • Bilateral filters

Binarization

  • Otsu Method

  • Mean Method

  • Li Method

  • Yen Method

  • Minimum Method

  • Isodata Method

Exercise

From the data folder import the image called dice.jpg, and do the followings : 1. Read the input image, convert it to grayscale, and blur it slightly. 2. Use simple fixed-level thresholding to convert the grayscale image to a binary image. 3. Find contours corresponding to the outlines of each dice. 4. Print information on how many dices can be found in the image. 5. For illustrative purposes, mark the centre position of each dice in the image grid so we can visualize the results.

Last updated

Was this helpful?