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;
}
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:
"error: ‘puntoexe’ is not a namespace-name" and "ptr" was also fault.
You are using a rather old version of Imebra.
With Imebra 4 and 5 you can:
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 code is similar but the functions returned pointers instead of objects.
Disclaimer: I'm the author of Imebra