EZvNIcircle.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. % Disk Image
  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. %radius=14;
  21. diaExt=2*(radius+1);
  22. circBoxA=zeros(diaExt,diaExt);
  23. center=[radius+2, radius+2];
  24. [m n ]=size(circBoxA);
  25. X=bsxfun(@plus,(1:m)', zeros(1,n));
  26. Y=bsxfun(@plus,(1:n), zeros(m,1));
  27. cirMask=sqrt(sum(bsxfun(@minus,cat(3,X,Y),reshape(center,1,1,[])) .^2,3))<=radius;
  28. area=pi*radius^2;
  29. cirPixA=nnz(cirMask);
  30. optCirMask=double(cirMask);
  31. optCirMask(optCirMask==0)=0.8;
  32. % Foto Circle Fram(e)
  33. expansion=2;
  34. radExpan=radius+expansion;
  35. FdiaExt=2*(radExpan);
  36. circBoxA=zeros(FdiaExt,FdiaExt);
  37. center=[radExpan+1, radExpan+1];
  38. [m n ]=size(circBoxA);
  39. X=bsxfun(@plus,(1:m)', zeros(1,n));
  40. Y=bsxfun(@plus,(1:n), zeros(m,1));
  41. FcirMask=sqrt(sum(bsxfun(@minus,cat(3,X,Y),reshape(center,1,1,[])) .^2,3))<=radExpan;
  42. % FcirPixA=nnz(cirMask);
  43. FoptCirMask=double(FcirMask);
  44. FoptCirMask(FoptCirMask==1)=2;
  45. % FoptCirMask(FoptCirMask==0)=1;
  46. % Combine Masks to create circular boundry
  47. padOptCirMask=padarray(optCirMask,[expansion-1 expansion-1],0.8);
  48. FoptCirMask=FoptCirMask .* padOptCirMask;
  49. FoptCirMask(FoptCirMask==1.6)=0.8;
  50. FoptCirMask(FoptCirMask==0)=1;
  51. FoptCirMask(FoptCirMask==2)=1;
  52. % imagesc(cirMask)