ncempy.eval.line_profile module

ncempy.eval.line_profile.line_profile(im0, p0, p1, num_points, width=0, step=0.5)[source]

Use interpolation to measure a line scan across a 2D image. map_coordinates uses a different convention from numpy indexing. So the x and y positions need to be flipped.

Parameters:
  • im0 (ndarray) – The 2D array of the image

  • p0 (tuple) – The start of the line scan (x0,y0) and (row,col)

  • p1 (tuple) – The end of the line scan (x1,y1)

  • num_points (int) – The number of points in the line scan

  • width (int) – The width of the line scan to average over. Must be an integer.

  • step (float) – The step size laterally for the interpolation. Must be < 1

Returns:

A tuple containing the line profile and the positions where the interpolation was performed

Return type:

tuple

Note

As an example: if width = 1 and step = 0.5 then there will be 3 line scans averaged.

Example

>> line, (xx, yy) = line_profile(image, (0, 100), (175, 100), 50, step=0.5, width=5) >> fg, ax = plt.subplots(1, 2) >> ax[0].plot(line, ‘-‘) >> ax[1].imshow(image) >> ax[1].scatter(yy, xx)