Freehand line Selection, Problem Creating points

Sample image and/or code

Background

  • I am creating a set of ROI based on the user’s “freehand line” selection.
    In the first step, the user is prompted to draw a freehand line around some object of interest.
    Next, the script creates a point list from the selection.
    Then, the script goes through each point and evaluates some criteria to decide whether this point should be the center of a ROI, or not.

The problem: Depending on whether the user draws the freehand line quickly or slowly, it completely changes the number of points that are underlying said line.
The image shown illustrated an extreme case. (Left-slow-many points. Right-fast-few points)

I want there to be a point for each pixel that the line goes through. Is there a way to obtain the x-y coordinates of all pixels that the freehand line intersects?

Or another workaround for this issue?

Note that in the smooth example on the left, also there the number of points generated varies greatly depending on where it is in the curve… this is problematic for my goals.

getSelectionCoordinates(xpoints, ypoints);
Array.show("x,y-coords", xpoints, ypoints);

Hi @dlite-x

It looks like

run("Interpolate", "interval=1");

(Edit > Selection > Interpolate)
gets you close, though it looks not to be pixels, but rather line segments of length 1.0.
If you need, rounding and removing duplicates will get you to pixels.

John

1 Like