luminance question

hi everyone. im trying to build a data structure for inputting some medical imagery and in order to subdivide relevant parts of my structure i would like to only use certain luminance levels found (in other words pick out the bright bits) but id like to be able to set a certain threshold value. Does anyone know the best way (if any) of doing this? a speedy response would be much appreciated.
kind regards in advance
tony

Don’t really see the point, please define “data structure”.

Is that what you meant ?
Some pseudocode :

initialise structure bright part
initialise structure dim part

for (each data element on imagery)
    if (element.brightness > threshold) {
        store element in structure bright part.
    } else {
        store element in structure dim part.
    }

well its an octree data structure and its going to be holding dicom data sets. (splices from an ultrasound to be precise). these data sets basically show dark and bright regions. the bright regions are the tissue/ veins and are my primary concern. im subdividing nodes in my octree and want to only subdivide those of relevance.so i need to specify as you’ve shown there a threshold, and only show white parts of the data. hope this isnt too much gobbledygook.

I’m not sure what you want to do exactly.

If you have volumetric data and want to draw a surface at some treshold value (this is called isosurface), you may want to google for the marching cubes algorithm. I’m sure there are plenty tutorials around.

i dont want to use marching cubes since im volume rendering and not surface rendering. ok i’ll try another approach. how can i produce test data with 3 dimensions (say h,j,k) using unsigned ints to display a simple oblong which is white (background is black) then only subdivide the nodes that contain the white areas (i have the algorithm for subdivision written)

Just iterate over all data points in a node. There are 3 cases:

  1. All points are black: leave it
  2. All points are white: leave it
  3. Some points are black, some are white: subdivide it further, and apply the same algorithm to the child nodes

but how do i tell it whats white and whats black? im unsure about how to put this into an argument. sure i want it to know black from white. but i also want to set the threshold, say 30-90 for arguments sake, then say 30-40 is orange, 40-50 is yellow, etc etc. i cant find anything anywhere that lets me select a threshold, or any C++ code that helps me. please anyone?

hi again.
does anyone know anything about tesseral addressing?
say i have a tesseral address 0000333
how would i go about reading this into an array. then putting it into a loop and depending on each digit i recursively work through, moving a set amount in the x, y, or z direction. any help is greatly appreciated

Cool, I didn’t know that this encoding had a name. First Google hit: http://www.csc.liv.ac.uk/~frans/OldResearch/dGKBIS/tesseral.html

From the look of it it’s just a decomposition of N-space into identical hyper-spaces.

Ok, your address looks like a quadtree:
Load your number digit by digit into an array of unsigned chars. The number of digits gives the subdivisions.
If you start at the center of the biggest quad, the next subdivided quad is in one of four directions, indexed with 0 to 3.
You need to figure out which ID is which sub-quad from your data.
Let’s say the distances in x and y to go into the center of the biggest quad was 1.0 (unit quad around origin from -1.0 to 1.0).
Then the first subdivision step needs to go distance *= 0.5 from there.
The index decides the direction vector, the distance is halved each subdivision step.
The last center describes your pixel coordinate in the -1.0 to 1.0 coordinate space.

Same with octrees just that addresses have digits from 0 to 7 and the final element is a voxel.

Pretty basic stuff.

ok i understand…i think…not so basic stuff for a beginner though.
say ive read in from a file a list of addresses. put them into an array.

 void LoadAddresses()
{
        g_pVertices[].

	FILE *fp = fopen(FILE_NAME, "r");

	if(!fp) 
		MessageBox(NULL, "Can't Open File", "Error", MB_OK);


	CVector3 vTemp;

	while(1)
	{
		int result = fscanf(fp, "%f
", &vTemp);
		if(result == EOF) 
			break;

		// Increase the address count
		g_NumberOfAdds++;
	}
	g_pAddresses = new CVector3 [ g_NumberOfAdds ];
	rewind(fp);
	int index = 0;

	for(int i = 0; i < g_NumberOfAdds; i++)
	{
		fscanf(fp, "%f
", &g_pAddresses[ index ]);

		index++;			
	}
	fclose(fp);
} 

how do i then put each address into a separate array then access each integer/char in that address?
say i have 0000377 as an address (its an octree)
how would i access each int to do what you’ve described? or would it be better to do it whilst reading it from the file? help please as im quite stuck.