How do I draw a line that has an origin coord but ends when it hits white (ie 255)?

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

How do I draw a line that has an origin coord but ends when it hits white (ie 255)?

Nikolas Jorstad
Hello,
 
My name is Nik and I am attempting to make a macro for quantifying human
 myelin thickness around axons in the optic nerve. I am able to do all the
 image processing necessary but am hitting a dead end on the final leg of
 the script.
 
My final image is in binary and looks like different shaped rings of
 different thicknesses. I need code that will draw a line, starting at the
 inner Feret Diameter, following the Feret Angle outwards until it hits the
 white background. In essence, the drawn lines will measure the thickness of
 these oblong loops. I am only aware of being able to draw a line from
 (X1,Y1) to (X2,Y2). Is there anyway to give the line a starting point and
 have it follow the Feret Angle until it hits color value = 255 (white)?
 
Thank you to anyone who may be able to help.
 

Nik
 

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How do I draw a line that has an origin coord but ends when it hits white (ie 255)?

Peter van Loon
Hi Nik, I'm not sure if I understand your question well (a picture may help). Maybe this code can help: To draw a line based on a center coordinate and angle: function makeLineC(centerX, centerY, length, angle) { angle = -angle * PI / 180; dX = cos(angle) * length / 2; dY = sin(angle) * length / 2; makeLine(centerX - dX, centerY - dY, centerX + dX, centerY + dY); } To draw a line based on an end coordinate and angle: function makeLineE(centerX, centerY, length, angle) { angle = -angle * PI / 180; dX = cos(angle) * length / 2; dY = sin(angle) * length / 2; makeLine(centerX, centerY, centerX + dX, centerY + dY); } By measuring the black and white(255) pixels you can use this function: function countMinMax(){ profileValues=getProfile(); Array.getStatistics(profileValues, min, max, mean, stdDev); countMin = 0; countMax = 0; for(i=0;i<lengthOf(profileValues);i++){ if (profileValues[i]==0) { countMin = countMin+1;} if (profileValues[i]==max) { countMax = countMax+1;} } }</i>By measuring the number of 0 (countMin) and 255 (countMax) values you can calculate the thickness. Regards, Peter
Reply | Threaded
Open this post in threaded view
|

Re: How do I draw a line that has an origin coord but ends when it hits white (ie 255)?

Peter van Loon
In reply to this post by Nikolas Jorstad
Hi Nik,

I'm not sure if I understand your question well (a picture may help).

Maybe this code can help:
To draw a line based on a center coordinate and angle:
function makeLineC(centerX, centerY, length, angle) {
        angle = -angle * PI / 180; dX = cos(angle) * length / 2; dY = sin(angle) * length / 2;
        makeLine(centerX - dX, centerY - dY, centerX + dX, centerY + dY);
}
To draw a line based on an end coordinate and angle:
function makeLineE(centerX, centerY, length, angle) {
       angle = -angle * PI / 180; dX = cos(angle) * length / 2; dY = sin(angle) * length / 2;
        makeLine(centerX, centerY, centerX + dX, centerY + dY);
}

By measuring the black and white(255) pixels you can use this function:
function countMinMax(){
  profileValues=getProfile(); Array.getStatistics(profileValues, min, max, mean, stdDev);
  countMin = 0; countMax = 0;
  for(i=0;i<lengthOf(profileValues);i++){
  if (profileValues[i]==0) { countMin = countMin+1;}
  if (profileValues[i]==max) { countMax = countMax+1;}
  }
 }
By measuring the number of 0 (countMin) and 255 (countMax) values you can calculate the thickness.

Regards,
Peter