[vtkusers] updating vtkImageAccumulate

mbcx9rb9 richard.j.brown at live.co.uk
Mon Jul 6 04:33:55 EDT 2015


That did the trick!

Thanks, seems very obvious in hindsight.

Regards,
Richard

> On 03 Jul 2015, at 19:24, Dan Lipsa-2 [via VTK] <ml-node+s1045678n5732713h75 at n5.nabble.com> wrote:
> 
> Did you called Modified() on your image data? This is how downstream algorithms know to recompute their results.
> 
> On Fri, Jul 3, 2015 at 4:50 AM mbcx9rb9 <[hidden email] <x-msg://2/user/SendEmail.jtp?type=node&node=5732713&i=0>> wrote:
> i have a vtkImageData, which I would like to be able to calculate the max,
> min, average, etc. via vtkImageAccumulate. Then I want to be able to edit
> the image data, update the image accumulate and see the new statistics.
> 
> However, it seems that vtkImageAccumulate doesn't work how I hoped it would.
> When I change my image data, my image accumulate still returns the original
> statistics of the image data before I made the changes.
> 
> If I edit my image data, am I obliged to reinitialise my image accumulate to
> be able to see the statistics on the edited image data?
> 
> I have attached a simple example of a matrix with one voxel=100 and whose
> max is found with imageaccumulate. Then, a voxel of 200 is added,
> imageaccumulate is updated, but returns a max of 100 instead of the new 200.
> Finally, a new imageaccumulate is used to verify that the actually max is
> 200 as expected.
> 
> Any ideas of where I'm going wrong would be greatly appreciated.
> 
> 
> 
>     // create image data
>     vtkSmartPointer<vtkImageData> id = vtkSmartPointer<vtkImageData>::New();
>     id->SetSpacing(1,1,1);
>     id->SetExtent(0,99,0,99,0,99);
>     id->AllocateScalars(VTK_DOUBLE,1);
> 
>     // set all values to zero
>     for (int i=id->GetExtent()[0]; i<=id->GetExtent()[1]; i++) {
>         for (int j=id->GetExtent()[2]; j<=id->GetExtent()[3]; j++) {
>             for (int k=id->GetExtent()[4]; k<=id->GetExtent()[5]; k++) {
>                 double* voxel =
> static_cast<double*>(id->GetScalarPointer(i,j,k));
>                 voxel[0] = 0;
>             }
>         }
>     }
> 
>     // set one voxel value to 100
>     double* voxel = static_cast<double*>(id->GetScalarPointer(50,50,50));
>     voxel[0] = 100;
> 
>     // set image accumulate
>     vtkSmartPointer<vtkImageAccumulate> ia =
> vtkSmartPointer<vtkImageAccumulate>::New();
>     ia->SetInputData(id);
>     ia->SetComponentExtent(id->GetExtent());
>     ia->SetComponentOrigin(id->GetOrigin());
>     ia->SetComponentSpacing(id->GetSpacing());
>     ia->Update();
> 
>     // output the max in the matrix (should be 100)
>     std::cout << "max before change: " << ia->GetMax()[0] << std::endl;
> 
>     // change a different voxel to 200
>     voxel = static_cast<double*>(id->GetScalarPointer(50,50,60));
>     voxel[0] = 200;
> 
>     // update image accumulate
>     ia->Update();
>     std::cout << "max after change (want this value to be 200): " <<
> ia->GetMax()[0] << std::endl;
> 
>     // create second image accumulate to verify that the max is, as it
> should be, 200
>     vtkSmartPointer<vtkImageAccumulate> ia2 =
> vtkSmartPointer<vtkImageAccumulate>::New();
>     ia2->SetInputData(id);
>     ia2->SetComponentExtent(id->GetExtent());
>     ia2->SetComponentOrigin(id->GetOrigin());
>     ia2->SetComponentSpacing(id->GetSpacing());
>     ia2->Update();
>     std::cout << "max with ia2 (should be 200): " << ia2->GetMax()[0] <<
> std::endl;
> 
> 
> 
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/updating-vtkImageAccumulate-tp5732697.html <http://vtk.1045678.n5.nabble.com/updating-vtkImageAccumulate-tp5732697.html>
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com/>
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html <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 <http://www.vtk.org/Wiki/VTK_FAQ>
> 
> Search the list archives at: http://markmail.org/search/?q=vtkusers <http://markmail.org/search/?q=vtkusers>
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers <http://public.kitware.com/mailman/listinfo/vtkusers>
> 
> _______________________________________________ 
> Powered by www.kitware.com 
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html <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 <http://www.vtk.org/Wiki/VTK_FAQ>
> 
> Search the list archives at: http://markmail.org/search/?q=vtkusers <http://markmail.org/search/?q=vtkusers>
> 
> Follow this link to subscribe/unsubscribe: 
> http://public.kitware.com/mailman/listinfo/vtkusers <http://public.kitware.com/mailman/listinfo/vtkusers>
> 
> 
> If you reply to this email, your message will be added to the discussion below:
> http://vtk.1045678.n5.nabble.com/updating-vtkImageAccumulate-tp5732697p5732713.html <http://vtk.1045678.n5.nabble.com/updating-vtkImageAccumulate-tp5732697p5732713.html>
> To unsubscribe from updating vtkImageAccumulate, click here <http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5732697&code=cmljaGFyZC5qLmJyb3duQGxpdmUuY28udWt8NTczMjY5N3wtMjU4ODcyOTI3>.
> NAML <http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://vtk.1045678.n5.nabble.com/updating-vtkImageAccumulate-tp5732697p5732724.html
Sent from the VTK - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150706/abbf132a/attachment.html>


More information about the vtkusers mailing list