@Override public LookupTable adjustOutBits(int outBits) { int diff = outBits - this.outBits; if (diff != 0) { byte[] lut = this.lut; if (outBits > 8) { short[] ss = new short[lut.length]; for (int i = 0; i < lut.length; i++) ss[i] = (short) ((lut[i] & 0xff) << diff); return new ShortLookupTable(inBits, outBits, offset, ss); } if (diff < 0) { diff = -diff; for (int i = 0; i < lut.length; i++) lut[i] = (byte) ((lut[i] & 0xff) >> diff); } else for (int i = 0; i < lut.length; i++) lut[i] <<= diff; this.outBits = outBits; } return this; }
@Override public LookupTable adjustOutBits(int outBits) { int diff = outBits - this.outBits; if (diff != 0) { byte[] lut = this.lut; if (outBits > 8) { short[] ss = new short[lut.length]; for (int i = 0; i < lut.length; i++) ss[i] = (short) ((lut[i] & 0xff) << diff); return new ShortLookupTable(inBits, outBits, offset, ss); } if (diff < 0) { diff = -diff; for (int i = 0; i < lut.length; i++) lut[i] = (byte) ((lut[i] & 0xff) >> diff); } else for (int i = 0; i < lut.length; i++) lut[i] <<= diff; this.outBits = outBits; } return this; }
@Override public LookupTable combine(LookupTable other) { byte[] lut = this.lut; if (other.outBits > 8) { short[] ss = new short[lut.length]; other.lookup(lut, 0, ss, 0, lut.length); return new ShortLookupTable(inBits, other.outBits, offset, ss); } other.lookup(lut, 0, lut, 0, lut.length); this.outBits = other.outBits; return this; }
@Override public LookupTable combine(LookupTable other) { byte[] lut = this.lut; if (other.outBits > 8) { short[] ss = new short[lut.length]; other.lookup(lut, 0, ss, 0, lut.length); return new ShortLookupTable(inBits, other.outBits, offset, ss); } other.lookup(lut, 0, lut, 0, lut.length); this.outBits = other.outBits; return this; }
private LookupTable combineModalityVOILUT(int outBits) { float m = rescaleSlope; float b = rescaleIntercept; LookupTable modalityLUT = this.modalityLUT; LookupTable lut = this.voiLUT; if (lut == null) { float c = windowCenter; float w = windowWidth; if (w == 0 && modalityLUT != null) return modalityLUT.adjustOutBits(outBits); int size, offset; StoredValue inBits = modalityLUT != null ? new StoredValue.Unsigned(modalityLUT.outBits) : storedValue; if (w != 0) { size = Math.max(2,Math.abs(Math.round(w/m))); offset = Math.round((c-b)/m) - size/2; } else { offset = inBits.minValue(); size = inBits.maxValue() - inBits.minValue() + 1; } lut = outBits > 8 ? new ShortLookupTable(inBits, outBits, offset, size, m < 0) : new ByteLookupTable(inBits, outBits, offset, size, m < 0); } else { //TODO consider m+b lut = lut.adjustOutBits(outBits); } return modalityLUT != null ? modalityLUT.combine(lut) : lut; }
private LookupTable combineModalityVOILUT(int outBits) { float m = rescaleSlope; float b = rescaleIntercept; LookupTable modalityLUT = this.modalityLUT; LookupTable lut = this.voiLUT; if (lut == null) { float c = windowCenter; float w = windowWidth; if (w == 0 && modalityLUT != null) return modalityLUT.adjustOutBits(outBits); int size, offset; StoredValue inBits = modalityLUT != null ? new StoredValue.Unsigned(modalityLUT.outBits) : storedValue; if (w != 0) { size = Math.max(2,Math.abs(Math.round(w/m))); offset = Math.round((c-b)/m) - size/2; } else { offset = inBits.minValue(); size = inBits.maxValue() - inBits.minValue() + 1; } lut = outBits > 8 ? new ShortLookupTable(inBits, outBits, offset, size, m < 0) : new ByteLookupTable(inBits, outBits, offset, size, m < 0); } else { //TODO consider m+b lut = lut.adjustOutBits(outBits); } return modalityLUT != null ? modalityLUT.combine(lut) : lut; }
ss[i] = (short) ByteUtils.bytesToShortLE(data, i << 1); return new ShortLookupTable(inBits, outBits, offset, ss);
ss[i] = (short) ByteUtils.bytesToShortLE(data, i << 1); return new ShortLookupTable(inBits, outBits, offset, ss);