Hai Everybody


In my viewer when ever i open a 12-16 bit image. when the image load on
to viewer i apply the default window width window level. But it does
not apply properly. I get a blur image in the viewer. I have applied
the same formula which was mentioned in the IOD 04v06_03 C.11.2.1.2
that was also not working. The formular which we apply are


int maxPixelValue = (samplesPerPixel * 8) - 1;
maxInputRange = (int) (Math.pow(2, maxPix) - 1);
int maxOutputRange=255;
LookupTableJAI currentLUT = createLookupTable(maxInputRange,
maxOutputRange, window, level);

RenderedImage destination = JAI.create("lookup", source, currentLUT);

ParameterBlock pb = new ParameterBlock();
pb.addSource(destination);
pb.add(DataBuffer.TYPE_BYTE);
destination = JAI.create("format", pb, null);

//creates the lookuptable
public static LookupTableJAI createLookupTable(int maxInputRange,
int maxOutputRange, int window, int level) {

int minOutputRange = 0;
int midWindow = (int) (window / 2);
int windowStart = level - midWindow;
int windowEnd = level + midWindow;

if (windowStart <= 0) {
windowStart = 0;
}

if (windowStart > maxInputRange) {
windowStart = maxInputRange;
}

if (windowEnd < 0) {
windowEnd = 0;
}

if (windowEnd > maxInputRange) {
windowEnd = maxInputRange;
}

byte[] lut = new byte[maxInputRange + 1];
double windowMappingRatio = ((maxOutputRange - minOutputRange)
/ (double) (window));
for (int i = 0; i < Math.min(windowStart, maxInputRange); i++) {
lut[i] = (byte) minOutputRange;
}

for (int i = windowStart; i < Math.min(windowEnd,
maxInputRange); i++) {
lut[i] = (byte) ((i - windowStart) * windowMappingRatio);
}

for (int i = windowEnd; i < maxInputRange; i++) {
lut[i] = (byte) maxOutputRange;
}

return (new LookupTableJAI(lut));
}

Thanks in advance

With regards
DICOM_TESTER