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))); } }
switch (dataBuffer.getDataType()) { case DataBuffer.TYPE_BYTE: min_max = calcMinMax(storedValue, sm, ((DataBufferByte) dataBuffer).getData()); break; case DataBuffer.TYPE_USHORT: min_max = calcMinMax(storedValue, sm, ((DataBufferUShort) dataBuffer).getData()); break; case DataBuffer.TYPE_SHORT: min_max = calcMinMax(storedValue, sm, ((DataBufferShort) dataBuffer).getData()); break;
public LookupTable createLUT(int outBits) { LookupTable lut = combineModalityVOILUT(presentationLUT != null ? log2(presentationLUT.length()) : outBits); if (presentationLUT != null) { lut = lut.combine(presentationLUT.adjustOutBits(outBits)); } else if (inverse) lut.inverse(); return lut; }
Attributes imgAttrs = metadata.getAttributes(); StoredValue sv = StoredValue.valueOf(imgAttrs); LookupTableFactory lutParam = new LookupTableFactory(sv); DicomImageReadParam dParam = param instanceof DicomImageReadParam ? (DicomImageReadParam) param Attributes psAttrs = dParam.getPresentationState(); if (psAttrs != null) { lutParam.setModalityLUT(psAttrs); lutParam.setVOI( selectVOILUT(psAttrs, imgAttrs.getString(Tag.SOPInstanceUID), frameIndex+1), 0, 0, false); lutParam.setPresentationLUT(psAttrs); } else { Attributes sharedFctGroups = imgAttrs.getNestedDataset( Attributes frameFctGroups = imgAttrs.getNestedDataset( Tag.PerFrameFunctionalGroupsSequence, frameIndex); lutParam.setModalityLUT( selectFctGroup(imgAttrs, sharedFctGroups, frameFctGroups, Tag.PixelValueTransformationSequence)); if (dParam.getWindowWidth() != 0) { lutParam.setWindowCenter(dParam.getWindowCenter()); lutParam.setWindowWidth(dParam.getWindowWidth()); } else lutParam.setVOI( selectFctGroup(imgAttrs, sharedFctGroups, frameFctGroups,
private LookupTable createLUT(StoredValue inBits, Attributes attrs) { if (attrs == null) return null; return createLUT(inBits, attrs.getInts(Tag.LUTDescriptor), attrs.getSafeBytes(Tag.LUTData), attrs.bigEndian()); }
private byte[] lutData(Attributes ds, int[] desc, int dataTag, int segmTag) { int len = desc[0] == 0 ? 0x10000 : desc[0]; int bits = desc[2]; byte[] data = ds.getSafeBytes(dataTag); if (data == null) { int[] segm = ds.getInts(segmTag); if (segm == null) { throw new IllegalArgumentException("Missing LUT Data!"); } if (bits == 8) { throw new IllegalArgumentException( "Segmented LUT Data with LUT Descriptor: bits=8"); } data = new byte[len]; inflateSegmentedLut(segm, data); } else if (bits == 16 || data.length != len) { if (data.length != len << 1) lutLengthMismatch(data.length, len); int hilo = ds.bigEndian() ? 0 : 1; if (bits == 8) hilo = 1 - hilo; // padded high bits -> use low bits data = LookupTableFactory.halfLength(data, hilo); } return data; }
public void setModalityLUT(Attributes attrs) { rescaleIntercept = attrs.getFloat(Tag.RescaleIntercept, 0); rescaleSlope = attrs.getFloat(Tag.RescaleSlope, 1); modalityLUT = createLUT(storedValue, attrs.getNestedDataset(Tag.ModalityLUTSequence)); }
private byte[] lutData(Attributes ds, int[] desc, int dataTag, int segmTag) { int len = desc[0] == 0 ? 0x10000 : desc[0]; int bits = desc[2]; byte[] data = ds.getSafeBytes(dataTag); if (data == null) { int[] segm = ds.getInts(segmTag); if (segm == null) { throw new IllegalArgumentException("Missing LUT Data!"); } if (bits == 8) { throw new IllegalArgumentException( "Segmented LUT Data with LUT Descriptor: bits=8"); } data = new byte[len]; inflateSegmentedLut(segm, data); } else if (bits == 16 || data.length != len) { if (data.length != len << 1) lutLengthMismatch(data.length, len); int hilo = ds.bigEndian() ? 0 : 1; if (bits == 8) hilo = 1 - hilo; // padded high bits -> use low bits data = LookupTableFactory.halfLength(data, hilo); } return data; }
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 setModalityLUT(Attributes attrs) { rescaleIntercept = attrs.getFloat(Tag.RescaleIntercept, 0); rescaleSlope = attrs.getFloat(Tag.RescaleSlope, 1); modalityLUT = createLUT(storedValue, attrs.getNestedDataset(Tag.ModalityLUTSequence)); }
public LookupTable createLUT(int outBits) { LookupTable lut = combineModalityVOILUT(presentationLUT != null ? log2(presentationLUT.length()) : outBits); if (presentationLUT != null) { lut = lut.combine(presentationLUT.adjustOutBits(outBits)); } else if (inverse) lut.inverse(); return lut; }
data = halfLength(data, bigEndian ? 1 : 0);
switch (dataBuffer.getDataType()) { case DataBuffer.TYPE_BYTE: min_max = calcMinMax(storedValue, sm, ((DataBufferByte) dataBuffer).getData()); break; case DataBuffer.TYPE_USHORT: min_max = calcMinMax(storedValue, sm, ((DataBufferUShort) dataBuffer).getData()); break; case DataBuffer.TYPE_SHORT: min_max = calcMinMax(storedValue, sm, ((DataBufferShort) dataBuffer).getData()); break;
private LookupTable createLUT(StoredValue inBits, Attributes attrs) { if (attrs == null) return null; return createLUT(inBits, attrs.getInts(Tag.LUTDescriptor), attrs.getSafeBytes(Tag.LUTData), attrs.bigEndian()); }
data = halfLength(data, bigEndian ? 1 : 0);
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 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); }