Monday, October 30, 2006

Visualizing Intensity Profiles

After completing the conversion of the itkMesh to a vtkPolyData and the calculation of the normals from the mesh, I started working with the intensity profile visualizer to analyze what the intensities look like. I was able to pass the class my itkMesh and vtkMesh directly to set up the visualization. The normals were read in from a file that I had made from the registration process, although this can be changed to get the normals directly from the mesh being looked at. One issue that needed to be dealt with was the offset of the mesh to make sure that it was in range with the image to calculate the intensities. I had kept getting a segmentation fault error that was probably due to the points in the mesh out of the image’s range. Adding an offset to each point in the mesh was able to help keep the mesh in range of the image. There were also some issues with the cells being undefined at certain points that has to due with how I initialized them and the count that I used to iterate through the points.

I was able to view some of the intensity profiles as seen in the above pictures of my three-dimensional ring that uses triangular faces on the edge to get normals to use to find the intensities at certain areas in the image. These initial profiles are not uniformly distributed throughout the image because the points could be better positioned around the skull area. To find the optimal value I will need to run the registration process again using the points to figure out the best possible position so as to get a better idea of where I can extract a general shape of the intensity profiles of the image.

Sunday, October 29, 2006

Mesh Conversion And Normals

To calculate the normals in the mesh created in the registration process, I converted the itkMesh into a vtkPolyData so that I could use vtkPolyDataNormals to easily find the face normals. ITK has some already made classes like itkMeshTovtkPolyData that contained a class to complete the process. I tried to implement an instance of the class to convert my itkMesh, but ran into problems with the itkMeshTovtkPolyData class complaining that the itkMesh that I was passing was of const type. Therefore, I added the functions that I needed directly into the itkIntensityProfileMetric class. I confirmed that the itkMesh had been converted to a vtkPolyData by checking the number of points and cells. Once this had been completed, I set out to calculated the normals for use in the itkIntensityProfileMetric and the GUI that displays the intensities for the faces of the mesh. However, I kept getting an error from the vtkPolyDataNormals class that stated there has been a segmentation fault. This may be due to the vtkPolyData that I created not having enough information to be considered a true Mesh or some the fields are not instantiated correctly.

Because of the problems that I encountered with the vtkPolyDataNormals class, I just calculated the normals myself. I accomplished this by storing the points in a double matrix then iterated through the triangle cells and computed the normal vector from the three points stored in each cell. Once the normals were computed I stored them in their own double matrix and made them unit vectors by dividing them by their length. After storing the normal vectors, I outputted them to a file for use in the intensity profile viewer. Incorporating the normals and the mesh into the viewer involves changing the way the viewer inputs meshes from .wrl files to just passing it a completed itkMesh or vtkPolyData.