function [i,j] = pinholemap_2d(u, v, P, kr, ic, jc)
	if nargin < 4
		kr			= [0 0];
		ic			= 512;
		jc			= 512;
	end

	S				= size(u);
	N				= numel(u);
	uv_tilde		= [u(:) v(:) ones(N,1)]';
	ij_tilde		= P * uv_tilde;
	i				= reshape(ij_tilde(1,:) ./ ij_tilde(3,:), S);
	j				= reshape(ij_tilde(2,:) ./ ij_tilde(3,:), S);
	
	% undistort
	rsq			= (i - ic).^2 + (j - jc).^2;
	i				= ic + (i - ic).*(1 + kr(1)*rsq + kr(2)*rsq.^2);
	j				= jc + (j - jc).*(1 + kr(1)*rsq + kr(2)*rsq.^2);
end