Re: Get intensities along polyline

Posted by lechristophe on
URL: http://imagej.273.s1.nabble.com/Get-intensities-along-polyline-tp5018818p5018821.html

Hi Greg,

I have another script where I do that:
https://github.com/cleterrier/Measure_ROIs/blob/master/Pro_Feat_Fit.js

It's the functions getCoordinates (line1077) and getFullCoordinates (with
1-pixel spacing interpolation, line 1093)

Christophe



//*************************************************************************************
// takes an i+, roimanager, index and returns an array of two arrays : x
and y coordinates (no interpolation)
function getCoordinates(imp, rm, r) {
rm.select(imp, r);
var roi = imp.getRoi();
var rpoly = roi.getInterpolatedPolygon();
var xPoints = rpoly.xpoints;
var yPoints = rpoly.ypoints;
var xCoor = new Array(xPoints.length);
var yCoor = new Array(yPoints.length);
for (var i = 0; i < xPoints.length; i++) {
xCoor[i] = xPoints[i];
yCoor[i] = yPoints[i];
}
return [xCoor, yCoor];
}
//*************************************************************************************
// takes an i+, roimanager, index and returns an array of two arrays : x
and y coordinates with 1-px interpolation
function getFullCoordinates(imp, rm, r, length) {
rm.select(imp, r);
var roi = imp.getRoi();
if (roi.getType() != 5) roi.fitSplineForStraightening();
var xPoints = roi.getFloatPolygon().xpoints;
var yPoints = roi.getFloatPolygon().ypoints;
var xCoor = new Array(xPoints.length);
var yCoor = new Array(yPoints.length);
for (var i = 5; i < xPoints.length; i++) {
xCoor[i] = xPoints[i];
yCoor[i] = yPoints[i];
}
return [xCoor, yCoor];
}

On Thu, Jun 1, 2017 at 1:57 PM, Greg <[hidden email]> wrote:

> Hi Christophe,
>
> yes thx that works! As I would also need the corresponding x,y coordinates,
> I guess I can take the ones from the getFloatPolygon method?!
>
> Best,
> Greg
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.
> com/Get-intensities-along-polyline-tp5018818p5018820.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html