The Substitution box (S-box) is pivotal in block cipher cryptosystems, as it provides critical properties of non-linearity and confusion essential for robust security. Despite the development of various S-boxes categorized by their robustness-high, medium, or low-evaluating their effectiveness manually remains labor-intensive and inefficient. This paper addresses this issue by introducing a machine learning model that leverages parameters such as bit independence criterion, nonlinearity, strict avalanche criterion, linear approximation probability, and differential uniformity to assess S-box strength automatically. Additionally, a novel lightweight image encryption scheme is proposed tailored for IoT applications that integrate these robust S-boxes alongside four advanced cryptographic techniques: chaotic maps, discrete wavelet transform, substitution box, and dynamic random phase encoding. The proposed approach significantly enhances encryption security. The proposed scheme is evaluated using both statistical and visual analyses, evaluating parameters such as entropy, correlation, chi-square analysis, energy, computational complexity analysis, and resilience to various attacks, including noise and occlusion. The scheme demonstrates exceptional security metrics, with an entropy value of 7.9991, a correlation of 0.0001, and a chi-square value of 268. Additionally, the computational complexity of the scheme is 0.08 s, indicating efficient performance. Furthermore, a detailed comparison between the proposed encryption scheme and existing methods is performed to show that the proposed approach surpasses existing schemes in terms of security and computational efficiency.