function proj = GetProjection(arr, dim)
%X is horiz means second index means col number

[ny,nx] = size(arr);

if (dim == 1)
  proj = zeros(nx,1);

  for j=1:nx
    for i=1:ny
      if (arr(i,j) ~= 0 )
        proj(j) = proj(j) + arr(i,j);
      end;
    end;
  end ;
end;


if (dim == 2)
  proj = zeros(ny,1)

  for j=1:ny
    for i=1:nx
      if (arr(i,j) ~= 0 )
        proj(j) = proj(j) + arr(j,i);
      end
    end
  end 
  
end
  

