read all the dicom files in a directory?
Moderator: Moderator Team
read all the dicom files in a directory?
Does DCMTK provide some method to read all the dicom files under the same directory and write into one file? Thank you.
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
read multiple dicom files in the dir and write to one file
Maybe I didn't express my idea clearly in the previous question. Now I have several hundred of dicom files under a directory, those files are randomly named. I need to read those randomly named dicom files into one file with only pixel data in order to create a 3d volume of raw image. This 3d volume are saved in an array that reads in the pixel data of each dicom file slice by slice. I'm not sure whether it could be done with DCMTK? Thank you.
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Alternatively, you could write a little program that performs this task (load DICOM file, extract pixel data, append to output file). I guess that "qs5d" would also like to sort the individual images before creating the image volume.
Btw, I could also imagine that some of the 3D toolkits for the visualization of medical images provide such functionality.
Btw, I could also imagine that some of the 3D toolkits for the visualization of medical images provide such functionality.
Hi,Jörg Riesmeier wrote:Alternatively, you could write a little program that performs this task (load DICOM file, extract pixel data, append to output file).
This is exactly what I am trying to do, I started from the example in the DCMTK documentation and have written the following code:
Code: Select all
FILE *stream;
int main()
{
int list[65536]; //image is 256*256
DicomImage *image =new DicomImage("test.dcm");
if (image != NULL)
{
if (image->getStatus() == EIS_Normal)
{
if (image->isMonochrome())
{
image->setMinMaxWindow();
Uint8 *pixelData = (Uint8 *)(image->getOutputData(8 /* bits */));
if (pixelData != NULL)
{ /* do something useful with the pixel data */
fopen_s(&stream, "test.raw", "wb" );
for (int i = 0; i < 65536; i++)
{ list[i]=pixelData[i];
fwrite( list, sizeof( int ), 65536, stream );
}
}fclose(stream);
}
} else
cerr << "Error: cannot load DICOM image (" << DicomImage::getString(image->getStatus()) << ")" << endl;
}
delete image;
}
I'm sorry if the answer sounds easy to you, but I'm quite new to this kind of things.
Thank you.
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Who is online
Users browsing this forum: Google [Bot] and 1 guest