[Insight-users] How to Decode MultiFrame DICOM Image by Using ITK

Jothybasu Selvaraj jothybasu at gmail.com
Wed Mar 7 04:51:44 EST 2012


Though it's not a vtk list,

vtkGDCmImageReader can handle it.

Jothy



On Wed, Mar 7, 2012 at 3:41 AM, Terran Wu <Terran.Wu at semt.com.cn> wrote:

> Hi All,
>
> I am currently write a application that reading and display DICOM image on
> IPAD2. Now I am able to read and decode DICOM files that contain only one
> frame, here is the code(using ITK LIB and object-c) that decode one frame
> DICOM file on IPAD:
>
> //assume that the size of image is 880*635
>
>     int imageWidth = 880;
>
>     int imageHeight = 635;
>
>
>
>     NSString *dicomPath = [[[[NSBundle mainBundle] resourcePath]
> stringByAppendingString:@"/"] stringByAppendingString:@"dicomfilename"];
>
>     const char *c_dicomPath = [dicomPath UTF8String];
>
>
>
>     typedef unsigned char InputPixelType;
>
>     const unsigned int InputDimension = 2;
>
>     typedef itk::Image< InputPixelType, InputDimension > InputImageType;
>
>
>
>     typedef itk::ImageSeriesReader< InputImageType > ReaderType;
>
>     ReaderType::Pointer reader = ReaderType::New();
>
>     reader->SetFileName(c_dicomPath);
>
>
>
>     typedef itk::GDCMImageIO ImageIOType;
>
>     ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
>
>
>
>     reader->SetImageIO(gdcmImageIO);
>
>
>
>     int frame_num = 1;
>
>     InputPixelType *imageBuf = new InputPixelType[imageHeight*imageWidth*3
> *frame_num];
>
>
>
>     try
>
>     {
>
>         reader->Update();
>
>         printf("image size in bytes = %d\n", gdcmImageIO->
> GetImageSizeInBytes());
>
>         printf("image size in pixel = %d\n", gdcmImageIO->
> GetImageSizeInPixels());
>
>         printf("image size in Components = %d\n", gdcmImageIO->
> GetImageSizeInComponents());
>
>         printf("pixel stride = %d\n", gdcmImageIO->GetPixelStride());
>
>         printf("Dimensions = %d\n", gdcmImageIO->GetNumberOfDimensions());
>
>         printf("file type = %d\n", gdcmImageIO->GetFileType());
>
>         std::cout << "file type = " << gdcmImageIO->GetFileTypeAsString
> (gdcmImageIO->GetFileType()) << std::endl;
>
>         std::cout << "Pixel type = " << gdcmImageIO->GetPixelTypeAsString
> (gdcmImageIO->GetPixelType()) << std::endl;
>
>         std::cout << "Byte order = " << gdcmImageIO->GetByteOrderAsString
> (gdcmImageIO->GetByteOrder()) << std::endl;
>
>         gdcmImageIO->GetPixelType();
>
>     }
>
>     catch (itk::ExceptionObject & e)
>
>     {
>
>         std::cerr << "exception in file reader " << std::endl; std::cerr<< e <<
> std::endl;
>
>         exit(EXIT_FAILURE);
>
>     }
>
>
>
>     //get dicom image
>
>     memset(imageBuf, 0, sizeof(InputPixelType)*imageHeight*imageWidth*3
> *frame_num);
>
>     gdcmImageIO->Read(imageBuf);//get decoded image data
>
>
>
>     CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
>
>     CGDataProviderRef provider = CGDataProviderCreateWithData(nil,
> imageBuf, imageWidth*imageHeight*3, nil);
>
>     CGImageRef imageRef = CGImageCreate(imageWidth,//width
>
>                                         imageHeight,//height
>
>                                         8,//size_t bitsPerComponent,
>
>                                         24,//size_t bitsPerPixel,
>
>                                         imageWidth*sizeof(InputPixelType)*
> 3,//size_t bytesPerRow,
>
>                                         colorspace,//CGColorSpaceRef
> space,
>
>                                         kCGBitmapByteOrderDefault,//CGBitmapInfo
> bitmapInfo,
>
>                                         provider,//CGDataProviderRef
> provider,
>
>                                         nil,//const CGFloat *decode,
>
>                                         NO,//bool shouldInterpolate,
>
>                                         kCGRenderingIntentDefault//CGColorRenderingIntent
> intent
>
>                                         );
>
>     UIImage *dicomImage = [[UIImage alloc] initWithCGImage:imageRef scale:
> 1.0 orientation:UIImageOrientationUp];//here is the decoded image
>
> But I don't know how to decode and read a DICOM file that has MultiFrame,
> and how to get the decoded image data to display them on IPAD screen?
>
> Can anybody help me on this issue?
>
>  Thank you very much!
>
> --
>
> Best Regards****
>
> Terran Wu****
>
> *Î׎Ì*
>
> *
> *
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


-- 
Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120307/81551a80/attachment.htm>


More information about the Insight-users mailing list