<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr"><div><div><div><div><div><div>Hello all,<br><br></div>I'm using vtkMarchingCubes to generate a surface of a niftii medical image.<br><br>    //Read image<br>    vtkSmartPointer<<wbr>vtkNIFTIImageReader> reader = vtkSmartPointer<<wbr>vtkNIFTIImageReader>::New();<br>    reader->SetFileName (inputPath);<br>    reader->Update();<br><br></div><div>    //Trick to transform to vtkImageData<br></div><div>    vtkSmartPointer<vtkImageData> volume = vtkSmartPointer<vtkImageData>:<wbr>:New();<br>    volume->DeepCopy(reader-><wbr>GetOutput());<br><br>    //Marching cubes<br>    vtkSmartPointer<<wbr>vtkMarchingCubes> surface =  vtkSmartPointer<<wbr>vtkMarchingCubes>::New();<br>    surface->SetInputData(volume);<br>    surface->ComputeNormalsOn();<br>    surface->SetValue(0, 1);<br>    surface->Update();<br>    vtkPolyData* surfacePiece = surface->GetOutput();<br><br></div>Then, I try to get the original intensity values for every point of the surface. This implies I have to map every surface point to its corresponding voxel in the original medical image. As follows:<br><br>    for(int i = 0; i < surfacePiece-><wbr>GetNumberOfPoints(); i++)<br>    {<br>       double p[3];<br>       p[0] = (p[0] - volume->GetOrigin()[0]) / volume->GetSpacing()[0];<br>       p[1] = (p[0] - volume->GetOrigin()[1]) / volume->GetSpacing()[1];<br>       p[2] = (p[0] - volume->GetOrigin()[2]) / volume->GetSpacing()[2];<br>       surfacePiece->GetPoint(i,p);<br><br>       double intensity = volume-><wbr>GetScalarComponentAsDouble((<wbr>int)(p[0]), (int)(p[1]), (int)(p[2]), 0);<br>       cout << p[0] << " " << p[1] << " " << p[2] << " " << intensity << endl;<br>    }<br><br></div>However, I get an intensity value of 0 for most of the points of the surface, which is not possible, as points with value 0 would not be part of the surface. So, I think my mapping is not correct, and surface and original image coordinates do not match. <br><br></div><div>I tried looking at close voxels, such as (int)(p[0]) + 1 or (int)(p[0]) - 1, but the result is the same. Also, I tried not to do the origin and spacing conversion, but there were no improvements. I'm thinking about orientation issues, but they do not seem to be the answer, and I cannot find a way to check orientation by using VTK.<br></div><div><br></div>Has anybody had this problem before?<br><br></div>Sincerely,<br><br></div>Renzo Phellan<br><div><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div>
</div><br></div>