function deteccion(imo,um_vm,um_st) % Deteccion version 5 % Divide la imagen y aplica el algoritmo a cada una % de las imagenes. close all imo=double(imo); imd=double(imo); [xmax, ymax]=size(imo); lim=divide(imo,50); medio=round(xmax/2) n=10; re=12; for k=0:1 a1=1+k*medio a2=medio +k*medio for h=1:length(lim)/2 % Reccorro las zonas de interes im=imo(a1:a2,lim(2*h-1):lim(2*h)); h vmedio=mean(mean(im(:,1+n:end-n))); % Calculo de Valor medio para el umbral. der=std(std(im(:,1+n+5:end-n-5))); oscuro=der>um_vm; if oscuro um=vmedio; imb=im0; imm=imm(2:end-1,2:end-1); bor=imb-imm; bor(:,1:1+n)=0; %Recorte. bor(:,end-n:end)=0; [i,j]=find(bor); per=length(i); re=round(per/(2*pi)); % Radio estimado [a,b,r]=hough2(bor,re); imd=bresen(imd,a+k*medio,lim(2*h-1)+b,r,300); else if der > um_st im=im(:,1+n:end-n); um = vmedio - std(std(im))/3; imb=im0; imm=imm(2:end-1,2:end-1); bor=imb-imm; bor(:,1:1+5)=0; %Recorte. bor(:,end-5:end)=0; [a,b,r]=hough(bor,re) imd=bresen(imd,a+k*medio,lim(2*h-1)+n+b,r,300); end end end end figure imagesc(imd)