- Timestamp:
- 02/22/10 00:53:34 (2 years ago)
- Files:
-
- 1 modified
-
branches/2010-image-rec/hist_test.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/2010-image-rec/hist_test.m
r698 r699 1 1 function hist_test(fn) 2 2 3 show_images = 0;3 show_images = 1; 4 4 5 5 if show_images 6 6 close all; 7 %fn = 'images/course-walk/cimg4943.jpg'; 8 %fn = 'images/course-walk/cimg4921.jpg'; 9 fn = 'images/elphel/cam-000078.jpeg'; 10 %fn = 'images/elphel/cam-000086.jpeg'; % Hard image 11 %fn = 'images/course-walk/cimg4989.jpg'; 12 %fn = 'images/elphel-09/test29.jpg'; 7 8 9 %fn = 'images/elphel/cam-000086.jpeg'; % Hard image, example of failure 10 11 %fn = 'images/elphel/cam-000087.jpeg'; 13 12 %fn = 'images/elphel/cam-000094.jpeg'; 14 13 %fn = 'images/elphel/cam-000081.jpeg'; … … 61 60 % Area at the bottom of the image assumed to be grass, clear of obstacles 62 61 clear_area = im(round(clear_area_top * rows):end, ... 63 round(clear_area_left * cols): ...64 round((1 - clear_area_left) * cols), :);62 round(clear_area_left * cols): ... 63 round((1 - clear_area_left) * cols), :); 65 64 66 65 % Histograms of each channel … … 155 154 right_x = round((1 - clear_area_left) * cols); 156 155 line([left_x right_x right_x left_x left_x], ... 157 [top_y top_y bottom_y bottom_y top_y],'LineWidth',4,'Color','red');156 [top_y top_y bottom_y bottom_y top_y],'LineWidth',4,'Color','red'); 158 157 scatter(bottomlist(:,1), bottomlist(:,2), '.'); 159 158 … … 171 170 axis on, axis normal, hold on; 172 171 P = houghpeaks(H,2,'NHoodSize',[161,161],'Threshold',ceil(0.5*max(H(:)))); 173 x = T(P(:,2)); 172 x = T(P(:,2)); 174 173 y = R(P(:,1)); 175 174 plot(x,y,'s','color','white'); … … 181 180 figure('Name','Hough lines'), imshow(im_rgb), hold on 182 181 for k = 1:length(lns) 183 xy = [lns(k).point1; lns(k).point2];184 plot(xy(:,1),xy(:,2),'LineWidth',8,'Color','blue');185 186 % plot beginnings and ends of lines187 plot(xy(1,1),xy(1,2),'x','LineWidth',8,'Color','yellow');188 plot(xy(2,1),xy(2,2),'x','LineWidth',8,'Color','red');182 xy = [lns(k).point1; lns(k).point2]; 183 plot(xy(:,1),xy(:,2),'LineWidth',8,'Color','blue'); 184 185 % plot beginnings and ends of lines 186 plot(xy(1,1),xy(1,2),'x','LineWidth',8,'Color','yellow'); 187 plot(xy(2,1),xy(2,2),'x','LineWidth',8,'Color','red'); 189 188 end 190 189 … … 198 197 199 198 function rgb = bw2rgb(bw) 200 rgb = zeros(size(bw, 1), size(bw, 2), 3);201 rgb(:,:,1) = bw;202 rgb(:,:,2) = bw;203 rgb(:,:,3) = bw;199 rgb = zeros(size(bw, 1), size(bw, 2), 3); 200 rgb(:,:,1) = bw; 201 rgb(:,:,2) = bw; 202 rgb(:,:,3) = bw; 204 203 end 205 204 206 205 function bottomlist = bottomFind(bw) 207 list = zeros(size(bw,2),2);208 for i = 1:size(bw,2)209 bw(1,:) = 1;210 list(i,2) = find(bw(:,i) == 1, 1, 'last');211 list(i,1) = i;212 end213 214 bottomlist = list(list(:,2) ~= 1, :);215 216 end 206 list = zeros(size(bw,2),2); 207 for i = 1:size(bw,2) 208 bw(1,:) = 1; 209 list(i,2) = find(bw(:,i) == 1, 1, 'last'); 210 list(i,1) = i; 211 end 212 213 bottomlist = list(list(:,2) ~= 1, :); 214 215 end

