A method and system for segmenting images of samples stained with two, three, or more stains accurately and reliably into multiple single-color images which represent the mass density of the stain at each position in the sample. The system includes a computer-controlled microscope and CCD camera, and at least one computer which includes data storage media for storing image data and which runs software for controlling image acquisition and analysis. To analyze tissue stained with N stains, images must be obtained at N different wavelengths, from multiply stained and singly stained samples. Relative stain mass densities are calculated with the use of the ratio of absorptivities measured at different wavelengths. The theoretical and practical basis for implementing the method with two, three, or more stains is presented. A method for selecting the wavelengths which provide optimal image accuracy and resolution is also provided.