Cells In itkMesh
A log of the work I am doing at the UC Davis School Of Medicine, Neurology Department in Professor Carmichael's Lab on Brain Image Processing. Specifically, the implementation of software related to the process of Registering Images along with its visualization.
To create a set of points to represent an ellipse, I first used the equation (x2/792) + (y2/952) = 1, solving for y and inserting x-values from -79 to 79, with increments of 0.5. This created around 600 points. The problem was that the sides of the ellipse contained very few points, due to the relatively high changes in the y-direction along the left and right sides of the ellipse. Using the equation in polar coordinates resolved that problem. This was accomplished by incrementing from zero to 2π and plugging that into r2 = (792952) / (792sin2(Θ) + 952cos2(Θ)) as the angle. After converting the resulting polar coordinates into rectangular ones, I was able to create an ellipse that had a uniform spread of points along the border. The following is an image of the ellipse using the rectangular coordinate representation of the equation on the left, and the one using the polar coordinate representation on the right:
Once I had all the points stored into an itkPointSet, I tried to incorporate that into the registration process, but ended up with a segmentation fault error. Taking the itkPointSet that was the output from the spatial object filter on the old ellipse, and replacing its point data with my newly created points fixed the problem. There is some parameter on the itkPointSet that I need to set to get it to work properly. I used the function "Print( std::cout )", that is a part of each itkPointSet, to print out and compare the details of the two itkPointSet objects. The only differences were in the fields "Requested Number Of Regions" with the old point set having its value as two, and mine have a value of zero, and in the field "Reference Count" with a two for the old point set and one for mine.
I had created an itkPointSetNormal class that was derived from itkPointSet, but now it seems that the functionality I was trying to capture is already in the itkMesh class. My task was to create a point set that contained the normals along with the points. Although calculating the normals would be difficult if the object started with was more complicated than a circle. One solution is to create a ring structure made up of triangular faces that would then be used to calculate the normals of the points. The class itkMesh allows for all of the abilities of itkPointSet with the addition of cells that contain information about the connectivity of two, three, or four points. Each cell can also have a piece of data attached to it. This allows there to be cells with three points representing a face along with a normal attached as the data.
In the current registration, I am using an ellipse as the shape. So to create the ring structure, I will use the equation (x2/792) + (y2/952) = 1 which will give me a row of points that represents the boundary of the ellipse, and where all the coordinates in the z-direction are zero. Supplementing that will be a duplicate ellipse except that in this one the z-coordinates will be negative one. This permits the two ellipses to connect together through triangular faces on their perimeter. The calculations of the normals will be handled in the metric class, where the direction will be the average of the normals of the faces that are adjacent to a point.