[vtkusers] Volume-Splatting-Problem with images
Matthias Mucha
matthiasmucha at gmx.de
Thu May 27 15:23:34 EDT 2010
Dear List,
I work with Realtime-2D-Ultrasound-Images which I get from a queue (the image- and tracking-data are stored in a queue which will be updated every 30 ms (30 FPS)). After I transform the images with tracking-data I store the pixel (with its position as vnl-vectors) and the scalars in a vtkPolyData-object. What I now want to do is to build a volume in realtime out of the vtkPolyData-object . So I played around with the vtkGaussianSplatter but I can't fasten it for realtime-reconstruction (it is very slow for images with a dimension of 765x576).
Also the resolution of the volume is very bad due to the low sample-dimension. Do I miss something when I initialize the vtkGaussianSplatter? Or supplies VTK another solution for such a problem?
Here is my code for the reconstruction:
for(/*each image (30) in the queue){
/*... get the image and transform them*/
//after transformation
//get the VTK-Image-data out of the MITK-Image
vtkImageData* imageData = m_MITKSlice->GetVtkImageData();
int* dims = imageData->GetDimensions(); //get image-dimensions
mitk::Point3D index = mitk::Point3D();
mitk::Point3D pixelPos = mitk::Point3D();
//iterate through each pixel in the 2D-image to get the color and the position
for (int z = 0; z < dims[2]; z++){
for (int y = 0; y < dims[1]; y++){
for (int x = 0; x < dims[0]; x++){
index = mitk::Point3D();
pixelPos = mitk::Point3D();
index.GetVnlVector()[0] = x;
index.GetVnlVector()[1] = y;
index.GetVnlVector()[2] = z;
//get the pixel-position m_MITKSlice->GetGeometry()->IndexToWorld(index, pixelPos);
unsigned char* pixel = static_cast<unsigned char*>(imageData->GetScalarPointer(x, y, z));
pixelValues->InsertNextValue(*pixel);
points->InsertNextPoint(pixelPos.GetVnlVector()[0], pixelPos.GetVnlVector()[1], pixelPos.GetVnlVector()[2]);
}
}
}
}
//set the point-Array which stores all slices
pointsPolydata->SetPoints(points);
//convert the points to vertices
vtkSmartPointer<vtkVertexGlyphFilter> vertexFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();
vertexFilter->SetInputConnection(pointsPolydata->GetProducerPort());
vertexFilter->Update();
volumeGrid->ShallowCopy(vertexFilter->GetOutput());
volumeGrid->GetPointData()->SetScalars(pixelValues);
//splatt the polydata into a volume
splatter->SetInput(volumeGrid);
splatter->SetRadius(0.05);
//it take hours to build the volume if the sample-dimension is set to a //high value
splatter->SetSampleDimensions(80,80,80);
splatter->SetAccumulationModeToMin();
splatter->SetExponentFactor(-10);
splatter->SetScaleFactor(1);
splatter->NormalWarpingOn();
splatter->Update();
vtkImageData* outVolume = splatter->GetOutput();
Best regards!
Matthias Mucha
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
More information about the vtkusers
mailing list