Computed tomography (CT) streak artifacts caused by metal implants have long been recognized as a problem that limits various applications of CT imaging. An effective and robust algorithm is highly desirable to minimize metal artifacts and achieve clinically acceptable CT images. In this work, the raw projection data is viewed as "incomplete" in the presence of metal shadows. Shape and location of metal objects are automatically identified and used as prior knowledge for accurate segmentation of metal shadows in projection domain. An iterative algorithm based on constrained optimization is then used for the image reconstruction. This algorithm minimizes a quadratic penalized smoothness measure function of the image, subject to the constraint that the estimated projection data is within a specified tolerance of the available metal-shadow-excluded projection data, with image non-negativity enforced. The constrained minimization problem is optimized through the combination of projection onto convex sets (POCS) and steepest gradient descent of the smoothness measure objective. Digital phantom study shows that the proposed constrained optimization algorithm has superior performance in reducing metal artifacts, suppressing noise and improving soft-tissue visibility. Some comparisons are performed with the filtered-back-projection (FBP), FDK, POCS and constrained optimization with total-variation (TV) objective. Although the algorithm is presented in the context of metal artifacts, it can be generated to image reconstruction from incomplete projections caused by limited angular range or low angular sampling rate in both 2D and 3D cases.