Weeds have a significant impact on the growth of rice. Accurate information about weed infestations can provide farmers with important information to facilitate the precise use of chemicals. In this study, we utilized visible light images captured by UAVs to extract information about weeds in areas of two densities on farmland. First, the UAV images were segmented using an optimal segmentation scale, and the spectral, texture, index, and geometric features of each segmented object were extracted. Cross-validation and recursive feature elimination techniques were combined to reduce the dimensionality of all features to obtain a better feature set. Finally, we analyzed the extraction effect of different feature dimensions based on the random forest (RF) algorithm to determine the best feature dimensions, and then we further analyzed the classification result of machine learning algorithms, such as random forest, support vector machine (SVM), decision tree (DT), and K-nearest neighbors (KNN) and compared them based on the best feature dimensions. Using the extraction results of the best classifier, we created a zoning map of the weed infestations in the study area. The results indicated that the best feature subset achieved the highest accuracy, with respective overall accuracies of 95.38% and 91.33% for areas with dense and sparse weed densities, respectively, and F1-scores of 94.20% and 90.57. Random forest provided the best extraction results for each machine learning algorithm in the two experimental areas. When compared to the other algorithms, it improved the overall accuracy by 1.74–12.14% and 7.51–11.56% for areas with dense and sparse weed densities, respectively. The F1-score improved by 1.89–17.40% and 7.85–10.80%. Therefore, the combination of object-based image analysis (OBIA) and random forest based on UAV remote sensing accurately extracted information about weeds in areas with different weed densities for farmland, providing effective information support for weed management.