The project which I am working in Google Summer of Code’ 15 is a combined project of two organizations scikit-image and scipy. There is a module ndimage in scipy for multidimensional image processing. Scikit image also uses this module for many of its image processing functions.

Objective of Project– The whole module has been written in C using Python-C API and my task is to rewrite the module into cython that will make the code easier to read and maintain. The main challenge expected that is expected is to maintain the same speed as that of c implementation.

About scipy.ndimage module:-

The module has basically following major divisions:-

  1. Filter Functions:- All the functions in this section perform some kind of spatial filtering of the input array. The output in each of them are some function of neighboring elements of input elements. These neighbour elements are termed as kernel.
  2. Correlation and Convolution:- The function under correlation calculate both one-dimensional and multidimensional correlation of the input array with a given kernel. Convolution functions just do the correlation after mirroring the kernel. So in it the result is shifted in the opposite direction.
  3. Smoothing and Generic Filter functions:- In this section mainly Guassian and Generic filters are implemented.
  4. Interpolation functions:- This section contains different based on B- Spline theory. These function mainly employ spline interpolation to effect some type of geometric transformation to the input array.
  5. Morphology functions:- The function under this section are used analysis and processing of geometrical structures. This also includes implementation of grey-scale  morphology.
  6. Segmentation and labeling:- Segmentation is the process of separating objects of interest from the background. The function label generates an array where each object is assigned a unique number.

Further details and examples of above functions can be seen here.

scipy.ndimage implementation details:- As said above the whole module is written in c using python – c API. The module depends upon 3 basic constructs defined in support.c file:-

  1. Iterators: NI_Iterator in its three variants:- point, subspace and line.
  2. Buffer: NI_LineBuffer
  3. Filter Iterator:

In the next blog I will be write about how these construct actually work and explain their implementation.

For porting what the initial plan is:- We will try to find a pair of basic construct in support.c and an underlying function in the module which uses only that construct. Going this way will help us in keeping track of correctness and performance at each step in rewriting.