1. A computer-implemented method for stain separation comprising: transforming a digital image from a first color domain to an optical domain to form an optical domain image (ODI); identifying a plane containing two or more basis vector which contain the pixels of the ODI; forming a histogram of the digital image represented by the two or more basis vectors; and determining one or more final stain vectors by searching for candidate vectors in the plane that minimize a cost function of the histogram.