预览加载中,请您耐心等待几秒...
1/2
2/2

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

第PAGE页码2页/总页数NUMPAGES总页数2页hough变换检测圆的matlab程序1hough变换检测圆的matlab程序1function[y0detect,x0detect,Accumulator]=houghcircle(Imbinary,r,thresh)%HOUGHCIRCLEdetectscircleswithspecificradiusinabinaryimage.%%Comments:%FunctionusesStandardHoughTransformtodetectcirclesinabinaryimage.%AccordingtotheHoughTransformforcircles,eachpixelinimagespace%correspondstoacircleinHoughspaceandviseversa.%upperleftcornerofimageistheoriginofcoordinatesystem.%%Usage:[y0detect,x0detect,Accumulator]=houghcircle(Imbinary,r,thresh)%%Arguments:%Imbinaryabinaryimage.imagepixelsthathavevalueequalto1are%interestedpixelsforHOUGHLINEfunction.%rradiusofcircles.%threshathresholdvaluethatdeterminestheminimumnumberof%pixelsthatbelongtoacircleinimagespace.thresholdmustbe%biggerthanorequalto4(default).%%Returns:%y0detectrowcoordinatesofdetectedcircles.%x0detectcolumncoordinatesofdetectedcircles.%AccumulatortheaccumulatorarrayinHoughspace.%%Writtenby:%AminSarafraz%Photogrammetryelseifthreshsize(Imbinary,2))high=size(Imbinary,2);endforx0=low:highy01=ysqrt(r^2(xx0)^2);y02=y+sqrt(r^2(xx0)^2);y01=round(y01);y02=round(y02);ify01=1Accumulator(y01,x0)=Accumulator(y01,x0)+1;endify02=1Accumulator(y02,x0)=Accumulator(y02,x0)+1;endend%%low=xIndex(cnt)r;%high=xIndex(cnt)+r;%if(lowsize(Imbinary,2))high=size(Imbinary,2);end%forx0=low:high%y01=yIndex(cnt)sqrt(r^2(xIndex(cnt)x0)^2);%y02=yIndex(cnt)+sqrt(r^2(xIndex(cnt)x0)^2);%y01=round(y01);y02=round(y02);%ify01=1%Accumulator(y01,x0)=Accumulator(y01,x0)+1;%end%ify02=1%Accumulator(y02,x0)=Accumulator(y02,x0)+1;%end%endend%FindinglocalmaximainAccumulatory0detect=[];x0detect=[];AccumulatorbinaryMax=imregionalmax(Accumulator);[Potential_y0Potential_x0]=find(AccumulatorbinaryMax==1);Accumulatortemp=Accumulatorthresh;forcnt=1:length(Potential_y0)ifAccumulatortemp(Potential_y0(cnt),Potential_x0(cnt))>=0y0detect=[y0detect;Potential_y0(cnt)];x0detect=[x0detect;Potential_x0(cnt)];endend