[vtkusers] A question about DICOM slice number
Dov Grobgeld
dov.grobgeld at weizmann.ac.il
Sat Apr 9 20:21:18 EDT 2005
This answer may be somewhat out of topic since I am not familiar with
the VTK Dicom image reading routines...
As I genaral dicom library I would recommend using the DCMTK library.
For a long time I was using my own library for reading Dicom, but
lately I have fountd that DCMTK answers all my needs. See:
http://dicom.offis.de/dcmtk.php.en
It is easy integrating this library with VTK by reading the data
with the library and then inserting it into VTK by the creation
of a vtkImageData class into which the DCMDTK data is inserted.
It looks something like:
for (int slice_idx=0; slice_idx<num_slices; slice_idx++) {
long int val_long;
string filename = filename_list[slice_idx];
DcmFileFormat dicom_img;
OFCondition status = dicom_img.loadFile(filename.c_str());
if (!status.good())
die("Failed reading %s\n", filename.c_str());
DcmDataset *ds = dicom_img.getDataset();
ds->findAndGetLongInt(DCM_Columns, val_long);
width = val_long;
ds->findAndGetLongInt(DCM_Rows, val_long);
height = val_long;
// Allocate the data the first time when we know the
// width and height of the data.
if (slice_idx==0) {
image_data->SetDimensions(width, height, num_slices);
image_data->SetScalarType(VTK_UNSIGNED_SHORT);
image_data->AllocateScalars();
vtk_buf = (unsigned short*)image_data->GetScalarPointer();
}
const unsigned short *dicom_buf;
ds->findAndGetUint16Array(DCM_PixelData, dicom_buf);
unsigned short *slice_buf = vtk_buf + slice_idx * width * height;
// Copy the data from DcmTK to VTK
memcpy(slice_buf, dicom_buf, 2 * width * height);
}
(Note that the example is hardcoded for Gray 16-bit dicom images,
but you get the idea...)
Another option is starting from scratch using my Gimp DICOM plugin,
the source of which may be seen at:
http://cvs.gimp.org/viewcvs/gimp/plug-ins/common/dicom.c?rev=1.8&view=markup
It would be easy to add recognition of the image sequence tag in the
load_image function.
Regards,
Dov
On Sat, Apr 09, 2005 at 09:51:09PM +0800, fengfenghsy wrote:
> Hello, everyone,
> I am dealing with a list of DICOM images, and if I use special DICOM image reader software to read one of these DICOM images, the software could read out a general Image information called Instance Number, which indicate the sequence of this list of DICOM image. No matter how you change each image name of the DICOM image, the Instance Number is invarable since the DICOM image generated from the making DICOM equipments.
> My problem is how could I read the Instance Number in VTK. Thanks a lot.
>
> ????????????????fengfenghsy
> ????????????????fengfenghsy at 163.com
> ????????????????????2005-04-09
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list