function [smip,ww3,mk,NNx,NNy,dD]=calcsmip(D,w,Nx,Ny,part);


dD=fix((D+1)/2)*2;                        % next largest even integer 
[xxs yys]=ndgrid(-dD/2:dD/2,-dD/2:dD/2);  % particle grid
smip=ipf(abs(xxs+i*yys),D,w);             % Calculate ideal image. Use ci=(1-tanh((abs(cr)-D/2)*w))/2; for small speedup.
if (nargout>1)
  bb1=ones(Nx,Ny);                          % Blank image;
  ww3=(conv2l(bb1,smip.^3,'full'));         % Weighting factor
  
  mk=conv2l(bb1,smip,'full')./sum(smip(:))>part;  % fraction of particle to consider on edge

  [NNx NNy]=size(ww3);                            % size of full images
end