For purposes of locating kerogen/organic matter and pores in SEM images of shale samples, we tested an automated SEM-image segmentation workflow involving feature extraction followed by machine learning. The proposed segmentation workflow is an alternative to threshold-based and object-based segmentation. For each pixel in the SEM image, sixteen features are generated and then fed to a random forest classifier to determine the presence of four rock components, namely (1) pore/crack, (2) rock matrix including clay, calcite and quartz, (3) pyrite, and (4) organic/kerogen components. Extraction of the 16 features for each pixel in a 2058 (pixel) by 2606 (pixel) SEM image requires approximately 5 s on a conventional desktop configuration. The most important features for the desired segmentation are wavelet transforms, Gaussian blur and difference of Gaussians. The random-forest classifier was trained using only 705, 2074, 17373, and 15,000 pixels for the pore/crack, organic/kerogen, rock matrix, and pyrite components, respectively. Training of the classifier was accomplished in approximately 7 s. The proposed segmentation methodology can segment one 2058 (pixel) by 2606 (pixel) SEM image in approximately 30 s. For purposes of validation of the segmentation method, 5121, 4725, 4815, and 4775 pixels were used for the pore/crack, organic/kerogen, rock matrix, and pyrite components, respectively, where 1 pixel covers 100 nm2. Despite the limited number of pixels used for training, the performance of the trained classifier, quantified in terms of overall F1 score, on the validation dataset was higher than 0.9. The newly developed method is significantly more reliable and robust in comparison to the popular histogram thresholding and object-based segmentation methods, especially for the matrix and pyrite components in shale samples.