MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / smooth

Method smooth

ij/src/main/java/ij/plugin/Selection.java:424–444  ·  view source on GitHub ↗

Smooth the specified line, preserving the end points. Author: Eugene Katrukha

(int[] a, int n)

Source from the content-addressed store, hash-verified

422 Author: Eugene Katrukha
423 */
424 int[] smooth(int[] a, int n) {
425 float [] out = new float[n];
426 int i,j;
427 //no point in averaging 2 points
428 if(n<3)
429 return a;
430 //preserve end points
431 out[0]= a[0];
432 out[n-1] = a[n-1];
433 //average middle points
434 for (i=1; i<(n-1); i++) {
435 out[i]=0.0f;
436 for(j=(i-1);j<(i+2);j++){
437 out[i] += a[j];
438 }
439 out[i] /= 3.0f;
440 }
441 for (i=0; i<n; i++)
442 a[i] = (int)Math.round(out[i]);
443 return a;
444 }
445
446 /**
447 Smooth the specified line, preserving the end points.<br>

Callers 2

trimPolygonMethod · 0.95
trimFloatPolygonMethod · 0.95

Calls 1

roundMethod · 0.45

Tested by

no test coverage detected