<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Hello Everybody,<div>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. </div>
<div>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).</div><div>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):</div>
<div><br></div><div><div><i>vtkImageData* TransformVTK(vtkImageData* sourceImage, vtkImageData* newImage)</i></div><div><i>{</i></div><div><i><span style="white-space:pre-wrap"> </span>int extent[6];</i></div><div><i><span style="white-space:pre-wrap"> </span>int x1,x2,y1,y2,z1,z2;</i></div>
<div><i><span style="white-space:pre-wrap"> </span>sourceImage->GetExtent(extent);</i></div><div><i><span style="white-space:pre-wrap"> </span>x1 = extent[0];</i></div><div><i><span style="white-space:pre-wrap"> </span>x2 = extent[1];</i></div>
<div><i><span style="white-space:pre-wrap"> </span>y1 = extent[2];</i></div><div><i><span style="white-space:pre-wrap"> </span>y2 = extent[3];</i></div><div><i><span style="white-space:pre-wrap"> </span>z1 = extent[4];</i></div>
<div><i><span style="white-space:pre-wrap"> </span>z2 = extent[5];</i></div><div><i><br></i></div><div><i><span style="white-space:pre-wrap"> </span>newImage->SetExtent(extent);</i></div><div><i><span style="white-space:pre-wrap"> </span>newImage->SetSpacing(1,1,1);</i></div>
<div><i><br></i></div><div><i><span style="white-space:pre-wrap"> </span>for(int k = z1; k<=z2; k++)</i></div><div><i><span style="white-space:pre-wrap"> </span>{</i></div><div><i><span style="white-space:pre-wrap"> </span>for(int j = y1; j<=y2; j++)</i></div>
<div><i><span style="white-space:pre-wrap"> </span>{</i></div><div><i><span style="white-space:pre-wrap"> </span>for (int i = x1; i<=x2; i++)</i></div><div><i><span style="white-space:pre-wrap"> </span>{</i></div>
<div><i><span style="white-space:pre-wrap"> </span>float* pValueSource = static_cast<float*>(sourceImage->GetScalarPointer(i,j,k));</i></div><div><i><span style="white-space:pre-wrap"> </span>float* pValueDestination = static_cast<float*>(newImage->GetScalarPointer(i,j,k));</i></div>
<div><i><span style="white-space:pre-wrap"> </span>pValueDestination[0] = pValueSource[0];</i></div><div><i><span style="white-space:pre-wrap"> </span>}</i></div><div><i><span style="white-space:pre-wrap"> </span>}</i></div>
<div><i><span style="white-space:pre-wrap"> </span>}</i></div><div><i><br></i></div><div><i><span style="white-space:pre-wrap"> </span>newImage->Update();</i></div><div><i><span style="white-space:pre-wrap"> </span>return newImage;</i></div>
<div><i>}</i></div></div><div><br></div><div>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:</div><div><br></div><div><div><i>vtkImageActor<span style="white-space:pre-wrap"> </span>*A =<span style="white-space:pre-wrap"> </span>vtkImageActor::New();</i></div>
<div><i><span style="white-space:pre-wrap"> </span>vtkRenderer <span style="white-space:pre-wrap"> </span>*R =<span style="white-space:pre-wrap"> </span>vtkRenderer::New();</i></div><div><i><span style="white-space:pre-wrap"> </span>vtkRenderWindow <span style="white-space:pre-wrap"> </span>*RW =<span style="white-space:pre-wrap"> </span>vtkRenderWindow::New();</i></div>
<div><i><span style="white-space:pre-wrap"> </span>vtkRenderWindowInteractor<span style="white-space:pre-wrap"> </span>*RWI =<span style="white-space:pre-wrap"> </span>vtkRenderWindowInteractor::New();</i></div>
<div><i><span style="white-space:pre-wrap"> </span>RW->AddRenderer(R);</i></div><div><i><span style="white-space:pre-wrap"> </span>RWI->SetRenderWindow(RW);</i></div></div><div><br></div><div><div><span style="white-space:pre-wrap"> </span>int imageextent[6];</div>
<div><span style="white-space:pre-wrap"> </span>int x1,x2,y1,y2,z1,z2;</div><div><span style="white-space:pre-wrap"> </span>NEWIMAGE->GetExtent(imageextent);</div><div><span style="white-space:pre-wrap"> </span>x1 = imageextent[0];</div>
<div><span style="white-space:pre-wrap"> </span>x2 = imageextent[1];</div><div><span style="white-space:pre-wrap"> </span>y1 = imageextent[2];</div><div><span style="white-space:pre-wrap"> </span>y2 = imageextent[3];</div>
<div><span style="white-space:pre-wrap"> </span>z1 = imageextent[4];</div><div><span style="white-space:pre-wrap"> </span>z2 = imageextent[5];</div></div><div><br></div><div><div><i>vtkSmartPointer<vtkExtractVOI> SLICER =<span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkExtractVOI>::New();</i></div>
<div><i><span style="white-space:pre-wrap"> </span>SLICER->SetInput(NEWIMAGE);</i></div><div><i><span style="white-space:pre-wrap"> </span>SLICER->SetVOI(x1,x2,y1,y2,10,10);</i></div><div><i><br></i></div><div>
<i><span style="white-space:pre-wrap"> </span>A->SetInput(SLICER->GetOutput());</i></div><div><i><span style="white-space:pre-wrap"> </span>R->AddActor(A);</i></div><div><i><span style="white-space:pre-wrap"> </span>RW->Render();</i></div>
<div><br></div><div><i><span style="white-space:pre-wrap"> </span>RWI->Initialize();</i></div><div><i><span style="white-space:pre-wrap"> </span>RW->Render();</i></div><div><i><span style="white-space:pre-wrap"> </span>RWI->Start();</i></div>
</div><div><i><br></i></div><div>The output is black although it has proper dimensions.</div><div><br></div><div>I have tried also:</div><div>NEWIMAGE->vtkDataSetMapper->vtkActor...</div><div>NEWIMAGE->vtkSmartVolumeMapper->vtkVolume</div>
<div>but still it didn't work.</div><div><br></div><div>Do you have any ideas where am I wrong or how it should be treated the other way?</div><div>Thanks in advance for any help.</div><div><br></div><div>Ania</div></div>
</div><br></div>