Robert Grzeszczuk (rg)
Tue, 20 Jul 1999 14:09:41 -0700 (PDT)
The code you enclosed looks right and when run on the CT data set provided with
the distribution produces reasonably looking histogram, including all values
<0,255>. Is Hist[] an array of int?
The only problem I see with this approach is that it does not account for
overlap. That is, some voxels will get counted twice. You can fix that by
replacing:
for ( i =0 ;i<xBrickSize*yBrickSize*zBrickSize;i++)
Hist[(int)*(start+i)]++;
with something along the lines of:
for(z=zbrickSize-2;z>0;z--,start+=xbrickSize)
for(y=yBrickSize-2;y>0;y--,start++)
for(x=xbrickSize-2;x>0;x--)
Hist[(int)*(start++)]++;
Alternatively, you can compute the histogram with overlap and then subtract the
overalpping areas.
-rg
On Jul 20, 12:32pm, Stefan van der Heijden wrote:
> Subject: Values read from texture incorrect?
> Hello you all
> I made a function to determine the histogram of a volume
> I created a volume with 8 blocks of 16*16*16 with greyvalues varying
> for 15 to 255
> When i call the determine_histogram function(see below) the result
> showns no values lower then 127,although i see in the volumeview the
> values
> the values in the volume which are lower then 127 are summed with the
> values higher then 127 (e.g. greyvalue 15 is summed in 127+15)
> When in do the same thing to the raw data before i write it to the
> texture the histogram is correct.
> Does anybody have an id how to get the job done???
> regards
> stefan
>
> void Determine_Histogram()
> {
> int sum=0;
> for (int i =0 ;i<256;i++)Hist[i]=0;;
> MaxHistval=0;
> voBrickSetIterator brickSetIter(aVolume->getCurrentBrickSet());
> for (voBrick * brick; brick = brickSetIter();) {
>
> int xBrickOrigin, yBrickOrigin, zBrickOrigin;
> int xBrickSize, yBrickSize, zBrickSize;
>
> void *vdata = brick->getDataPtr();
> unsigned char *start;
> // get brick sizes -- they may different than those requested
> brick->getBrickSizes(xBrickOrigin, yBrickOrigin, zBrickOrigin,
> xBrickSize, yBrickSize, zBrickSize);
> start =(unsigned char *)vdata;
>
> for ( i =0 ;i<xBrickSize*yBrickSize*zBrickSize;i++)
> Hist[(int)*(start+i)]++;
> for ( i =0 ;i<256;i++)
> {
> sum+=Hist[i];
> if (Hist[i]>MaxHistval){MaxHistval=Hist[i];}
> }
>
> }
> printf( "Number of Voxels %d\n",sum);
> }
>
> --
> J.W.M v/d Heijden -oOo-@-@-oOo-
> XRD Predevelopment Philips Medical Systems
> Building QJ2327, Veenpluis 2, Best, The Netherlands
> Phone: +31-40-2762275 Fax : +31-40-2765657
> mailto:Stefan.vdHeijden@best.ms.philips.com
> http://members.xoom.com/AxeCrazy
> Just a memory remains....
>
>-- End of excerpt from Stefan van der Heijden
This archive was generated by hypermail 2.0b2 on Mon Nov 01 1999 - 14:11:13 PST