90 likes | 262 Views
Lesson 3. 找一直線的的二個端點. clear; close ; img(1:300,1:100)=uint8(0); imshow (img);. for ii=1:300 for jj=1:ii img(ii,jj)=255; end end imshow(img);. clear; close ; img1=ReadImage('c:line.bmp'); imshow(img1); img2 = RGB2Gray(img1);
E N D
clear; close; img(1:300,1:100)=uint8(0); imshow(img);
for ii=1:300 for jj=1:ii img(ii,jj)=255; end end imshow(img);
clear; close ; img1=ReadImage('c:\line.bmp'); imshow(img1); img2 = RGB2Gray(img1); figure(); ShowImage(img2, 'Gray Level Image'); img3=im2bw(img2,0.5); figure(); ShowImage(img3, 'Black and White Image');
[m n]=size(img3) quit_loop=%F; tic for ii=1:1:m for jj=1:1:n if (img3(ii,jj)==%F & quit_loop==%F) then ansii=ii ansjj=jj quit_loop=%T; end end end toc