DCMTK读取多帧图像,不需要全部读取像素数据,即可处理数据

 

Howto: Access multi-frame images without loading complete pixel data

Here's an example that shows how to access the individual frames of a large multi-frame image (for visualization purposes) without loading the complete pixel data into main memory.

The parameter fcount in the DicomImage constructor specifies that initially only the first 10 frames are processed. Multiple calls of processNextFrames() give access to the subsequent frames.

See API documentation for details.

Source Code

 

#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmimgle/dcmimage.h"
 
int main(int argc, char *argv[])
{
    OFLog::configure(OFLogger::INFO_LOG_LEVEL);
 
    DicomImage *image = new DicomImage("mf_image.dcm", CIF_UsePartialAccessToPixelData, 0, 10 /* fcount */); 
 
    if (image->getStatus() == EIS_Normal)
    {
        do {
            DCMIMGLE_INFO("processing frame " << image->getFirstFrame() + 1 << " to "
                                              << image->getFirstFrame() + image->getFrameCount());
        } while (image->processNextFrames());
    }
 
    delete image;
 
    return 0;
}

 Note

This example requires DCMTK 3.5.5 (20091222) or newer.

 

DicomImage::DicomImage(const char *  filename,
const unsigned long  flags = 0,
const unsigned long  fstart = 0,
const unsigned long  fcount = 0 
)

constructor, open a DICOM file.

Opens specified file and reads image related data, creates internal representation of image data. Use getStatus() to obtain detailed information about any errors.

Parameters:
filenamethe DICOM file
flagsconfiguration flags (see diutils.h, CIF_MayDetachPixelData is set automatically)
fstartfirst frame to be processed (optional, 0 = 1st frame), all subsequent use of parameters labeled 'frame' in this class refers to this start frame.
fcountnumber of frames (optional, 0 = all frames)

 

int DicomImage::processNextFrames (const unsigned long  fcount = 0 )[inline]

process next couple of frames.

If the image object has been created with less than the number of frames stored in the DICOM image, this function allows for accessing the subsequent frames. Multiple calls to this function allow for successively processing all frames stored in the file or dataset. See parameters 'fstart' and 'fcount' of the constructor for how to initially create an instance of this class. NB: Only "original" images can be processed in this way, i.e. images that were created by one of the above constructors. Images that were created by one of the createXXX() methods can not be processed since they are derived from original image data in a certain way, e.g. scaled.

Parameters:
fcountnumber of frames to be processed (0 = same number as before)
Returns:
status, true if successful, false otherwise

------------------------------------------------------------------

柳北风儿

http://qimo601.iteye.com

转载: http://support.dcmtk.org/wiki/dcmtk/howto/multiframe
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值