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; }
public void setVOI(Attributes img, int windowIndex, int voiLUTIndex, boolean preferWindow) { if (img == null) return; Attributes vLUT = img.getNestedDataset(Tag.VOILUTSequence, voiLUTIndex); if (preferWindow || vLUT == null) { float[] wcs = img.getFloats(Tag.WindowCenter); float[] wws = img.getFloats(Tag.WindowWidth); if (wcs != null && wcs.length != 0 && wws != null && wws.length != 0) { int index = windowIndex < Math.min(wcs.length, wws.length) ? windowIndex : 0; windowCenter = wcs[index]; windowWidth = wws[index]; return; } } if (vLUT != null) voiLUT = createLUT(modalityLUT != null ? new StoredValue.Unsigned(modalityLUT.outBits) : storedValue, vLUT); }
public void setPresentationLUT(Attributes attrs) { Attributes pLUT = attrs.getNestedDataset(Tag.PresentationLUTSequence); if (pLUT != null) { int[] desc = pLUT.getInts(Tag.LUTDescriptor); if (desc != null && desc.length == 3) { int len = desc[0] == 0 ? 0x10000 : desc[0]; presentationLUT = createLUT(new StoredValue.Unsigned(log2(len)), resetOffset(desc), pLUT.getSafeBytes(Tag.LUTData), pLUT.bigEndian()); } } else { String pShape = attrs.getString(Tag.PresentationLUTShape); inverse = (pShape != null ? "INVERSE".equals(pShape) : "MONOCHROME1".equals( attrs.getString(Tag.PhotometricInterpretation))); } }
public void setVOI(Attributes img, int windowIndex, int voiLUTIndex, boolean preferWindow) { if (img == null) return; Attributes vLUT = img.getNestedDataset(Tag.VOILUTSequence, voiLUTIndex); if (preferWindow || vLUT == null) { float[] wcs = img.getFloats(Tag.WindowCenter); float[] wws = img.getFloats(Tag.WindowWidth); if (wcs != null && wcs.length != 0 && wws != null && wws.length != 0) { int index = windowIndex < Math.min(wcs.length, wws.length) ? windowIndex : 0; windowCenter = wcs[index]; windowWidth = wws[index]; return; } } if (vLUT != null) voiLUT = createLUT(modalityLUT != null ? new StoredValue.Unsigned(modalityLUT.outBits) : storedValue, vLUT); }
public void setPresentationLUT(Attributes attrs) { Attributes pLUT = attrs.getNestedDataset(Tag.PresentationLUTSequence); if (pLUT != null) { int[] desc = pLUT.getInts(Tag.LUTDescriptor); if (desc != null && desc.length == 3) { int len = desc[0] == 0 ? 0x10000 : desc[0]; presentationLUT = createLUT(new StoredValue.Unsigned(log2(len)), resetOffset(desc), pLUT.getSafeBytes(Tag.LUTData), pLUT.bigEndian()); } } else { String pShape = attrs.getString(Tag.PresentationLUTShape); inverse = (pShape != null ? "INVERSE".equals(pShape) : "MONOCHROME1".equals( attrs.getString(Tag.PhotometricInterpretation))); } }
public static StoredValue valueOf(Attributes attrs) { int bitsStored = attrs.getInt(Tag.BitsStored, 0); if (bitsStored == 0) bitsStored = attrs.getInt(Tag.BitsAllocated, 8); return attrs.getInt(Tag.PixelRepresentation, 0) != 0 ? new Signed(bitsStored) : new Unsigned(bitsStored); } }
public static StoredValue valueOf(Attributes attrs) { int bitsStored = attrs.getInt(Tag.BitsStored, 0); if (bitsStored == 0) bitsStored = attrs.getInt(Tag.BitsAllocated, 8); return attrs.getInt(Tag.PixelRepresentation, 0) != 0 ? new Signed(bitsStored) : new Unsigned(bitsStored); } }