bilinear: Bilinear interpolator

Bilinear interpolator, peak finder, line-profile for images

class BilinearImage

Bilinear interpolator for images … or any data on a regular grid


Function f((y, x)) where f is a continuous function made from the image and (y,x)=(row, column) is the pixel coordinates in natural C-order


x – 2-tuple of float (row, column)


Interpolated signal from the image

coarse_local_maxi(self, Py_ssize_t x) Py_ssize_t

Return the nearest local maximum … without sub-pixel refinement


idx – start index (=row*width+column)


local maximum index

local_maxi(self, coord)

Return the nearest local maximum … with sub-pixel refinement

Nearest maximum search:

steepest ascent

Sub-pixel refinement:

Second order Taylor expansion of the function; At the maximum, the first derivative is null delta = x-i = -Inverse[Hessian].gradient if Hessian is singular or |delta|>1: use a center of mass.


coord – 2-tuple of scalar (row, column)


2-tuple of float with the nearest local maximum

map_coordinates(self, coordinates)

Map coordinates of the array on the image


coordinates – 2-tuple of array of the same size (row_array, column_array)


array of values at given coordinates

opp_f(self, coord)

Function -f((y,x)) for peak finding via minimizer.

Gives large number outside the boundaries to return into the image


x – 2-tuple of float in natural C order, i.e (row, column)


Negative interpolated signal from the image

profile_line(self, src, dst, int linewidth=1, method=u'mean')

Return the mean or sum of intensity profile of an image measured along a scan line.

  • src (2-tuple of numeric scalar) – The start point of the scan line.

  • dst (2-tuple of numeric scalar) – The end point of the scan line. The destination point is included in the profile, in contrast to standard numpy indexing.

  • linewidth (int) – Width of the scanline (unit image pixel).

  • method (str) – ‘mean’ or ‘sum’ depending if we want to compute the mean intensity along the line or the sum.


The intensity profile along the scan line. The length of the profile is the ceil of the computed length of the scan line.

Return type

1d array

Inspired from skimage