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

Method interpolate

ij/src/main/java/ij/plugin/LutLoader.java:281–300  ·  view source on GitHub ↗
(byte[] reds, byte[] greens, byte[] blues, int nColors)

Source from the content-addressed store, hash-verified

279 }
280
281 void interpolate(byte[] reds, byte[] greens, byte[] blues, int nColors) {
282 byte[] r = new byte[nColors];
283 byte[] g = new byte[nColors];
284 byte[] b = new byte[nColors];
285 System.arraycopy(reds, 0, r, 0, nColors);
286 System.arraycopy(greens, 0, g, 0, nColors);
287 System.arraycopy(blues, 0, b, 0, nColors);
288 double scale = nColors/256.0;
289 int i1, i2;
290 double fraction;
291 for (int i=0; i<256; i++) {
292 i1 = (int)(i*scale);
293 i2 = i1+1;
294 if (i2==nColors) i2 = nColors-1;
295 fraction = i*scale - i1;
296 reds[i] = (byte)((1.0-fraction)*(r[i1]&255) + fraction*(r[i2]&255));
297 greens[i] = (byte)((1.0-fraction)*(g[i1]&255) + fraction*(g[i2]&255));
298 blues[i] = (byte)((1.0-fraction)*(b[i1]&255) + fraction*(b[i2]&255));
299 }
300 }
301
302 /** Opens a LUT and returns it as a LUT object. */
303 public static LUT openLut(String pathOrURL) {

Callers 2

getBuiltInLutMethod · 0.95
openBinaryLutMethod · 0.95

Calls 1

arraycopyMethod · 0.45

Tested by

no test coverage detected