@@ -1100,8 +1100,10 @@ private void process(int op, double value) {
11001100
11011101 /**
11021102 * Returns an array containing the pixel values along the
1103- * line starting at (x1,y1) and ending at (x2,y2). Pixel
1104- * values are sampled using getInterpolatedValue(double,double)
1103+ * line starting at (x1,y1) and ending at (x2,y2). The end
1104+ * point is included, and the interval is chosen such that
1105+ * the distance between successive points is close to 1.0 pixel.
1106+ * Pixel values are sampled using getInterpolatedValue(double,double)
11051107 * if interpolation is enabled or getPixelValue(int,int) if it is not.
11061108 * For byte and short images, returns calibrated values if a
11071109 * calibration table has been set using setCalibrationTable().
@@ -1114,20 +1116,20 @@ private void process(int op, double value) {
11141116 public double [] getLine (double x1 , double y1 , double x2 , double y2 ) {
11151117 double dx = x2 -x1 ;
11161118 double dy = y2 -y1 ;
1117- int n = (int )Math .round (Math .sqrt (dx *dx + dy *dy )) + 1 ;
1119+ int n = (int )Math .round (Math .sqrt (dx *dx + dy *dy ));
11181120 double xinc = n >0 ?dx /n :0 ;
11191121 double yinc = n >0 ?dy /n :0 ;
1120- double [] data = new double [n ];
1122+ double [] data = new double [n + 1 ];
11211123 double rx = x1 ;
11221124 double ry = y1 ;
11231125 if (interpolate ) {
1124- for (int i =0 ; i <n ; i ++) {
1126+ for (int i =0 ; i <= n ; i ++) {
11251127 data [i ] = getInterpolatedValue (rx , ry );
11261128 rx += xinc ;
11271129 ry += yinc ;
11281130 }
11291131 } else {
1130- for (int i =0 ; i <n ; i ++) {
1132+ for (int i =0 ; i <= n ; i ++) {
11311133 data [i ] = getPixelValue ((int )Math .round (rx ), (int )Math .round (ry ));
11321134 rx += xinc ;
11331135 ry += yinc ;
0 commit comments