[vtkusers] Median of a ROI

Michael Knopke Michael.Knopke at gmx.de
Tue Mar 20 10:23:01 EDT 2007


Hi Sergi,

 

I have the same problem but use a workaround, there should be a better way
for it.

 

I set the background to an unlikely value eg. 50000

And then loop over the image excluding those values not in the selected
region:

 

   for(vtkIdType i = 0; i<=NumberOfTuples; i++){

       Value =
stencil->GetOutput()->GetPointData()->GetScalars()->GetTuple(i);

   if(*Value != 50000)

        {

         if (maxValue < *Value) maxValue = *Value;

         SummedValue = SummedValue + (*Value );

         counter++;

        }

MeanValue = (int)(SummedValue/counter);

 

Regards

 

Michael

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070320/1b439948/attachment.htm>


More information about the vtkusers mailing list