Posts

Showing posts with the label vtk

Reslice 3d Raw image using vtkImageReslice

Image
Clash Royale CLAN TAG #URR8PPP Reslice 3d Raw image using vtkImageReslice I'm trying to get a 2d slice from a 3d raw image, and I'm viewing the output on a vtkImageViewer2 but I'm getting a blank window. I'm afraid that i can not make this code shorter because each step in this pipeline is necessary as mentioned here: example that i followed . also you need a raw image and its header file FullHead.raw.gz which uses FullHead.mhd as a header file. Here is my code : #include <vtkPolyDataMapper.h> #include <vtkActor.h> #include <vtkRenderer.h> #include<vtkRenderWindow.h> #include<vtkRenderWindowInteractor.h> #include <vtkGenericOpenGLRenderWindow.h> #include <vtkInteractorStyleTrackballCamera.h> #include <vtkImageReslice.h> #include <vtkImageData.h> #include <vtkLookupTable.h> #include <vtkImageMapToColors.h> #include <vtkImageViewer2.h> #include <vtkMatrix4x4.h> int main(){ vtkSmartPointer<vtk...

How to get VTK's tuple size from vtkDataArray

Image
Clash Royale CLAN TAG #URR8PPP How to get VTK's tuple size from vtkDataArray I'm trying to read all the data from all the tuples from a vtkDataArray class. However vtkDataArray::GetTuple as can be seen here returns a pointer to a double array. I'm wondering how can I get the size of that array. Seems like I'm missing an obvious solution. Code snipet: void doSomething(vtkSmartPointer<vtkDataArray> dataArray) { vtkIdType numTuples = dataArray->GetNumberOfTuples(); for (vtkIdType tupleIdx = 0; tupleIdx < numTuples; ++tupleIdx) { double* tuple = dataArray->GetTuple(tupleIdx); for (int j = 0; j < ¿¿¿???; ++j} double var = tuple[j]; //Do something with var //Carefull don't go out of bounds } } 1 Answer 1 You need dataArray->GetNumberOfComponents() . If you know the number of components then it may be easi...