Rose-Hulman Robotics Team

Changeset 661

Show
Ignore:
Timestamp:
02/10/10 21:45:04 (2 years ago)
Author:
taborts
Message:

added hough line finding stuff

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/2010-image-rec/hist_test.m

    r659 r661  
    77fn = 'images/elphel/cam-000086.jpeg'; % Hard image 
    88fn = 'images/course-walk/cimg4989.jpg'; 
     9fn = 'images/elphel/cam-000094.jpeg'; 
     10fn = 'images/elphel/cam-000081.jpeg'; 
    911 
    10 fn = 'images/elphel/cam-000081.jpeg'; 
    11 fn = 'images/elphel/cam-000094.jpeg'; 
    1212 
    1313fprintf('Running on %s... ', fn); 
     
    4141vedges = filter2(fsobel', imbig(:,:,texture_band)); 
    4242edges = sqrt(hedges .^ 2 + vedges .^ 2); 
    43 edges=double(imread('images/elphel/cam-000094.jpeg-sobel-v-5.png'))/255; 
     43edges=double(imread('images/elphel/cam-000081.jpeg-sobel-v-5.png'))/255; 
    4444texture = filter2(fspecial('average', 10), edges); 
    4545texture = filter2(fspecial('average', 10), texture); 
     
    124124line([left_x right_x right_x left_x left_x], ... 
    125125     [top_y top_y bottom_y bottom_y top_y]); 
     126  
     127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 
     128  
     129 [H,T,R] = hough(line_mask); 
     130       imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit'); 
     131       xlabel('\theta'), ylabel('\rho'); 
     132       axis on, axis normal, hold on; 
     133       P  = houghpeaks(H,5,'NHoodSize',[161,161])%ceil(0.3*max(H(:)))); 
     134       x = T(P(:,2));  
     135       y = R(P(:,1)); 
     136       plot(x,y,'s','color','white'); 
     137  
     138  lines = houghlines(line_mask,T,R,P,'FillGap',5,'MinLength',7); 
     139       figure, imshow(im_rgb), hold on 
     140       max_len = 0; 
     141       for k = 1:length(lines) 
     142         xy = [lines(k).point1; lines(k).point2]; 
     143         plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green'); 
     144  
     145         % plot beginnings and ends of lines 
     146         plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow'); 
     147         plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red'); 
     148  
     149         % determine the endpoints of the longest line segment  
     150         len = norm(lines(k).point1 - lines(k).point2); 
     151         if ( len > max_len) 
     152           max_len = len; 
     153           xy_long = xy; 
     154         end 
     155       end 
     156  
     157       % highlight the longest line segment 
     158       plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','cyan'); 
     159  
     160  
     161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    126162 
    127163fprintf('Done\n');