[vtkusers] Fwd: 3D ImageData
Anna Galas
anna.galas at wp.pl
Fri May 9 04:09:10 EDT 2014
Hello Everybody,
I am a beginner in vtk and I have some problems in one of my projects. My
task is to load a set of images from files together with their location
data (in txt files) and make them a 3D image.
My idea was to read the files and then rewrite the intensity values from
one vtkImageData (which is the output of the reader) to the new ImageData
(newly created).
At the beginnig I have an algorithm that copies the intensity values to the
new image without any changing in location (just to try if it works):
*vtkImageData* TransformVTK(vtkImageData* sourceImage, vtkImageData*
newImage)*
*{*
* int extent[6];*
* int x1,x2,y1,y2,z1,z2;*
* sourceImage->GetExtent(extent);*
* x1 = extent[0];*
* x2 = extent[1];*
* y1 = extent[2];*
* y2 = extent[3];*
* z1 = extent[4];*
* z2 = extent[5];*
* newImage->SetExtent(extent);*
* newImage->SetSpacing(1,1,1);*
* for(int k = z1; k<=z2; k++)*
* {*
* for(int j = y1; j<=y2; j++)*
* {*
* for (int i = x1; i<=x2; i++)*
* {*
* float* pValueSource =
static_cast<float*>(sourceImage->GetScalarPointer(i,j,k));*
* float* pValueDestination =
static_cast<float*>(newImage->GetScalarPointer(i,j,k));*
* pValueDestination[0] = pValueSource[0];*
* }*
* }*
* }*
* newImage->Update();*
* return newImage;*
*}*
Such newImage I want to get somehow to the screen. The goal is to do it 3D,
but now I just tried to slice it and render as an image:
*vtkImageActor *A = vtkImageActor::New();*
* vtkRenderer *R = vtkRenderer::New();*
* vtkRenderWindow *RW = vtkRenderWindow::New();*
* vtkRenderWindowInteractor *RWI = vtkRenderWindowInteractor::New();*
* RW->AddRenderer(R);*
* RWI->SetRenderWindow(RW);*
int imageextent[6];
int x1,x2,y1,y2,z1,z2;
NEWIMAGE->GetExtent(imageextent);
x1 = imageextent[0];
x2 = imageextent[1];
y1 = imageextent[2];
y2 = imageextent[3];
z1 = imageextent[4];
z2 = imageextent[5];
*vtkSmartPointer<vtkExtractVOI> SLICER =
vtkSmartPointer<vtkExtractVOI>::New();*
* SLICER->SetInput(NEWIMAGE);*
* SLICER->SetVOI(x1,x2,y1,y2,10,10);*
* A->SetInput(SLICER->GetOutput());*
* R->AddActor(A);*
* RW->Render();*
* RWI->Initialize();*
* RW->Render();*
* RWI->Start();*
The output is black although it has proper dimensions.
I have tried also:
NEWIMAGE->vtkDataSetMapper->vtkActor...
NEWIMAGE->vtkSmartVolumeMapper->vtkVolume
but still it didn't work.
Do you have any ideas where am I wrong or how it should be treated the
other way?
Thanks in advance for any help.
Ania
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140509/09c09be3/attachment.html>
More information about the vtkusers
mailing list