How to show legally DICOM 16 unsigned integer on the device are supporting 8 bit unsigned integer?

前端 未结 2 527
时光说笑
时光说笑 2021-01-22 15:26

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

2条回答
  •  走了就别回头了
    2021-01-22 16:25

    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.

提交回复
热议问题