如何使用imebra将RAW图像转换为DICOM图像? [英] How can I convert RAW image to DICOM image using imebra?

查看:446
本文介绍了如何使用imebra将RAW图像转换为DICOM图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是imebra的新手,想将原始图像转换为DICOM图像。我已经将imebra库编译到我的虚拟机(ubuntu 16.04)中,并按照网站上的教程进行操作。我发现它们没有显示如何将原始图像转换为DICOM图像。

I am new to imebra and want to convert raw image to DICOM image. I have complied the imebra library to my virtual machine (ubuntu 16.04), and followed the tutorial from the website. I found that they do not show how to convert raw image to DICOM image.

有人可以帮助我或告诉我转换过程吗?

Can anyone help me out or tell me the process of converting?

#include <imebra/imebra.h>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <memory>

using namespace std;
int main()
{   

    //creat read stream  
    using namespace puntoexe;
    ptr<stream> readStream(new stream);
    readStream->openFile(NSStringToStringW(imagePath), std::ios::in);


    // Create dataset
    streamReader reader =new streamReader(readStream);
    imebra::dataSet testDataSet = imebra::codecs::codecFactory::getCodecFactory()->load(reader);

    // Set Tags
    testSet->setString(0x0010,0,0x0010,0,"testSrt0");
    testSet->setString(0x0010,0,0x0010,1,"testSrt1");

    // Load jpeg
    std::unique_ptr<imebra::DataSet> testSet(imebra::CodeFcactory::load("/home/lixingyu/care.raw"));

    // Save as DICOM
    imebra::CodecFactory::save(testSet, "/home/lixingyu/care.dcm", imebra::codecType_t::dicom);
    */
    return 0;
}

我不确定上面的代码。这个过程有什么问题吗?
当我尝试以下代码时:使用命名空间puntoexe; 发生错误:

I am not quiet sure about the code above. Is there anything wrong with this process?? When I tried this code: using namespace puntoexe; an error occurred:


错误:'puntoexe'不是名称空间名称,并且 ptr也是错误。

"error: ‘puntoexe’ is not a namespace-name" and "ptr" was also fault.


推荐答案

您使用的是旧版本的Imebra。

You are using a rather old version of Imebra.

使用Imebra 4和5,您可以:

With Imebra 4 and 5 you can:


  • 创建图像对象

  • 用原始数据填充图像对象

  • 创建DICOM数据集

  • 将图像添加到DICOM数据集中

  • 填充所有必要的DICOM标签(例如,sop类,实例,患者姓名等)

  • 保存DICOM数据集

  • create an Image object
  • fill the image object with raw data
  • create a DICOM dataset
  • add the image to the DICOM dataset
  • fill all the necessary DICOM tags (e.g. sop class, instance, patient name, etc)
  • save the DICOM dataset

在代码中,使用Imebra5:

In code, with Imebra5:

include <imebra/imebra.h>

// Create an image 500 pixels wide, 400 pixels height,
// each sample is a 16 bit unsigned value, the colorspace
// is monochrome_2, the higher bit used is 15
imebra::MutableImage image(500, 400, imebra::bitDepth_t::depthU16, "MONOCHROME2", 15);

// We fill the image with data
{
    // We use a writing data handler to write into the image.
    // The data is committed into the image only when the writing
    // data handler goes out of scope.
    imebra::WritingDataHandlerNumeric writeIntoImage(image.getWritingDataHandler());

    for(size_t y(0); y != 400; ++y)
    {
        for(size_t x(0); x != 500; ++x)
        {
            // This method is slow, you can access directly the memory
            // with writeIntoImage.assign() or getMemory()
            writeIntoImage.setUnsignedLong(y * 500 + x, pixelValue);
        }
    }
}

// We specify the transfer syntax and the charset
imebra::charsetsList_t charsets;
charsets.push_back("ISO 2022 IR 6");
imebra::MutableDataSet dataSet("1.2.840.10008.1.2.1", charsets);

// Add the image to the dataset
dataSet.setImage(0, image,  imebra::imageQuality_t::veryHigh);

// Set the patient name
dataSet.setUnicodePatientName(imebra::TagId(imebra::tagId_t::PatientName_0010_0010), imebra::UnicodePatientName(L"Patient^Name", "", ""));

// Save to a file
imebra::CodecFactory::save(dataSet, "dicomFile.dcm", imebra::codecType_t::dicom);

Imebra 4代码相似,但是函数返回的是指针而不是对象。

Imebra 4 code is similar but the functions returned pointers instead of objects.

免责声明:我是Imebra的作者

Disclaimer: I'm the author of Imebra

这篇关于如何使用imebra将RAW图像转换为DICOM图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆