Foam stability is an important factor for many engineering applications, including oil and gas practice. The evaluation of formation behavior in drilling fluid foam is essential for efficient drilling operations. Several aspects such as high pressure and temperature, change in foam state over time, surfactant characteristics, etc. need to be considered. At present, none of the existing models considering these parameters are well developed. In this paper, foam stability is studied using digital image processing. Laboratory studies were carried out using a conventional surfactant with a given solution concentration and at fixed values of pressure and temperature. Images of the foam were taken at intervals during each test. They were further analyzed using digital image processing technology and interpreted as numerical parameters: average bubble size, bubble roundness (compactness), etc. as a function of time. The results of such interpretation allow us to assess the stability of the foam at each specific moment of time.