闲话不说,直接上代码与图的效果!
AngleD=59; %[-90 90]c=20:80;centralPoint=[50 50]';image=zeros(100,100);image(25:74,25:74)=ceil(abs(rand(50,50).*10));if abs(AngleD)==90, fprintf(1,'no single line for the x area\n');elseif AngleD==0, r=centralPoint(1).*ones(size(c,2),1);else k=tand(AngleD); b=centralPoint(1)-k*centralPoint(2); r=k.*c+b;endimagesc(image);hold onplot(c,r,'r-');hold off;colormap gray;axis equal