Hi

I am getting a black and white image after applying the default window
level to a 16 bit CT image. I'm using JAI APIs for window leveling....

Here is the code:
//maxInputRange =65535 for 16 bit CT
//maxOutputRange=255 -common for all the images
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));

}

Please give me a solution..I am totally halted here

Thanks
Muttus