public LutParameters getLutParameters(TagReadable tagable, boolean pixelPadding, LookupTableCV mLUTSeq,
boolean inversePaddingMLUT) {
Integer paddingValue = getPaddingValue();
boolean isSigned = isPixelRepresentationSigned();
int bitsStored = getBitsStored();
double intercept = getRescaleIntercept(tagable);
double slope = getRescaleSlope(tagable);
if (bitsStored > 16
|| (MathUtil.isEqual(slope, 1.0) && MathUtil.isEqualToZero(intercept) && paddingValue == null)) {
return null;
}
Integer paddingLimit = getPaddingLimit();
boolean outputSigned = false;
int bitsOutputLut;
if (mLUTSeq == null) {
double minValue = super.getMinValue(tagable, pixelPadding) * slope + intercept;
double maxValue = super.getMaxValue(tagable, pixelPadding) * slope + intercept;
bitsOutputLut = Integer.SIZE - Integer.numberOfLeadingZeros((int) Math.round(maxValue - minValue));
outputSigned = minValue < 0 ? true : isSigned;
if (outputSigned && bitsOutputLut <= 8) {
bitsOutputLut = 9;
}
} else {
bitsOutputLut = mLUTSeq.getDataType() == DataBuffer.TYPE_BYTE ? 8 : 16;
}
return new LutParameters(intercept, slope, pixelPadding, paddingValue, paddingLimit, bitsStored, isSigned,
outputSigned, bitsOutputLut, inversePaddingMLUT);
}