Nitrites react with 4-aminobenzoic acid (PABA) to form diazo compounds, which further couple with N-(1-naphthyl)-1,2-ethylenediamine dihydrochloride (NED) to generate purple or brown compounds, resulting in a color change on the surface of the hydrogel. The intensity of the hydrogel's coloration varies with changes in nitrite concentration, leading to variations in its grayscale values. The diazo coupling reaction can be used for colorimetric determination of nitrites and has been proven effective for nitrite detection in real water samples.