<div dir="ltr"><div>Sorry for so many questions, but I need to get on my project.<br><br>I've got an Octree where its DataSet contains voxels with scalar values to 0 or 1 (it comes from a binary image).<br><br>If I traverse the dataset the following way<br><br></div><div> dataset = octree->GetDataSet();<br></div><div><br></div><div> for (int z = 0; z < dims[2]; z++)<br> {<br> for (int y = 0; y < dims[1]; y++)<br> {<br> for (int x = 0; x < dims[0]; x++)<br> {<br> double* pixel = static_cast<double*>(dataset->GetScalarPointer(x,y,z));<br> if ( pixel[0] != 0 ) count++;<br> }<br> }<br> }<br><br>then it works OK, that is, I detect how many voxels are 1's and how many are 0's.<br><br>However, when I go through region by region, getting the vtkIds and then the scalar value from it:<br><br>for(int j=0; j < octree->GetNumberOfLeafNodes(); j++)<br> {<br> vtkIdTypeArray* points = octree->GetPointsInRegion(j);<br><br> for(vtkIdType idx=0; idx < points->GetSize(); idx++)<br> {<br> dataset->GetPoint(idx, p); // Get the idx coordinates<br> x = p[0]; y = p[1]; z = p[2];<br><br> voxelValue = static_cast<double*>(dataset->GetScalarPointer(x, y, z));<br> if ( voxelValue[0] != 0 ) count++;<br> }<br> }<br><br><br></div><div>Thank you very much for your support and patience.<br></div><div><br>then:<br><br>1. I donot know why the x, y, z coordinates are returned as double values, e.g. instead of (1,0,0) it returns (1.07234, 0,0).<br>2. I donot understand why all voxel values are now 0's.</div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-10 13:25 GMT+02:00 Francisco Lopez de la Franca <span dir="ltr"><<a href="mailto:franciscolopezdelafranca@gmail.com" target="_blank">franciscolopezdelafranca@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi everybody,<br>Once I retrieve the list of points (IDs) in an octree region/octant, by coding<br><br>vtkIdTypeArray* points = octree->GetPointsInRegion(i);<br><br>I'd like to know the scalar voxel value (0 or 1 since the image is binary) of every point in the "points" array.<br></div><div>I've tried with "points->GetValue(iterator)" and with "points->GetTuple1()" but the result is not the expected.<br></div><div><br></div><div>Please, does someone know what I should I do or what am I doing wrong?<br><br></div><div>Sincerely, thank you very much.<br></div><div>Regards<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-06-09 23:49 GMT+02:00 Francisco Lopez de la Franca <span dir="ltr"><<a href="mailto:franciscolopezdelafranca@gmail.com" target="_blank">franciscolopezdelafranca@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi again,<div><span style="font-size:15px">Could anybody tell what is the difference between vtkoctreepointlocator and vtkhyperoctree? I am using the former for ceating an octree from an image, but i donot know which one is the best. My intention is mainly to know how many points there are per octant.</span></div><span><div>Thank you very much.</div><div>My best regards.</div></span><div><div><div><br>El miércoles, 3 de junio de 2015, Francisco Lopez de la Franca <<a href="mailto:franciscolopezdelafranca@gmail.com" target="_blank">franciscolopezdelafranca@gmail.com</a>> escribió:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Thanks a lot.<br>
And is there an example on how to traverse the whole octree? I mean, i would like to know how many points there are per octant.<br>
And finally, independently on the image, if i create an octree with a fixed level, will the representation be the same? I mean, the same number of octants with the same distribution independently on the image?<br>
Thank you very much.<br>
My best regards.</p>
<div class="gmail_quote">El 03/06/2015 15:36, "Bill Lorensen" <<a>bill.lorensen@gmail.com</a>> escribió:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This example may help:<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/DataStructures/OctreeVisualize" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/DataStructures/OctreeVisualize</a><br>
<br>
<br>
On Wed, Jun 3, 2015 at 8:48 AM, Francisco Lopez de la Franca<br>
<<a>franciscolopezdelafranca@gmail.com</a>> wrote:<br>
> Hi.<br>
> I've created an example (see below) but everything is OK except that the<br>
> output image is not created. I'd be very pleased if someone can help me<br>
> (maybe with an explanatory example or whatever).<br>
><br>
> char* filename = new char[255];<br>
> strcpy(filename, "nifti_image.nii");<br>
><br>
> vtkSmartPointer<vtkNIFTIImageReader> reader =<br>
> vtkSmartPointer<vtkNIFTIImageReader>::New();<br>
><br>
> reader->SetFileName(filename);<br>
> reader->Update();<br>
><br>
> //Create the octree<br>
> vtkSmartPointer<vtkOctreePointLocator> octree =<br>
> vtkSmartPointer<vtkOctreePointLocator>::New();<br>
> octree->SetDataSet((vtkDataSet*) reader->GetOutput());<br>
> octree->BuildLocator();<br>
><br>
> std::cout << "Number of cells in tree: " <<<br>
> octree->GetDataSet()->GetNumberOfCells() << std::endl;<br>
> std::cout << "Number of points in tree: " <<<br>
> octree->GetDataSet()->GetNumberOfPoints() << std::endl;<br>
><br>
> char* outfile = new char[255];<br>
> strcpy(outfile, "OcTree.vtp");<br>
><br>
> vtkSmartPointer<vtkXMLPolyDataWriter> writer =<br>
> vtkSmartPointer<vtkXMLPolyDataWriter>::New();<br>
> writer->SetInputData((vtkPolyData*) octree->GetDataSet());<br>
> writer->SetFileName(outfile);<br>
> writer->Write();<br>
><br>
><br>
> 2015-05-29 12:40 GMT+02:00 Francisco Lopez de la Franca<br>
> <<a>franciscolopezdelafranca@gmail.com</a>>:<br>
>><br>
>> Hi everybody,<br>
>> I'd like to represent a 3D image as a fixed number of cubes, I mean,<br>
>> something like a spatial occupancy matrix in 3D.<br>
>><br>
>> Could you, please, recommend me a fast way to do it or does it exist a<br>
>> data structure in VTK to achieve this?<br>
>><br>
>> I've found the OcTree structure but I donot know if it is valid for this.<br>
>><br>
>> Thank you very much.<br>
>> My best regards.<br>
>> /Francisco<br>
><br>
><br>
><br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
><br>
<br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
</blockquote></div>
</blockquote></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>