Line Profile Diagonal

Viewed 29

When you make a line profile of all x-values or all y-values the extraction from each pixel is clear. But when you take a line profile along a diagonal, how does DM choose which pixels to use in the one dimensional readout?

1 Answers

Not really a scripting question, but I'm rather certain that it uses bi-linear interpolation between the grid-points along the drawn line. (And if perpendicular integration is enabled, it does so in an integral.) It's the same interpolation you would get for a "rotate" image. In fact, you can think of it as a rotate-image (bi-linearly interpolated) with a 'cut-out' afterwards, potentially summed/projected onto the new X-axis.

Here is an example

Assume we have a 5 x 4 image, which gives the grid as shown below. I'm drawing top-left corners to indicate the coordinates system pixel convention used in DigitalMicrgraph, where
(x/y)=(0/0) is the top-left corner of the image

Now extract a LineProfile from (1/1) to (4/3). I have highlighted the pixels for those coordinates.

Note, that a Line drawn from the corners seems to be shifted by half-a-pixel from what feels 'natural', but that is the consequence of the top-left-corner convention. I think, this is why a LineProfile-Marker is shown shifted compared to f.e. LineAnnotations.

In general, this top-left corner convention makes schematics with 'pixels' seem counter-intuitive. It is easier to think of the image simply as grid with values in points at the given coordinates than as square pixels.

Now the maths.

The exact profile has a length of:

ProfileLength

As we can only have profiles with integer channels, we actually extract a LineProfile of length = 4, i.e we round up.

The angle of the profile is given by the arc-tangent of dX and dY.

So to extract the profile, we 'rotate' the grid by that angle - done by bilinear interpolation - and then extract the profile as grid of size 4 x 1:

This means the 'values' in the profile are from the four points:

Which are each bi-linearly interpolated values from four closest points of the original image:

In case the LineProfile is averaged over a certain width W, you do the same thing but:

  • extract a 2D grid of size L x W centered symmetrically over the line.
    i.e. the grid is shifted by (W-1)/2 perpendicular to the profile direction.

  • sum the values along W

Related