[vtkusers] vtkImageAccumulate
Ula Popov
ula.popov at gmail.com
Fri Apr 29 12:52:45 EDT 2011
Hi Liam,
this is how I usually add arrays to image data
vtkDataArray *Velocity;
Velocity = Velocity->CreateDataArray(VTK_DOUBLE);
Velocity->SetNumberOfComponents(3);
Velocity->SetNumberOfTuples(grid->GetNumberOfPoints());
Velocity->SetName("vertexVelocity");
grid->GetPointData()->AddArray(Velocity);
vtkDataArray *Density;
Density =Density ->CreateDataArray(VTK_DOUBLE);
Density->SetNumberOfComponents(1);
Density ->SetNumberOfTuples(grid->GetNumberOfPoints());
Density->SetName("Density");
grid->GetPointData()->AddArray(Density);
I checked my arrays, they look ok.
I was able to calculate avg just using for-loop,
but I'd still like to understand/use vtk functions for
these tasks.
Thank you,
ula
On Fri, Apr 29, 2011 at 3:07 AM, Liam Kurmos <quantum.leaf at gmail.com> wrote:
> hi Ula,
>
> can i see the code for how you add the 2 fields to the imagedata?
>
> thanks,
>
> Liam
>
>
> On Fri, Apr 29, 2011 at 7:33 AM, Ula Popov <ula.popov at gmail.com> wrote:
> > Hello all,
> >
> > I have an object of class vtkImageData.
> > It has two arrays: density (scalar) and velocity (vector).
> >
> > I want to know mean and median values of the density field.
> >
> > I tried to use vtkImageAccumulate to achieve this goal, but
> > my program crashes on my input (actually, I don't know how
> > to specify on which of the arrays I want to apply. How
> > should I do it?)
> > When I tried to specify origin and spacing, I got similar result (seg
> fault)
> >
> > vtkImageAccumulate *Accumulate = vtkImageAccumulate::New();
> >
> > Accumulate->SetInput(grid);
> >
> > Accumulate->Update();
> > <------- crashes here
> > double *mean = Accumulate->GetMean();
> >
> >
> > Thank you!
> > ula
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110429/e27e25b5/attachment.htm>
More information about the vtkusers
mailing list