[vtkusers] Does vtkImageBlend or vtkAppendPolyData generate 3D / Volumetric representation of 2D Image Data or PolyData respectively
Neel007
sayanmaity.10 at gmail.com
Mon Jul 13 20:10:35 EDT 2015
Dear Cory,
I was following the second-step you mentioned: "Alternatively, you could
*create a 3D image from your input 2D image*s, then use *vtkThreshold to
create an unstructured grid of just the white parts of the 3D image*. To
convert the resulting hexahedral elements in the *unstructured grid to
tetrahedra, use vtkDataSetTriangleFilter*." I am able to complete the first
step successfully the second one partially. I have included the code & the
output window, if you can have a look and give me some input It will be very
much appreciated. Thank you for your time.
*/create a 3D image from your input 2D images...(Working Fine as I have
visualized it similar as Matlab)/*
// Start by loading some data.
vtkSmartPointer<vtkTIFFReader> reader =
vtkSmartPointer<vtkTIFFReader>::New();
reader->SetFileNameSliceOffset(1);
reader->SetFileNameSliceSpacing(1);
reader->SetFilePattern("C:\\Users\\Neel\\Desktop\\VTK_try\\test_images\\2.%d.bspline.tif");
reader->SetDataExtent(0, 63, 0, 63, 1, 551);
reader->SetOrientationType(3);
reader->Update();
*/vtkThreshold to create an unstructured grid of just the white parts of the
3D image/*
As you have suggested to use vtkThreshold but the input data being binary
"Image Thresholding" operation is not applicable. Thus, I tried to convert
the 3D volume of *.tif stack of images to vtkImageData and trying to use
vtkClipVolume to create an unstructured grid using the white pixels. Here
I'm facing an issue: vtkImageData pixel values of the Binary Image resulting
-5.4861292803319049e+303 ; Instead of 0 & 1; Any suggestion if I am missing
something here. The code snippet & the output-window:
<http://vtk.1045678.n5.nabble.com/file/n5732876/1.png>
// Create an image data
vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>::New();
//vtkImageData *imageData=0;
imageData->AllocateScalars(VTK_DOUBLE,1);
imageData =reader->GetOutput() ;
int* dims = imageData->GetDimensions();
// int dims[3]; // can't do this
std::cout << "Dims: " << " x: " << dims[0] << " y: " << dims[1] << " z: "
<< dims[2] << std::endl;
std::cout << "Number of points: " << imageData->GetNumberOfPoints() <<
std::endl;
std::cout << "Number of cells: " << imageData->GetNumberOfCells() <<
std::endl;
int extent[6];
imageData->GetExtent(extent) ;
<http://vtk.1045678.n5.nabble.com/file/n5732876/2.png>
vtkIdType numberOfPointArrays =
imageData->GetPointData()->GetNumberOfArrays();
std::cout << "Number of PointData arrays: " << numberOfPointArrays <<
std::endl;
cout<< "Number of Scalar Components:
"<<imageData->GetNumberOfScalarComponents()<<endl;
for(vtkIdType i = 0; i < numberOfPointArrays; i++)
{
// The following two lines are equivalent
//arrayNames.push_back(polydata->GetPointData()->GetArray(i)->GetName());
//arrayNames.push_back(polydata->GetPointData()->GetArrayName(i));
int dataTypeID = imageData->GetPointData()->GetArray(i)->GetDataType();
std::cout << "Array " << i << ": " <<
reader->GetOutput()->GetPointData()->GetArrayName(i)
<< " (type: " << dataTypeID << ")" << std::endl;
}
vtkSmartPointer<vtkClipVolume> vol =
vtkSmartPointer<vtkClipVolume>::New();
vol->SetInputData(imageData);
double tryval=-5.4861292803319049e+303;//* */Not sure which value I should
for clipping/*
vol->SetValue(tryval);
vol->Update();
*For few slices (50) vtkClipVolume is working but for entire series it
throwing memory exception. I think I might need to use some other
functionalities. Please give me some suggestion.*
*/unstructured grid to tetrahedra, use vtkDataSetTriangleFilter/*
vtkNew<vtkDataSetTriangleFilter> tf;
tf->SetInputConnection(vol->GetOutputPort());
tf->Update();
--
View this message in context: http://vtk.1045678.n5.nabble.com/Does-vtkImageBlend-or-vtkAppendPolyData-generate-3D-Volumetric-representation-of-2D-Image-Data-or-Poy-tp5732834p5732876.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list