prog2 - Computer Science 130B Winter 2012 Programming...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computer Science 130B Winter 2012 Programming Assignment #2 Due: 4:00pm, Friday, February 10 In this and the next programming assignments, we are going to consider a problem that arises in medical image visualization, or more specifically, that of visualizing the surface structure in between parallel slices of anatomical data. For example, computer tomography (CT) gathers anatomical data as a collection of parallel slices. The Visible Human Project of the National Library of Medicine collects transverse CT, MRI, and cryosection images of representative male and female cadavers at one millimeter intervals. If a transverse scan (from head to toe) is performed on the human body, the arm and leg bone structures will be imaged in many parallel slices. It often of interest to generate 3D description of these anatomical structures from slices. Suppose that each slice is recorded in a digital format as a 2D image. Furthermore, suppose that certain image processing algorithm has been applied to locate the boundary, say, between a bone and the surrounding tissue. Then to obtain a 3D surface description of the bone in between two adjacent slices, bone-tissue boundaries in adjacent slices are interpolated to generate a surface description (e.g., see Figure 1). Mathematically, the problem can be stated as follows: You are given two parallel planes, P1 and P2 , with P1 on top of P2 . On each plane, you have an ordered sequence of points which, when connected together, form a closed, simple (non-intersecting) contour. The contours may have different number of points though and there is no requirement that the points should “line up” in any manner. The number of points on the contour on P1 is m and that on P2 is n, where m ≥ 1 and n ≥ 1. Then the set of points on P1 are: 1 1 1 (x1 , y0 ), (x1 , y1 ), · · · , (x1 −1 , ym−1 ) , 0 1 m and those on P2 are 2 2 2 (x2 , y0 ), (x2 , y1 ), · · · , (x2 −1 , yn−1 ) . 0 1 n Assume z 1 = 1 and z 2 = 0 for convenience. Your task is to design a greedy triangulation algorithm in between the boundary points on these two planes (again, see Figure 1). The goal is to form a closed surface in between the two contours satisfying the following constraints: • Only triangles are used as building elements. • These triangles use points on P1 and P2 as their vertices. • The triangulation result should be such that the collection of triangles form a closed (no holes) surface in between the two contours. • The total area of these triangles should be as small as possible. 1 1 The area of a triangle, expressed in terms of its three edge lengths a, b, and c is: s(s − a)(s − b)(s − c) , where s = a+b+c . 2 i 111111111 000000000 11111111111111111111111111111 00000000000000000000000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 00 111111111 000000000 111111111 000000000 11 1 00 0 111111111 000000000 111111111 000000000 11 00 0 111111111 000000000 111111111 000000000 11 m-10000 1 2 ... 00 111111111 000000000 1111 111111111 000000000 111 000 11 00 111111111 1111 000000000 0000 111111111 000000000 111 000 11 00 11111 00000 111111111 1111 111 11 000000000 0000 000 00 111111111 000000000 111 111 000 000 11111 00000 111111111 1111 111 11 000000000 0000 000 00 111111111 000000000 111 111 000 000 1 11111 00000 111111111 1111 111 11 000000000 0000 000 00 111111111 000000000 111 111 000 000 1111111111111111111111111111 0000000000000000000000000000 11111 11 00000 00 1111 111 0000 000 111 111 000 000 11111 11 00000 00 1111 111 0000 000 111 111 000 000 11111 11 00000 00 1111 111 0000 000 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 11111 00000 111 111 000 000 111111111 1111 111 11 000000000 0000 000 00 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 11 000000000 0000 000 00 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 11 000000000 0000 000 00 111111111 000000000 11111 00000 1111 111 11 0000 000 00 111 111 000 000 111111111 1111 000000000 0000 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 j 11111 00000 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 11111 00000 111 111 000 000 111111111 1111 000000000 0000 111111111 000000000 111 000 11111 00000 ... 111 111 000 000 111111111 1111 111 000000000 0000 000 111111111 000000000 11111 00000 111 111 000 000 111111111 000000000 111111111 000000000 11111 00000 111 111 000 000 2 111111111 000000000 111111111 000000000 111111111 000000000 111111111 000000000 01 2 n-1 111111111 000000000 111111111 000000000 1111111111111111111111111111 0000000000000000000000000000 P ... ... P Figure 1: Triangulation in between two parallel planes For this homework, you can assume that only two slices are given and only one contour per slice. The input data will be of the following format: m, n 1 x1 , y 1 , 1 1 1, y1 , 1 x2 2 ··· 1 x1 , y m , 1 m 2, y2 , 0 x1 1 2 x2 , y 2 , 0 2 ··· 2 x2 , y n , 0 n //number of points on the f irst and second contours //f irst point on the f irst contour //second point on the f irst contour //last point on the f irst contour //f irst point on the second contour //second point on the second contour //last point on the second contour Your output should be in the following format: i11 , i12 , i13 //f irst triangle i21 , i22 , i23 //second triangle ··· it1 , it2 , it3 //last triangle where ik1 , ik2 , ik3 are the index numbers of the three vertices of the k-th triangle. If a vertex is drawn from the first contour, then the index number is exactly what it is shown above. If a vertex is drawn from the second contour, then the index number is the index number shown above plus m. (I.e., the first vertex on the second contour will be m + 1, the second vertex on the second contour will be m + 2, and so on so forth.) Also, note that the vertex number starts from 1 not 0. All these are to make sure that you can use Matlab for visualization (try trimesh or trisurf in Matlab). For example, if m = 4 and n = 4, and both contours are made of the following points: (0, 0), (0, 1), (1, 0), (1, 1) 2 1.9 1.8 2 1.7 1.8 1.6 1.6 1.5 1.4 1.4 1.2 1.3 1 0 1 0.2 1.2 0.8 0.4 1.1 1 0 0.6 0.6 0.4 0.8 0.5 1 1.5 2 2.5 3 3.5 4 0.2 1 (a) 0 (b) Figure 2: Triangulation in between two parallel planes, and the contours on both planes are square: (a) Triangles displayed in between two index lists and (b) triangles displayed in between actual 3D points. Then, the input file will look like: 44 001 011 111 101 000 010 110 100 and a valid algorithm might generate results as shown in Figure 2 with the following output: 1 6 2 7 3 8 4 5 2 5 3 6 4 7 1 8 6 1 7 2 8 3 5 4 A slightly more complicated example, where the contours on both P1 and P2 are unit circles, but the contour on P1 is made of 15 points while that on P2 is made of twice as many points, with contour points distributed evenly around the circle in both cases, is shown in Figure 3. 2 1.9 1.8 1.7 2 1.6 1.5 1.5 1.4 1 −1 1.3 1 −0.5 0.5 1.2 0 0 1.1 0.5 1 0 5 10 15 (a) 20 25 30 −0.5 1 −1 (b) Figure 3: Triangulation in between two parallel planes, and the contours on both planes are circle: (a) Triangles displayed in between two index lists and (b) triangles displayed in between actual 3D points. Your algorithm must be a greedy one, i.e., you must use a feasibility constraint and an optimality constraint. Your algorithm must make decision one triangle at a time, and you must not back track once a decision has been made. In addition to the program, you should turn in written answers to the following questions: 1. Give a pseudo-code algorithm of your program. What is the time complexity of your algorithm? 2. Explain clearly and concisely what feasibility constraint you impose during the solution of this problem. 3. Will your algorithm always generate the optimal triangulation? If so, prove it. If not, give a counter example. NOTE: This is a problem that allows many different solutions. As we will see, we are going to solve this problem again using dynamic programming. The purpose of solving the same problem over and over again is not to bore you to death, but to afford you a chance to formulate solutions using different design criteria, and to compare the strength and limitation of different algorithm design techniques. ...
View Full Document

Ask a homework question - tutors are online