A method for determining the mineral content of a sample using an electron microscope, said method comprising: directing an electron beam toward a first area of interest of a sample (100, 502), the first area of interest comprising an unknown composition of minerals; and detecting backscattered electrons from the first area of interest of the sample; characterized by: (a) determining a first working distance, between a backscattered electron detector of the microscope and the first area of interest of the sample, using at least one of: - an auto-focus feature of the microscope, to determine a focal depth of the first area of interest; - a laser interferometer; - a capacitive sensor, and (b) compensating for a difference between the first working distance and a predetermined working distance, the predetermined working distance being selected to provide desired grayscale values for detected backscattered electrons, using at least one of: (i) adjusting the z-axis position of at least one of the sample stage and the backscattered electron detector, so that there is substantially no difference between the first working distance and the predetermined working distance; (ii) a method comprising the following steps: - modeling the effect of a plurality of working distance variations on detected backscattered electron levels; - calculating a backscattered electron level adjustment based on the difference between the first working distance and the predetermined working distance; and - adjusting one or more of the detected backscattered electron levels based on the calculated backscattered electron level adjustment. directing an electron beam toward a first area of interest of a sample (100, 502), the first area of interest comprising an unknown composition of minerals; and detecting backscattered electrons from the first area of interest of the sample; (a) determining a first working distance, between a backscattered electron detector of the microscope and the first area of interest of the sample, using at least one of: - an auto-focus feature of the microscope, to determine a focal depth of the first area of interest; - a laser interferometer; - a capacitive sensor, and - an auto-focus feature of the microscope, to determine a focal depth of the first area of interest; - a laser interferometer; - a capacitive sensor, (b) compensating for a difference between the first working distance and a predetermined working distance, the predetermined working distance being selected to provide desired grayscale values for detected backscattered electrons, using at least one of: (i) adjusting the z-axis position of at least one of the sample stage and the backscattered electron detector, so that there is substantially no difference between the first working distance and the predetermined working distance; (ii) a method comprising the following steps: - modeling the effect of a plurality of working distance variations on detected backscattered electron levels; - calculating a backscattered electron level adjustment based on the difference between the first working distance and the predetermined working distance; and - adjusting one or more of the detected backscattered electron levels based on the calculated backscattered electron level adjustment. (i) adjusting the z-axis position of at least one of the sample stage and the backscattered electron detector, so that there is substantially no difference between the first working distance and the predetermined working distance; (ii) a method comprising the following steps: - modeling the effect of a plurality of working distance variations on detected backscattered electron levels; - calculating a backscattered electron level adjustment based on the difference between the first working distance and the predetermined working distance; and - adjusting one or more of the detected backscattered electron levels based on the calculated backscattered electron level adjustment. - modeling the effect of a plurality of working distance variations on detected backscattered electron levels; - calculating a backscattered electron level adjustment based on the difference between the first working distance and the predetermined working distance; and - adjusting one or more of the detected backscattered electron levels based on the calculated backscattered electron level adjustment.