Write My Paper Button

WhatsApp Widget

3D Scalar Field Visualization | My Assignment Tutor

1Assignment #3: 3D Scalar Field VisualizationDue on October 7th, before midnightGoals and Requirements:The goals of this assignment include: (1) complete the cut planes for 3D volume data, (2) extract andvisualize iso-surfaces from volumetric scalar fields, and (3) perform ray-casting direct volume rendering.Two 3D volumetric data sets in the format of image data (or uniform structured grid) are provided. Askeleton code in Python is also available to help you get started.You should submit your source code and a writing report in a single .zip file via Blackboard before thedeadline.Your report (required) should include your answers to the writing questions AND high-quality imagescaptured from the individual visualization tasks listed below for the two data sets given. Also, pleasespecify the parameters used to produce the corresponding visualization (like the iso-value for the isosurface and the configuration file for the transfer function design), especially for the bernard3D_Q dataset.Tasks:1. Writing questions (20 points)1.1 (5 points) What are the potential issues during the computation of Marching Cubes?1.2 (5 points) What is the fundamental difference between Raycasting and Splatting?1.3 (5 points) What are the limitations of Raycasting? How will you improve Raycasting?1.4 (5 points) Why designing proper transfer function for DVR is challenging?2. 3D slicing (30 points)Visualize three axis-aligned cut planes based on the user-specified locations. You can safely assume thatthese locations are integers corresponding to the indices of the XY, YZ, and XZ planes in the provideddata. For example, Z=10 defines an XY plane with all the 3D points (or voxels) that have Z index 10.You can use the following code to get the dimensions of the image data, dim = [xdim, ydim, zdim]dim = reader.GetOutput().GetDimensions()The following code shows how to specify an XY cut plane for a loaded 3D image data2# Create a mapper and assign it to the corresponding readerxy_plane_Colors = vtk.vtkImageMapToColors()xy_plane_Colors.SetInputConnection(reader.GetOutputPort())xy_plane_Colors.SetLookupTable(bwLut)xy_plane_Colors.Update()Note that bwLut is a black/white look up table that can be setup as follows. You can re-use the colorscale look up tables you created in Assignment 2 here, but this look up table must be setup first beforeit can be used. A place to set this look up table is when you load the data file (e.g., in theopen_vtk_file() function).# Create a black/white lookup tablebwLut = vtk.vtkLookupTable()# YOU need to adjust the following range to address the dynamic range issue!bwLut.SetTableRange(0, 2)bwLut.SetSaturationRange(0, 0)bwLut.SetHueRange(0, 0)bwLut.SetValueRange(0, 1)bwLut.Build()# Create an actor for the XY planexy_plane = vtk.vtkImageActor()xy_plane.GetMapper().SetInputConnection(xy_plane_Colors.GetOutputPort())xy_plane.SetDisplayExtent(0, xdim-1, 0, ydim-1, current_zID, current_zID)# Current_zID is a user-input integer within the range of [0, zdim-1]# Add the actor to the renderer (ren is a vtkRenderer object)ren.AddActor(xy_plane)The following shows a screenshot of the three selected cut planes for the FullHead data.33. Iso-surface Extraction and Visualization (20 points)Extract and visualize an iso-surface based on the user input iso-value. You can use thevtkMarchingCubes() filter to achieve that.isoSurfExtractor = vtk.vtkMarchingCubes()Once you create a marching cubes filter, you can use the similar function SetValue(0, isovalue) as you used in Assignment 2 with the contour filter, and pass the iso-value that the user inputs.To accelerate the rendering of the extracted iso-surface(s), it is recommended to use the vtkStripperto convert the individual triangles in the iso-surface into triangle strip.isoSurfStripper = vtk.vtkStripper()isoSurfStripper.SetInputConnection(isoSurfExtractor.GetOutputPort())isoSurfStripper.Update()Next, you will pass this stripper object to a vtkPolyDataMapper() mapper. Remember to call theScalarVisibilityOff() function IF you want to specify a color for the surface.Next, create an actor for the iso-surface so that you can set its color and other materials. If you wish touse the lighting effect, you can use the following functions.your_actor.GetProperty().SetDiffuseColor([the color you prefer])your_actor.GetProperty().SetSpecular(.3)your_actor.GetProperty().SetSpecularPower(20)You can also specify the transparency of the extracted iso-surfaces, which can be useful when multipleiso-surfaces are shown at the same time.your_actor.GetProperty().SetOpacity([your preferred opacity in [0, 1]])The following shows a screenshot of the iso-surface corresponding to value 500 of the FullHead data.This iso-surface represents the skin of a patient.44. DVR-Raycasting (30 points)Compute and show the volume rendering using ray-casting. To achieve that, you can use thevtkFixedPointVolumeRayCastMapper() mapper or the vtkSmartVolumeMapper()mapper. The former is the standard raycasting DVR and the latter is the improved DVR. alphacomposition will be used. Note that for DVR, there is no filter needed as no geometry will be extractedfrom the data. So, you should directly connect the loaded data from the source to ray-casting mapperusing the SetInputConnection() function of the mapper.To compute the pixel colors, both color and opacity transfer functions need to be set.The following shows an example code for the specification of the color transfer function for the FullHeaddata. The vtkColorTransferFunction is used. The AddRGBPoint() function of this class isused to add control points to the color transfer function. This function consists of four parameters, the firstone specifies the iso-value and the last three provide the RGB color you want to assign to that value.# The goal is to assign one color for flesh (between 500 and 1000)# and another color for bone (1150 and over).volumeColor = vtk.vtkColorTransferFunction()volumeColor.AddRGBPoint(0, 0.0, 0.0, 0.0)volumeColor.AddRGBPoint(500, 1.0, 0.5, 0.3)volumeColor.AddRGBPoint(1000, 1.0, 0.5, 0.3)volumeColor.AddRGBPoint(1150, 1.0, 1.0, 0.9)The following shows an example code for the specification of the opacity transfer function (which is a 1Dfunction) for the FullHead data. The vtkPiecewiseFunction is used. The AddPoint () function isused to add control points to this 1D function and provide the specific opacity values. Other opacityvalues for the data between these control points will be interpolated linear as the piecewise function isused here.volumeScalarOpacity = vtk.vtkPiecewiseFunction()volumeScalarOpacity.AddPoint(0, 0.00)volumeScalarOpacity.AddPoint(500, 0.15) #Skin is more transparentvolumeScalarOpacity.AddPoint(1000, 0.15)volumeScalarOpacity.AddPoint(1150, 0.85) #Bone get the highest opacityNOTE that for both the color and opacity functions, the above locations of control points need to beadjusted by the user interactively to achieve the best rendering effect. Also, those scalar values (e.g.,500, 1000, and 1150) are data dependent. You must replace them based of the data range of theloaded data (e.g., for the bernard3D_Q data).To facilitate the interactive specification of the above two transfer functions, a “rendering_config.txt” fileis used that has the following format:#Color0, 0.0, 0.0, 0.0500, 1.0, 0.5, 0.31000, 1.0, 0.5, 0.31150, 1.0, 1.0, 0.95#Opacity0, 0.00500, 0.151000, 0.151150, 0.85Each row under the #Color section corresponds to a control point for the color transfer function asexplained earlier. The rows under the #Opacity section are similar. During run time, the user can open thisrendering_config.txt file and modify the control points to adjust the volume rendering effect. Once the fileis modified and save, it can be reloaded by pressing the “Load control points” button on the interface (seean example interface later) or uncheck and check the “Show Volume Rendering” checkbox as currentlydone in the skeleton code.After you specify the above transfer functions, you need to add them to a vtkVolumeProperty object.The following shows an example of adding the previously defined transfer functions to the volumeproperty object.volumeProperty = vtk.vtkVolumeProperty()volumeProperty.SetColor(volumeColor)volumeProperty.SetScalarOpacity(volumeScalarOpacity)volumeProperty.SetGradientOpacity(volumeGradientOpacity)volumeProperty.SetInterpolationTypeToLinear()If you wish to add illumination (or shading) effect to your volume rendering, you can do something likethe following for your volume property object (after the above setting).volumeProperty.ShadeOn()volumeProperty.SetAmbient(0.4)volumeProperty.SetDiffuse(0.6)volumeProperty.SetSpecular(0.2)Next, you should create a volume object using vtkVolume and add the ray-casting mapper and thecorresponding volume property object to this volume object as follows.volume = vtk.vtkVolume()volume.SetMapper(volumeMapper)volume.SetProperty(volumeProperty)Finally, add this volume object to your renderer so that it can be rendered. The following provides ascreenshot of the raycasting of the FullHead data with the above setting (and the rendering_config.txtfile) for your reference.Note that if you use the vtkSmartVolumeMapper(), which is recommended, you may see different(most likely better) rendering effect.65. Graphical interface (GUI)A skeleton code with a QT GUI is provided for you to get started. The interface of the skeleton programlooks like belowThe interface for XY cut plane with the full functionality is provided to you as a reference. The interfacefor iso-surface extraction and volume rendering is also included in the skeleton code, but they currentlydo nothing as their respective functions are incomplete. You need to complete these functions asdescribed earlier to see the respective visualization.7A more complete interface MAY look like the followingBut you should make your best decision and practice for the interface design.Some simple instruction on PyQt and its widgets is provided in assignment 2 and the following smalltutorial.http://www2.cs.uh.edu/~chengu/Teaching/Fall2020/Assigns/PyQT_PyVTK%20Tutorial.pdfA more detailed instruction and reference can be found belowhttps://doc.qt.io/qtforpython/contents.htmlGrading rubric: TasksTotal points1 202 303 204 30 8The following shows a screen shot of a volume rendering for the bernard3D_Q data set for yourreference. Again, you need to play with the transfer function designed via the rendering_config.txt file toachieve a volume rendering that reveals the characteristics of this data.

Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?