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

Method getMedian

ij/src/main/java/ij/plugin/Binner.java:196–224  ·  view source on GitHub ↗
(ImageProcessor ip, int x, int y)

Source from the content-addressed store, hash-verified

194 }
195
196 private float getMedian(ImageProcessor ip, int x, int y) {
197 int shrinksize = xshrink*yshrink;
198 float[] pixels = new float[shrinksize];
199 int p=0;
200 // fill pixels within local neighborhood
201 for (int y2=0; y2<yshrink; y2++) {
202 for (int x2=0; x2<xshrink; x2++)
203 pixels[p++] = ip.getf(x*xshrink+x2, y*yshrink+y2);
204 }
205 // find median value
206 int halfsize=shrinksize/2;
207 for (int i=0; i<=halfsize; i++) {
208 float max=0f;
209 int mj=0;
210 for (int j=0; j<shrinksize; j++) {
211 if (pixels[j]>max) {
212 max = pixels[j];
213 mj = j;
214 }
215 }
216 pixels[mj] = 0;
217 }
218 float max = -Float.MAX_VALUE;
219 for (int j=0; j<shrinksize; j++) {
220 if (pixels[j]>max)
221 max = pixels[j];
222 }
223 return max;
224 }
225
226 private float getMin(ImageProcessor ip, int x, int y) {
227 float min = Float.MAX_VALUE;

Callers 1

shrinkMethod · 0.95

Calls 1

getfMethod · 0.45

Tested by

no test coverage detected