function mB= MirrorFeature(nI,nJ, B)
% Creates Miror image of a feature.
% nI and nJ are ropws and cols of the original image
% B is a column vector of (nI+1)*(nJ+1) dimensions.
% See README for explanation of how features are represented
% as column vectors
  
  nI = nI+1; % rows in zero patched image
  nJ = nJ+1; % cols in zero patched image  

  % find all non-zero points in B and figure out their row and col
  % positions in the unppaded image
  points = find(B ~=0 );
  cols = ceil(points./nI) ;
  rows = points - nI*(cols -1) ;
  if sum(rows < 1) | sum(rows > nI) | sum(cols < 1) | sum(cols > nJ) 
    mB = [];
    return;
  end
  values = B(points);
  
  mB=zeros(nI*nJ,1);
  cols = nJ -cols+1;
  for i=[1:length(points)]
    index =  (cols(i) -1)*nI +  rows(i);
    mB(index) = -1*values(i);
    
  end
















  
