【问题标题】:How to Extract Pixel data from DIcom image to view it in a n iPhone如何从 DIcom 图像中提取像素数据以在 iPhone 中查看
【发布时间】:2013-02-11 21:37:19
【问题描述】:

我一直在使用以下代码读取使用 DCMTK 框架的 dicom 图像以将其显示在 UIImage 视图中。

NSString *dcmFilename   = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"dcm"];
 const void* buffer = dcmFilename;


// Set the dimensions of the current context
size_t width = 250; // set manually, but correct
size_t height = 252;

// 1 byte per component
size_t bitsPerComponent = 8;





bitsPerComponent *= 2; // short = 2 byte

size_t bitsPerPixel, bytesPerRow;
CGColorSpaceRef colorSpace;
CGBitmapInfo bitmapInfo;
CGDataProviderRef theDataProvider;
CFDataRef theDataReference;
bool shouldInterpolate = NO;
CGColorRenderingIntent theIntent;


bitsPerPixel = bitsPerComponent * 1; // because of grayscale image
colorSpace = CGColorSpaceCreateDeviceGray();
bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrder32Big;

// cg data provider to build the cg image
const UInt8* rawData = static_cast<const UInt8*>(buffer);

// For some reason initiating a CGImage uses BITS per pixel, so we need to divide by 8 to get BYTES
// per pixel
bytesPerRow = (bitsPerPixel/8) * width;

theDataReference = CFDataCreate(NULL,
                                rawData,
                                (bytesPerRow*height));

theDataProvider = CGDataProviderCreateWithCFData(theDataReference);





// Finally create the image reference
CGImageRef theImageRef = CGImageCreate(width,
                                       height,
                                       bitsPerComponent,
                                       bitsPerPixel,
                                       bytesPerRow,
                                       colorSpace,
                                       bitmapInfo,
                                       theDataProvider,
                                       nil,
                                       shouldInterpolate,
                                       theIntent);


// Construct an output image
UIImage *myImage = [UIImage imageWithCGImage:(theImageRef)];
NSLog(@"image-- %@", myImage);
patientImageView.image = myImage;

我得到这样的输出。我在处理 dcm 图像时哪里出错了???

【问题讨论】:

标签: iphone ios ipad image-processing dicom


【解决方案1】:

我的猜测是图像被压缩了。默认情况下,DCMTK 仅支持某些形式的压缩。例如,默认情况下不支持 JPEG2000。检查图像的传输语法,看它是否是 DCMTK 支持的压缩格式。有关传输语法的更多信息,请参阅here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多