Image processing functions are generally thought to operate over two-dimensional arrays of value. There are however a number we need to operate over images with more than wo dimensions. The scipy.ndimage module is an excellent collection of a number of general image processing functions which are designed to operate over arrays with arbitrary dimensions. This module is an extension of Python library written in C using Python – C API to ameliorate its speed. The whole module can be broadly divided into 3 categories:-

  • Files containing wrapper functions:- This includes the nd_image.h and nd_image.c files. ndimage.c file mainly contains functions required for extension of module in c viz. All the wrapper functions along with other module initialization function and method table.
  • Files containing basic constructs:- These are in the files ni_support.c and ni_support.h. These constructs include a mixture of some containers, macros and various functions. These constructs are like arteries of the module and it can be summarised in three functions:-
    1. NI_Iterators and its other variants, NI_LineIterator and NI_SubspaceIterator
    2. NI_FilterIterator
    3. NI_LineBuffer

    I will explain these constructs in detail in further blogs.

  • Files containing all the underlying functions:- It includes files ni_filter.c, ni_fourier.c, ni_interpolation.c, ni_measure.c and ni_morphology.c. All the general image processing functions of the module are defined in these files.

For rewriting the module our plan of action as suggested by my mentor Jaime is something like:-

  1. Implement basic iteration
  2. Implement a couple of selected functions that only use basic iteration
  3. Implement iteration over buffered lines
  4. Implement a couple of selected functions that only use these two types of iteration
  5. Implement iteration over a neighborhood of a point, i.e. filter iteration
  6. Implement a couple of selected functions that use the three types of iteration
  7. Is there any other basic functionality needed by any function? While true, repeat the above two-step pattern.
  8. Once all basic functionality is in place, implement all other missing functions.

In order to identify specific functions in points 2, 4 and 6, I have made a list of all constructs used by various functions in the module. It can be seen here. We will use this list to decide the order of poting of functions.

</keep coding>