I\'m working on a Medical app on iOS. The iOS devices just support GL_UNSIGNED_BYTE with GL_LUMINANCE or generally just support 8 bit per component. Now I have some grayscale im
You MUST convert these values in order to show them applying a Window Level.
Grayscale Dicom images do usually have two Data Elements (Dicom fields) containing the values WC (Window Center, Data Element: 0028,1050) and WL (Window Level, Data Element: 0028,1051). These values define the linear equation necessary to display the information contained in the image.
You can find a more detailed description about the concept of Window Level here.
I tried it by dividing each pixel by a value (max value in the matrix or brightest / 256), then each pixel became an 8 bit value. And it gave same result when I apply pseudo equation mentioned in https://www.dabsoft.ch/dicom/3/C.11.2.1.2/.
const void *bytes = [data bytes];
NSMutableData* ary = [[NSMutableData alloc] init];
int maxValue = 4087/256; //its a dummy value, use your max value in image instead of 4087
for (NSUInteger i = 0; i < [data length]; i += sizeof(int16_t)) {
UInt16 elem = OSReadLittleInt16(bytes, i);
UInt8 temp = round(elem/maxValue);
[ary appendBytes:&temp length:sizeof(UInt8)];
}
Use 'ary' to make your image.