Get intensities along polyline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Get intensities along polyline

Greg
Hello,

I want to get the intensities along a PolygonRoi, which is of polyline subtype. There seems to be no getPixels() method or alike as for straight lines?! With the GUI, the Plot Profile command readily plots the intensities along arbitrary line selections, what would be the best way to do it programmatically (e.g. with jython or java script)?

I guess I could manually get the x- and y-coordinates of the polyline, and then call the getPixelInterpolated(x,y) method of the actual ImageProcessor, I wonder if there is some already some convenience function for that?

Thx,
Gregor


PS: I guess the answer is already somewhere hidden in this forum but I can't find it
Reply | Threaded
Open this post in threaded view
|

Re: Get intensities along polyline

lechristophe
hi Greg,

I get the intensity profile from lines or segmented lines in my
autocorrelation javascript available here:
https://github.com/cleterrier/Process_Profiles/blob/master/Autocorrelation_.js

The relevant lines are 80 to 92: it activates the roi from the ROI manager
on the image plus, gets the profile plot then gets the Y values form the
plot.

rm.select(imp, r);
var profPlot = new ProfilePlot(imp);
var rawY = profPlot.getProfile();

Hope this helps,

Christophe

--
Christophe Leterrier
NeuroCyto lab
NICN CNRS UMR 7259
Aix Marseille University, France






On Thu, Jun 1, 2017 at 11:50 AM, Greg <[hidden email]> wrote:

> Hello,
>
> I want to get the intensities along a PolygonRoi, which is of polyline
> subtype. There seems to be no getPixels() method or alike as for straight
> lines?! With the GUI, the Plot Profile command readily plots the
> intensities
> along arbitrary line selections, what would be the best way to do it
> programmatically (e.g. with jython or java script)?
>
> I guess I could manually get the x- and y-coordinates of the polyline, and
> then call the getPixelInterpolated(x,y) method of the actual
> ImageProcessor,
> I wonder if there is some already some convenience function for that?
>
> Thx,
> Gregor
>
>
> PS: I guess the answer is already somewhere hidden in this forum but I
> can't
> find it
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.
> com/Get-intensities-along-polyline-tp5018818.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
Reply | Threaded
Open this post in threaded view
|

Re: Get intensities along polyline

Greg
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
Reply | Threaded
Open this post in threaded view
|

Re: Get intensities along polyline

lechristophe
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