NIcircle.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. %% CALLED BY par4Gbl_Main8c.m %%
  2. %{
  3. %Imaging ToolBox method
  4. r=14;
  5. A=zeros(70,70); %(fIntsc(refPtR:(refPtRExt),refPtC:(refPtCExt)))
  6. m={40,40};
  7. A(m{:})=1;
  8. B=imdilate(A,strel('disk',r,0) );
  9. imshow(B)
  10. area=pi*r^2
  11. clear all
  12. %}
  13. %without Image Proc. Toolbox
  14. %r=14;
  15. %A=zeros(70,70);
  16. %A=zeros(r,r);
  17. %P=[40,40];
  18. %center=[refPtR+ round(.5*width), refPtC+ round(.5*width)];
  19. %A=zeros(70,70);
  20. %---------------------------------------------------------------------
  21. %radius=14;
  22. diaExt=2*(radius+1);
  23. circBoxA=zeros(diaExt,diaExt);
  24. center=[radius+2, radius+2];
  25. [m,n]=size(circBoxA);
  26. X=bsxfun(@plus,(1:m)', zeros(1,n));
  27. Y=bsxfun(@plus,(1:n), zeros(m,1));
  28. cirMask=sqrt(sum(bsxfun(@minus,cat(3,X,Y),reshape(center,1,1,[])) .^2,3))<=radius;
  29. area=pi*radius^2;
  30. cirPixA=nnz(cirMask);
  31. optCirMask=double(cirMask);
  32. optCirMask(optCirMask==0)=0.8;
  33. % Foto Circle Fram(e)
  34. expansion=2;
  35. radExpan=radius+expansion;
  36. FdiaExt=2*(radExpan);
  37. circBoxA=zeros(FdiaExt,FdiaExt);
  38. center=[radExpan+1, radExpan+1];
  39. [m, n ]=size(circBoxA);
  40. X=bsxfun(@plus,(1:m)', zeros(1,n));
  41. Y=bsxfun(@plus,(1:n), zeros(m,1));
  42. FcirMask=sqrt(sum(bsxfun(@minus,cat(3,X,Y),reshape(center,1,1,[])) .^2,3))<=radExpan;
  43. %FcirPixA=nnz(cirMask);
  44. FoptCirMask=double(FcirMask);
  45. FoptCirMask(FoptCirMask==1)=2;
  46. %FoptCirMask(FoptCirMask==0)=1;
  47. %********Combine Masks to create circular boundry************
  48. padOptCirMask=padarray(optCirMask,[expansion-1 expansion-1],0.8);
  49. FoptCirMask=FoptCirMask .* padOptCirMask;
  50. FoptCirMask(FoptCirMask==1.6)=0.8;
  51. FoptCirMask(FoptCirMask==0)=1;
  52. FoptCirMask(FoptCirMask==2)=1;
  53. %---------------------------------------------------
  54. %imagesc(cirMask)