[vtkusers] Please help! How can I store all the images from a dicom file?
gurugurupalm
gurugurupalm at yahoo.com.tw
Thu Oct 13 11:31:44 EDT 2005
Dear VTK user:
I am using vtk 4.4 to read in a Dicom file and try
to show the images to a MFC project.
Will the following code store all the images from the
Dicom file I just read?
dcm_page=dicom_page.m_csPath;//get the dicom file
path location
reader = vtkDICOMImageReader::New();
viewer = vtkImageViewer2::New();
reader->SetFileName(dcm_page);
//check how many images in this dicom file
int number_of_frames = 1;
if (m_FileAttributes.GetSize() > 0)
{
for (int i=0;i<m_FileAttributes.GetSize();i++)
{
CString cts;
cts = m_FileAttributes[i].Left(9);
if (cts == "0028,0008")
{
for (int j = 0; j <
m_FileAttributes[i].GetLength();j++)
if (m_FileAttributes[i][j] == '[')
{
cts.Empty();
j++;
while (m_FileAttributes[i][j] != ',')
{
cts += m_FileAttributes[i][j];
j++;
}
number_of_frames = _ttoi(cts);
break;
}
}
}
}
//begin to put all the images to the list , where
std::list<vtkImageActor *>;
for(int i=0;i<=number_of_frames;i++)
{
viewer->SetInput(reader->GetOutput());
lst.push_back(viewer->GetImageActor());
reader->Update();
}
reader->Delete();
Because when I try to display the image (say the first
one, then second one, ...), they all look the same.
-----------------------------------------------
renChild->SetViewport(0, 0.0, 1.0, 1.0);
vtkImageActor *a = pDoc->GetDCMImage(15);//show a
particulr image from the dicom file
renChild->GetProps()->RemoveAllItems();
renChild->AddActor(a);
renChild->GetActiveCamera()->SetViewUp (0, 1, 0);
renChild->GetActiveCamera()->SetPosition (0, 0, 1);
renChild->GetActiveCamera()->SetFocalPoint (0, 0,
0);
renChild->GetActiveCamera()->ComputeViewPlaneNormal();
renChild->ResetCamera();
renChild->GetActiveCamera()->Dolly(1.5);
renChild->Render();
-------------------------------------------------
vtkImageActor* CVtkDoc::GetDCMImage(int which_one)
{
if( current_mode == DICOM)
{
int index = 0;
if (index == which_one)
return lst.front();
else
{
std::list<vtkImageActor *>::iterator ptr =
lst.begin();
for (ptr; ptr != lst.end();ptr++)
if (index == which_one)
return (*ptr);
else
index ++;
}
}
return NULL;
}
___________________________________________________ ×îаæ Yahoo!ÆæĦ¼´rÍ¨Ó 7.0 beta£¬ÃâÙM¾W·ëÔÈÎÄã´ò£¡ http://messenger.yahoo.com.tw/beta.html
More information about the vtkusers
mailing list