Background and ObjectiveInadvertent retained surgical gauzes are an infrequent medical error but can have devastating consequences in the patient health and in the surgeon professional reputation. This problem seems easily preventable implementing standardized protocols for counting but due to human errors it still persists in surgery. The omnipresence of gauzes, their small size, and their similar appearance with tissues when they are soaked in blood make this error eradication really complex. In order to reduce the risk of accidental retention of surgical sponges in laparoscopy operations, in this paper we present an image processing system that tracks the gauzes on the video captured by the endoscope. MethodsThe proposed image processing application detects the presence of gauzes in the video images using texture analysis techniques. The process starts dividing the video frames into square blocks and each of these blocks is analyzed to determine whether it is similar to the gauze pattern. The video processing algorithm has been tested in a laparoscopic simulator under different conditions: with clean, slightly stained and soaked in blood gauzes as well as against different biological background tissues. Several methods, including different Local Binary Patterns (LBP) techniques and a convolutional neural network (CNN), have been analyzed in order to achieve a reliable detection in real time. ResultsThe proposed LBP algorithm classifies the individual blocks in the image with 98% precision and 94% sensitivity which is sufficient to make a robust detection of any gauze that appears in the endoscopic video even if it is stained or soaked in blood. The results provided by the CNN are superior with 100% precision and 97% sensitivity, but due to the high computational demand, real-time video processing is not attainable in this case with standard hardware. ConclusionsThe algorithm presented in this paper is a valuable tool to avoid the retention of surgical gauzes not only because of its reliability but also because it processes the video transparently and unattended, without the need for additional manipulation of special equipment in the operating room.