<div dir="ltr">Did you called Modified() on your image data? This is how downstream algorithms know to recompute their results.<br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 3, 2015 at 4:50 AM mbcx9rb9 <<a href="mailto:richard.j.brown@live.co.uk">richard.j.brown@live.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">i have a vtkImageData, which I would like to be able to calculate the max,<br>
min, average, etc. via vtkImageAccumulate. Then I want to be able to edit<br>
the image data, update the image accumulate and see the new statistics.<br>
<br>
However, it seems that vtkImageAccumulate doesn't work how I hoped it would.<br>
When I change my image data, my image accumulate still returns the original<br>
statistics of the image data before I made the changes.<br>
<br>
If I edit my image data, am I obliged to reinitialise my image accumulate to<br>
be able to see the statistics on the edited image data?<br>
<br>
I have attached a simple example of a matrix with one voxel=100 and whose<br>
max is found with imageaccumulate. Then, a voxel of 200 is added,<br>
imageaccumulate is updated, but returns a max of 100 instead of the new 200.<br>
Finally, a new imageaccumulate is used to verify that the actually max is<br>
200 as expected.<br>
<br>
Any ideas of where I'm going wrong would be greatly appreciated.<br>
<br>
<br>
<br>
// create image data<br>
vtkSmartPointer<vtkImageData> id = vtkSmartPointer<vtkImageData>::New();<br>
id->SetSpacing(1,1,1);<br>
id->SetExtent(0,99,0,99,0,99);<br>
id->AllocateScalars(VTK_DOUBLE,1);<br>
<br>
// set all values to zero<br>
for (int i=id->GetExtent()[0]; i<=id->GetExtent()[1]; i++) {<br>
for (int j=id->GetExtent()[2]; j<=id->GetExtent()[3]; j++) {<br>
for (int k=id->GetExtent()[4]; k<=id->GetExtent()[5]; k++) {<br>
double* voxel =<br>
static_cast<double*>(id->GetScalarPointer(i,j,k));<br>
voxel[0] = 0;<br>
}<br>
}<br>
}<br>
<br>
// set one voxel value to 100<br>
double* voxel = static_cast<double*>(id->GetScalarPointer(50,50,50));<br>
voxel[0] = 100;<br>
<br>
// set image accumulate<br>
vtkSmartPointer<vtkImageAccumulate> ia =<br>
vtkSmartPointer<vtkImageAccumulate>::New();<br>
ia->SetInputData(id);<br>
ia->SetComponentExtent(id->GetExtent());<br>
ia->SetComponentOrigin(id->GetOrigin());<br>
ia->SetComponentSpacing(id->GetSpacing());<br>
ia->Update();<br>
<br>
// output the max in the matrix (should be 100)<br>
std::cout << "max before change: " << ia->GetMax()[0] << std::endl;<br>
<br>
// change a different voxel to 200<br>
voxel = static_cast<double*>(id->GetScalarPointer(50,50,60));<br>
voxel[0] = 200;<br>
<br>
// update image accumulate<br>
ia->Update();<br>
std::cout << "max after change (want this value to be 200): " <<<br>
ia->GetMax()[0] << std::endl;<br>
<br>
// create second image accumulate to verify that the max is, as it<br>
should be, 200<br>
vtkSmartPointer<vtkImageAccumulate> ia2 =<br>
vtkSmartPointer<vtkImageAccumulate>::New();<br>
ia2->SetInputData(id);<br>
ia2->SetComponentExtent(id->GetExtent());<br>
ia2->SetComponentOrigin(id->GetOrigin());<br>
ia2->SetComponentSpacing(id->GetSpacing());<br>
ia2->Update();<br>
std::cout << "max with ia2 (should be 200): " << ia2->GetMax()[0] <<<br>
std::endl;<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/updating-vtkImageAccumulate-tp5732697.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/updating-vtkImageAccumulate-tp5732697.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div>