Estimation of Vector Fields in Unconstrained and Inequality Constrained Variational Problems for Segmentation and Registration