
function validMatrix = makeValidMatrix(Sample,i,j,width)
%% 
%%

validMatrix = ones(width);
sample = getSample(Sample,i,j,width);

for ii=i:i+width-1,
  for jj=j:j+width-1,
    vi = ii-i+1;
    vj = jj-j+1;    

    %% boundary conditions
    if ( ii < 1 | jj < 1 | ii > size(Sample,1) | jj > size(Sample,2) )
      validMatrix(vi,vj)=0;
    end
    if(sample(vi,vj)<0)
      validMatrix(vi,vj)=0;
    end
  end
end


