The accumulation of aflatoxin B1 (AFB1) during wheat storage may pose a potential threat to food safety and quality control. This study explores the application of a colorimetric sensor array based on natural pigments for the quantitative detection of AFB1 and evaluates its detection performance. Anthocyanin dyes were extracted from various plant materials, and nine dyes with excellent response characteristics were selected to construct a sensor array for capturing volatile gas information released by wheat samples with different degrees of mold contamination. Subsequently, the ReliefF algorithm and SVM_Rfe algorithm were used to optimize the color components of the differential images from the sensor array. A back-propagation neural network (BPNN) model was constructed based on the best combination of color features, and the parameters of the network were adjusted using the particle swarm optimization (PSO) algorithm. The results showed that after the optimization of color components, the root mean square error (RMSE) of the BPNN model on the prediction set decreased from 4.4362 μg kg−1 to 3.7699 μg kg−1, while the correlation coefficient (R) increased to 0.9828. In general, the natural pigment-based sensor arrays based on natural pigments combined with chemometric methods can play an important role in grain mycotoxin detection and provide a non-destructive, rapid and environmentally friendly method for quantitative detection of mycotoxins in stored grains. Meanwhile, the feature optimization strategy significantly reduces the complexity and cost of sensor array construction, demonstrating excellent application potential.