public double pixel2mLUT(Number pixelValue, TagReadable tagable, boolean pixelPadding) { if (pixelValue != null) { LookupTableCV lookup = getModalityLookup(tagable, pixelPadding); if (lookup != null) { int val = pixelValue.intValue(); if (val >= lookup.getOffset() && val < lookup.getOffset() + lookup.getNumEntries()) { return lookup.lookup(0, val); } } return pixelValue.doubleValue(); } return 0; }
public static PresetWindowLevel buildPresetFromLutData(LookupTableCV voiLUTsData, DicomImageElement image, TagReadable tagable, boolean pixelPadding, String explanation) { if (voiLUTsData == null || explanation == null) { return null; } Object inLut; if (voiLUTsData.getDataType() == DataBuffer.TYPE_BYTE) { inLut = voiLUTsData.getByteData(0); } else if (voiLUTsData.getDataType() <= DataBuffer.TYPE_SHORT) { inLut = voiLUTsData.getShortData(0); } else { return null; } int minValueLookup = voiLUTsData.getOffset(); int maxValueLookup = voiLUTsData.getOffset() + Array.getLength(inLut) - 1; minValueLookup = Math.min(minValueLookup, maxValueLookup); maxValueLookup = Math.max(minValueLookup, maxValueLookup); int minAllocatedValue = image.getMinAllocatedValue(tagable, pixelPadding); if (minValueLookup < minAllocatedValue) { minValueLookup = minAllocatedValue; } int maxAllocatedValue = image.getMaxAllocatedValue(tagable, pixelPadding); if (maxValueLookup > maxAllocatedValue) { maxValueLookup = maxAllocatedValue; } double fullDynamicWidth = (double) maxValueLookup - minValueLookup; double fullDynamicCenter = minValueLookup + fullDynamicWidth / 2f; LutShape newLutShape = new LutShape(voiLUTsData, explanation); return new PresetWindowLevel(newLutShape.toString(), fullDynamicWidth, fullDynamicCenter, newLutShape); }
if (mLUTSeq != null) { if (!pixelPadding || paddingValue == null) { if (super.getMinValue(tagable, false) >= mLUTSeq.getOffset() && super.getMaxValue(tagable, false) < mLUTSeq.getOffset() + mLUTSeq.getNumEntries()) { return mLUTSeq; } else if (prModLut == null) { byte[] data = mLUTSeq.getByteData(0); if (data != null) { modalityLookup = new LookupTableCV(data, mLUTSeq.getOffset(0)); modalityLookup = new LookupTableCV(data, mLUTSeq.getOffset(0), mLUTSeq.getData() instanceof DataBufferUShort);