% DIGIFILTER_circR 

% === PREPARE VARIABLES ===
b=1; j=0;
rad=RA(end);
X=[]; CT=[]; RA=[];
t=linspace(0,2*pi,32);
co=cos(t); si=sin(t);

% === MESSAGE ===
hat=text(0,-20,'Press <ESC> to finish series.','Fontsize',14,'Color','b');


% === DIGITIZE ===
while b<27   
   [x,y,b]=ginput(1);
   if b==1,
      j=j+1;
      CT(j,:)=[x y]; 
      plot([x],[y],'.b');
      r=rad;
      plot(CT(j,1)+r*co,CT(j,2)+r*si,'m')
      RA(j)=r;
    end
    if (b==99)|(b==67),
        
    end   
end
 J=j;
 
[Ny,Nx]=size(At);
[x,y]=meshgrid(1:Nx,1:Ny);

%MASK=logical(0*MASK);
for j=1:J
MASK=MASK + inpolygon(x,y,CT(j,1)+RA(j)*co,CT(j,2)+RA(j)*si);
end

% === DISPLAY ===
MASK=min(MASK,1);
MAC(:,:,1)=MASK;

image(uint8(FTC*220 +35*MAC) );
SHOW=1;
set(HHHL.buttonTOGGLEFILTER,'String','SHOW FILTER');

delete(hat);
