有谁能告诉我for
- 循环中发生了什么?
%find slopes of each line
m1 = diff(line1_start_end_points(:,2))/ diff(line1_start_end_points(:,1))+0.1/(2*pi);
m2 = diff(line2_start_end_points(:,2))/ diff(line2_start_end_points(:,1))+0.1/(2*pi);
m3 = diff(line3_start_end_points(:,2))/ diff(line3_start_end_points(:,1))+0.1/(2*pi);
%====================find longest scratch on each line==========================
if (line1_flag==0)
x = line1_start_end_points(1,1);
y = line1_start_end_points(1,2);
% iterate through the height of the image
for i=1:COLS
final_line1(:,i)=[y + m1*(i-x) i]';
gray_image_copy1(floor(y+m1*(i-x)), i) = 255;
hough_in_new1(:,i)=0;
hough_in_new1(floor(y+m1*(i-x)),i)=1;
end
end
.... .... ....
.... .... ....
答案 0 :(得分:1)
似乎是在灰度图像和零数组上逐个像素地绘制直线:
if (line1_flag==0)
% x coordinate of line start
x = line1_start_end_points(1,1);
% y coordinate of line start
y = line1_start_end_points(1,2);
% iterate through the height of the image
for i=1:COLS % iterate on image columns (x's), i is like variable x
% compute the y value for this column using y = mx + b, where
% (i) is the x coordinte, and j=(y + m1*(i-x)) is the y coord.
j = y + m1*(i-x);
final_line1(:,i)=[j i]';
% draw this x-y pixel in white on the image, floor j to nearest
% integer - results in 255's where the line is
gray_image_copy1(floor(j), i) = 255;
% reset all hough array i'th column
hough_in_new1(:,i)=0;
% set only the j,i element to 1 - results in 1's where the line
% is
hough_in_new1(floor(j),i)=1;
end
end