Login  Register

Re: Measuring along oblique lines

Posted by Sullivan, Michael J (College of Med.) on Apr 05, 2007; 4:27pm
URL: http://imagej.273.s1.nabble.com/Measuring-along-oblique-lines-tp3699835p3699837.html

Fintan, I ran into this oblique line problem in a different situation
and had to write code that would read the pixel values along a "strait"
contiguous line (pixels touching either at edge or at corner) from one
set of pixel coordinates to another. Your welcome to this code (you'll
have to adapt it to your needs but the underlying algorithm should
work).  Also, someone else may respond with a more complete solution and
I'll realize I've just needlessly reinvented the wheel. Let me know if
you want my code.  --- Mike Sullivan

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Fintan McEvoy
Sent: Thursday, April 05, 2007 10:15 AM
To: [hidden email]
Subject: Measuring along oblique lines

Hi,

Can anybody help with what are probably very basic questions?

My questions :

If a line selection runs obliquely across the image how does
"getProfile" in ImageJ count pixels?
Does it count every pixel the line  touches?  
Can I accurately measure distances along oblique lines in ImageJ?
Is there any merit in measuring aling lines parallel to either the x or
y axis?


I know that the line is drawn from the upper left corner of each pixel I
specify in the  makeLine command.
If the line is parallel with the side of the pixel,  ImageJ will count
the exact number of pixels  between two points of interest along the
line and since I  know the pixel dimensions, I can then calculate a
distance that interests me.

The detail of what I am doing is below:


I am using  a macro that contains written to run on CT images.  I  want
to measure the thickness  of subcutaneous adipose tissue. The while
statment below starts checking the value of the pixel at  "i", this will
be less than zero for air outside the patient , more than zero for skin
and then again less than zero for adipose tissue. Thus the the junction
between skin and adipose tissue is detected ad the variable "outer" gets
the value of "i", the process is repated to give the inner edge.  Since
the lne is parallel with the y axis of the image , all I need to do to
get the thickness of the tissue in pixels is subtract the value of the
variable "outer" from the value of "i" when it is stoped at the "inner
edge"

In order to make measurements around the whole circumference of the
patient I have opted to rotate the image and not the line because I am
not clear what ImageJ, "getProfile" does with oblique lines,  


selectImage("temp6.dcm");
   w = getWidth/2;
   h = getHeight/2;
   makeLine (w,0,w,h);
   value=getProfile;
   i=0;
   while (value[i]<0) {i++;}
   //outer adipose edge
   while (value[i]>0) {i++;}
   outer=i;
   //inner adipose edge
   while (value[i]<-0) {i++;}
   //sub cutis fat thickness
   t=(outer-i)*(-1);



Thanks in anticipation for any help

Fintan McEvoy