[vtkusers] output surface coordinates for vtkSurfaceReconstructionFilter

Obada Mahdi omahdi at gmx.de
Fri Dec 8 07:38:23 EST 2006


Hello Ismail!

On Thu, 7 Dec 2006, Ismail Elkhrachy wrote:
> Is the output surface coordinates  for  vtkSurfaceReconstructionFilter 
> scaled? If yes , how to get the surface coordinates according to the 
> input surface coordinates?

Apparently, origin and spacing are not propagated into the output data
set for some reason by vtkSurfaceReconstructionFilter.  They are,
however, propagated to the output information vector of the algorithm.
I am not sure whether vtkSurfaceReconstructionFilter should set up
spacing and origin in the output data set, or whether vtkContourFilter
(or the classes it delegates the actual work to) should honour the
spacing and origin provided through the information vector, or both.

Anyway, this has been reported both in the mailing list as well as in
the bug tracker, see

http://public.kitware.com/pipermail/vtkusers/2006-February/083627.html
http://www.vtk.org/Bug/bug.php?op=show&bugid=2826&pos=0

(I found those searching the mailing list archives, via the Kitware
website, for "vtkusers vtkSurfaceReconstructionFilter spacing origin".)

This explains the "scaling effect": If you have a look at the bounds of
the contoured output data set from your previous message, which I am
quoting below for reference, you will notice that they closely match the
expected dimensions of the sampled distance function produced by
vtkSurfaceReconstructionFilter, with respect to a sampling resolution.

For example, given the input bounds

> For example The bounds for the original input (x, y,z) data coordinates 
> is :
>
> X_min = 1.037000,    X_max =2.401000

and a sampling spacing of 0.026, one would probably expect the output
extent in x to be from 0 to (X_max-X_min)/0.026, which is 52.  It turns
out to be a bit larger

> But for the output for the pt[0], pt[1], pt[2]) is:
> X_min =0.000000,  X_max =55.000000

which looks like a result of an adjustment made by the filter:

[Imaging/vtkSurfaceReconstructionFilter.cxx, lines 411ff]
| 411   // allow a border around the volume to allow sampling around the extremes
| 412   for(i=0;i<3;i++)
| 413     {
| 414     bounds[i*2]-=this->SampleSpacing*2;
| 415     bounds[i*2+1]+=this->SampleSpacing*2;
| 416     }


What you could try to fix this, is to obtain the output of
vtkSurfaceReconstructionFilter after a forced pipeline Update() and set
up spacing and origin manually, probably like this:

|   surf->Update();
|
|   vtkImageData* signedDist = surf->GetOutput()->ShallowCopy();
|   vtkInformation* signedDistInfo = surf->GetOutputPortInformation();
|   signedDist->SetSpacing(signedDistInfo->Get(vtkDataObject::SPACING()));
|   signedDist->SetOrigin(signedDistInfo->Get(vtkDataObject::ORIGIN()));
|
|   vtkContourFilter *cf=vtkContourFilter::New();
|   cf->SetInput(signedDist);

In the output port information, spacing and origin are set to the sample
spacing and top left of the padded bounding box, respectively.

Note that I do not know anything about how the reconstruction filter
works, so I am not sure how accurate the results of simply setting
spacing and origin will be.


Regards

Obada


On Wed, 6 Dec 2006, Ismail Elkhrachy wrote:
> Date: Wed, 06 Dec 2006 08:57:04 +0100
> From: Ismail Elkhrachy <I.Elkhrachy at tu-bs.de>
> To: VTKMailList <vtkusers at vtk.org>
> Subject: [vtkusers] Problem with surface coordinates from vtkContourFilter
> 
> Dear friends,
> I have a point cloud(x, y,z) that represents an object surface. After I 
> use surface reconstruct filter (vtkSurfaceReconstructionFilter) , and as 
> Amy told me how to get all the generated surface coordinate. It is 
> working ok, Thanks again to Amy!!.
> 
> But the output  coordinates pt[0], pt[1], pt[2]) are not in the same 
> coordinates system of original point cloud(x, y,z)polyDat1, Do you know 
> how to get them in the same old coordinate system.
> For example The bounds for the original input (x, y,z) data coordinates 
> is :
> 
> X_min = 1.037000,    X_max =2.401000
> Y_min = 2.508000  ,  Y_max =4.061000
> Z_min = -19.063601 , Z_zmax =-18.101999 
> 
> But for the output for the pt[0], pt[1], pt[2]) is:
> X_min =0.000000,  X_max =55.000000
> Y_min =0.000000 ,  Y_max= 62.000000
> Z_min =0.000000,  Z_zmax= 38.941410 
> 
> Ma code is:
> vtkSurfaceReconstructionFilter *surf = 
> vtkSurfaceReconstructionFilter::New();
>
>   surf->SetInput(polyData1);
>   surf->SetSampleSpacing(0.026);
>   surf->GetReleaseDataFlag();
>   surf->Update();
>
>   vtkContourFilter *cf=vtkContourFilter::New();
>   cf->SetInput(surf->GetOutput());
>   cf->SetValue (0, 0.0 );
>   cf->Update();
> 
> vtkPoints *points = cf->GetOutput()->GetPoints();
> int numPts = points->GetNumberOfPoints();
> int i;
> double pt[3];
> 
> for (i = 0; i < numPts; i++)
>  {
>    points->GetPoint(i, pt);
>    printf("point %d: %f %f %f\n", i, pt[0], pt[1], pt[2]);
>  }
> 
> I am using vtk 5.0.0 under MS Visual C++ 6.0, windows xp professional.
> 
> Any suggestion will be appreciated. Thank you in advance.
> Ismail
> 
> 
> 
> 
> 
> M.Sc. Ismail Elkhrachy
> PhD student
> 
> Institut für Geodäsie und Photogrammetrie
> Technische Universität Braunschweig
> Gaußstr. 22   38106 Braunschweig Germany
> 
> Mob.           : 0049 0163 3623486
> Tel.           : 0049 0531 3917497
> Fax            : 0049 0531 3917499
> E-mail         : I.Elkhrachy at tu-bs.de, I.Elkhrachy at yahoo.com


More information about the vtkusers mailing list