I am stuck on one problem and I need your advice on what I am doing wrong.
I want to read a segmentation mask from a DICOM SEG file. The mask is stored as a binary multi-layered image in PixelData tag. I can either access the tag by creating a DcmFileFormat object and reading the contents of the tag, or I can load this file as DicomImage and use its methods. My problem is, however, that I am not sure, how to correctly store the mask data in an aray. The segmentation mask is a binary image, BitsAllocated tag has value 1. When I read the image, I get a result in form of a void* pointer. Which variable type do I have to convert this pointer to, if I have a binary array?
Here is my code:
Code: Select all
DicomImage* dicomImage = new DicomImage( filename.c_str() );
unsigned long dataSize = dicomImage->getOutputDataSize();
const void* pData = dicomImage->getOutputData(1, dataSize );
void * buffer = new unsigned char[dataSize];
if( !dicomImage->getOutputData(buffer, dicomImage->getOutputDataSize(), dicomImage->getDepth() ) ){
std::cerr << "DicomSRReaderWrapper::readDicomImage Error: dicomImage->getOutputData() was not successful!" << std::endl;
}
for( int i = 0; i < dataSize; ++i ) {
if( *((unsigned char*)(buffer)+i) != 0 )
std::cout << *((unsigned char*)(buffer)+i) << std::endl;
}
delete[] buffer;