Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vertices=radon2vertices(radonpts)
- #converts the radon points in the format offset,angle (from +ive yaxis) to y=ax+b form
- line_cts=[tan((-radonpts(:,2)).*pi/180),radonpts(:,1)./cos(radonpts(:,2).*pi/180)];
- #we now have a set of 4 y=ax+b type line eqations
- #each line should intercept three others, two of the interception points will be vertices of the screen
- #one further interception point will usually be present due to the perspective effects
- #we need to probe the six different possible combinations, giving sixinterception points
- points(1:3,1)=(line_cts(2:4,2).-line_cts(1,2))./(line_cts(1,1).-line_cts(2:4,1));#line one intersections
- points(4:5,1)=(line_cts(3:4,2).-line_cts(2,2))./(line_cts(2,1).-line_cts(3:4,1));#line two intersections
- points(6,1)=(line_cts(4,2).-line_cts(3,2))./(line_cts(3,1).-line_cts(4,1));#lines three and four intersection
- #these are the x co-ordinates of our interception points, now calculate y
- points=[points(1:3,1),points(1:3,1).*line_cts(1,1).+line_cts(1,2);points(4:5,1),points(4:5,1).*line_cts(2,1).+line_cts(2,2);points(6,1),points(6,1)*line_cts(3,1)+line_cts(3,2)];
- #we now have the six intercept points, and 4 line equations, the next stage is to solve for the 4 sided polygon
- #we start by marking each point that has a point either side of it along one of the lines
- pointsmarks=zeros(6,1);#in the consecutive order they were defined
- lookp=[1,2,3;1,4,5;2,4,6;3,5,6];#lookup table for the positions in the pointsmark list
- #now check lines, this is a little bit complex due to the way the line combinations are generated
- for k=1:4 #loop over the three remaining lines
- [res,order]=sort(points(lookp(k,1:3),1));
- pointsmarks(lookp(k,order(2)))=1;#mark the middle point
- endfor
- #the points are now marked, we should find that there are three marked points(one has been marked twice)
- #of the non marked points, we eliminate the two on lines that pass through three marked points
- m=1;
- for n=1:6 #loop through the 6 points
- pointsonlines=0;
- if pointsmarks(n)==0 #an unmarked point - all the points that need to be removed will be unmarked
- for k=1:4 #loop over the three remaining lines
- if find(n==lookp(k,1:3))
- pointsonlines+=sum(pointsmarks(lookp(k,1:3)));
- endif
- endfor
- endif
- if(pointsonlines<3) #if theres are less than 3 marked middle points on the lines connected to the vertex
- vertices(m,:)=points(n,:);
- m+=1;
- endif
- endfor
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement