In [1]:
from IPython.display import Image
Image(filename='Figs_ipandcg_2014/2014_Session_3.png')
Out[1]:

Python Imaging Library (PIL)

The Python Imaging Library (PIL) provide us with additional 2D image processing algorithms. PIL consists of several modules. To become acquainted with its capabilities go throuout tutorial; additional exercises you can find here (subsections 2010 Sessions 1-3).

Import functionality of PIL as Image.

In [4]:
import Image

Load image from file into variable 'im'.

In [15]:
im = Image.open('images_2014/FluorescentCells.jpg')

If you receive error message:

AttributeError: 'NoneType' object has no attribute 'bands'

you have to load data manually. Add this line:

im.load()

In [16]:
im.load()
Out[16]:
<PixelAccess at 0x6647590>
Print basic information about loaded image.
In [3]:
print im.format, im.size, im.mode
JPEG (512, 512) RGB

Image.show() method enables to display im variable in the default operating system viewer.
In [4]:
im.show()

Split RGB imiage into 3 separate bands.

In [17]:
r,g,b = im.split()

Based on 2010 IPandCG tutorial - Part 1 and PIL handbook do following operations:

Perform various filtration types of the im variable. Apply filtration for several parameter values for each filtration. Note the results for values bigger than 1 and smaller than 1. Read additional information about image filtering and edge detection (slides by prof. Paweł Strumiłło and prof. Michał Strzelecki). 

ImageEnhance Module (see 2010 IPandCG tutorial - Part 2)

ImageFilter Module

Linear filtering

Compese your own averaging filter based on slides. Use 3 x 3 mask. Propose two versions of filter:

Multi-dimensional image processing (scipy.ndimage)

Load image "blood1.bmp". Perform image thresholding e.g. with thresh equal to 126. This is not optimal threshold value. Try to find better one. Theoretical background of thresholding you can find here (by prof. Paweł Strumiłło, prof. Michał Strzelecki).

Browse capabilities of morphological opearation of ndimage library. Theory on mathematical morphology is provided in lecture. On thresholded, binary image perform some operations:

Write your own function that perform

Compare with 2010 IPandCG tutorial - Part 3.