FractalFormer for Image-Based estimation of Reactive Blue 21 in water - Durmus, Barbaros; Durmus, Neslihan; Dogan, Sengul; Tuncer, Turker (Pergamon-Elsevier Science Ltd, 2026)
This work introduces FractalFormer, a novel and lightweight deep learning model for visual quantification of Reactive Blue 21 (RB21) concentrations in aquatic environments. Unlike conventional spectrophotometric methods, which are costly, stationary, and require extensive sample preparation, FractalFormer enables direct and reliable measurement from real-world laboratory images. A dataset was collected containing 13 standard RB21 concentrations (0-1000 ppm) using three types of laboratory glassware (beaker, Erlenmeyer flask, volumetric flask) under varied lighting and viewing angles. Ground-truth concentrations were determined via UV-Vis spectrophotometry at 625 nm, providing a robust reference for supervised learning. Implemented in MATLAB2023b, FractalFormer comprises 63 layers and 82 interconnections, integrating fractal self-attention modules and recursive convolutional blocks. The model achieved 100% training accuracy, 99.83% validation accuracy, and over 99% accuracy, precision, recall, and F1-score on the test set. Grad-CAM visualization highlighted that the introduced FractalFormer focused on relevant regions and these results illustrated that this transformer has high explainable AI (XAI) capability. The proposed workflow reduces reagent use and laboratory waste. UV-Vis requires dilution only for samples with high absorbance, outside the linear range. FractalFormer estimates concentration from undiluted images under the calibrated imaging setup. The method still requires calibration against UV-Vis reference concentrations. The same framework can support other dyes and pollutants after new calibration and training. It offers a scalable and cost-effective option for laboratory water quality assessment. By combining high performance with explainable AI techniques, FractalFormer demonstrates the potential of domain-specific transformer architectures in environmental diagnostics, particularly for rapid, low-cost monitoring in resource-limited settings.
Keywords: Reactive Blue 21; FractalFormer; Computer Vision; Environmental monitoring; Transformer architecture; Deep learning