[vtkusers] vtkImageAccumulate

Odet Christophe christophe.odet at creatis.insa-lyon.fr
Thu Jun 21 10:17:01 EDT 2001


Hi, David,
> 
> It might just be a matter of convention.  One way to build histograms
> is to place the bins at 0.5, 1.5, 2.5, etc. and then the bin at 0.5 collects
> values in the range [0,1), the bin at 1.5 collects the range [1,2).  This
> makes more sense to me, because the position of the bin corresponds to
> the center of the range.

I agree with you. That 's the way hings are generally presented. But...
In our case the bin number is only an integer index in the output array.
and not the real value of the gray level at the bin center.

> 
> > If you add 0.5 before rounding, this will change the rule and can create
> > problems at both ends of the histogram with something like "half filled"
> > bins. Am I right ?
> 
> Not if you set the 'origin' at e.g. 0.5, -32768.5, etc (assuming the
> spacing is 1.0)

That's look a bit tricky for me. In the vtkImageAccumulate doc, the meaning of origin was not really clear
for me. It looks like a kind of gray level shifting and using it can lead to negative index in the
output array if it is set far away from the real gray value origin of the input image.
It looks simpler for me to consider that origin is the start of bin 0. With your solution, I have to
put an origin at (start of gray level + spacing/2) even if I have grey levels lower than this value.

Without 0.5 addition, the meaning is quite simple (I hope, and can be easily explained in the doc ;-) ):
bin 0 contains the number of pixel having gray level in[origin,origin+spacing)
bin 1 contains the number of pixel having gray level in[origin+spacing,origin+2*spacing)
and so on...

With your solution, the grey level center of the bin is equal to the index number only when
spacing is 1 and origin is correct. But the doc can be:
bin 0 contains the number of pixel having gray level in[origin-spacing/2,origin+spacing/2)
bin 1 contains the number of pixel having gray level in[origin+spacing/2,origin+spacing+spacing/2)
...
bin n contains the number of pixel having gray level in[origin+n*spacing-spacing/2,origin+n*spacing+spacing/2)

> Unless we get a third opinion, we might never know ;)
> 

We really need a third opinion. Hello, dear vtkusers ?

Christophe





More information about the vtkusers mailing list