Osteoporosis leads to the loss of cortical thickness, a decrease in bone mineral density (BMD), deterioration in the size of trabeculae, and an increased risk of fractures. Changes in trabecular bone due to osteoporosis can be observed on periapical radiographs, which are widely used in dental practice. This study proposes an automatic trabecular bone segmentation method for detecting osteoporosis using a color histogram and machine learning (ML), based on 120 regions of interest (ROI) on periapical radiographs, and divided into 60 training and 42 testing datasets. The diagnosis of osteoporosis is based on BMD as evaluated by dual X-ray absorptiometry. The proposed method comprises five stages: the obtaining of ROI images, conversion to grayscale, color histogram segmentation, extraction of pixel distribution, and performance evaluation of the ML classifier. For trabecular bone segmentation, we compare K-means and Fuzzy C-means. The distribution of pixels obtained from the K-means and Fuzzy C-means segmentation was used to detect osteoporosis using three ML methods: decision tree, naive Bayes, and multilayer perceptron. The testing dataset was used to obtain the results in this study. Based on the performance evaluation of the K-means and Fuzzy C-means segmentation methods combined with 3 ML, the osteoporosis detection method with the best diagnostic performance was K-means segmentation combined with a multilayer perceptron classifier, with accuracy, specificity, and sensitivity of 90.48%, 90.90%, and 90.00%, respectively. The high accuracy of this study indicates that the proposed method provides a significant contribution to the detection of osteoporosis in the field of medical and dental image analysis.