Real-Time Feature Extraction of Fine Mucosal Structures in Endoscopic Images Using Morphological Watershed Segmentation for Early Gastric Cancer Detection


Siyue HAN1, ZhizhaoYU1, Jiahui YU1, Simon James Fong1[0000-0002-1848-7246]*, Yongze GUO2, Hongwei ZHANG2, Huicong DONG2, Saicong LU2, Xian WANG2, and Feng TIAN3
Faculty of Science and Technology University of Macau, Macau SAR. China.,2Department of Gastroenterology Affiliated Hospital of Hebei University of Engineering Handan, Hebei Province. China., 3 Institute of Biomedical Informatics, School of Medicine Hebei University of Engineering, Handan Hebei Province. China
ccfong@umac.mo



ABSTRACT

Gastric cancer is among the leading causes of cancer related mortality worldwide, and its early detection remains challenging due to subtle endoscopic manifestations. Artificial intelligence (AI) assisted analysis of endoscopic images offers a promising pathway for improving diagnostic accuracy in real time. This paper presents a real time feature extraction framework for fine mucosal structures (FMS) in gastroscopy images using a structure enhanced morphological watershed segmentation algorithm. The method performs image preprocessing through directional filtering and morphological operations to highlight FMS patterns, followed by marker controlled watershed segmentation to deline ate structural boundaries. Geometric features including area, circularity, convexity, and Feret diameter are quantified and evaluated using multiple machine learning classifiers. Experimental results on endoscopic datasets demonstrate that filtering segmentation outliers significantly improves classification performance with neural networks achieving an AUC of 0.813. The results indicate that max Feret diameter is the most discriminative feature for distinguishing early gastric cancer from non cancerous tissues. This study contributes to real time intelligent healthcare systems by providing an interpretable and computationally efficient feature extraction pipeline that can support AI-driven clinical decision making in endoscopic screening.

Keywords:

Endoscopic Image Analysis, Fine Mucosal Structures, Morphological Watershed Segmentation, Feature Extraction, Early Gastric Cancer Detection, Machine Learning, Medical Image Processing


ALL METRICS

963

VIEWS


831

DOWNLOADS


Get PDF Get XML Cite Export
1. Introduction

Gastric cancer is one of the most prevalent malignancies worldwide and remains a leading cause of cancerrelated mortality. According to Global Cancer Statistics 2022, approximately 20 million new cancer cases were diagnosed and 9.7 million deaths were recorded, with gastric cancer ranking fifth in incidence and fourth in mortality, accounting for 4.9% and 6.8% of total cases and deaths, respectively [1]. A key challenge is that early gastric cancer (EGC) often presents with minimal or no symptoms, which increases the risk of delayed diagnosis and reduces the chances of curative treatment. Improving the detection rate of EGC is therefore essential to enhance patient survival and treatment outcomes. For example, in Figure 1, the endoscopic image of a stage IIb gastric cancer lesion closely resembles that of non cancerous gastritis, as both exhibit a reddish appearance.

Recent advances in artificial intelligence (AI) have provided powerful tools to assist clinicians in real time diagnostic workflows. AI-assisted endoscopy, particularly machine learning and deep learning, has shown great promise in enhancing diagnostic accuracy. Studies demonstrate that machine learning can elevate the diagnostic capability of non-specialist clinicians to levels comparable with trained experts [2–5], while deep learning models have reached or even surpassed the performance of human endoscopists.
An essential step in developing such intelligent systems is feature extraction, which provides discriminative descriptors for classification. Traditional methods rely on color, texture, and shape features of the gastric mucosa, but these are often insufficient for detecting flat type EGC, which exhibits subtle changes [6]. Clinical findings suggest that alterations in fine mucosal structures (FMS) such as miniaturization, irregularity, or disappearance serve as critical indicators of early malignancy [7]. Hence, extracting and quantifying FMS features from endoscopic images can provide a more reliable diagnostic basis.
Morphological watershed segmentation is a classical image segmentation technique that does not require pretraining and is particularly suitable for medical images with complex textures and boundaries [8]. Prior works have applied this method to segment and classify abnormal endoscopic images [9] and to fuse morphological operations for broader medical imaging applications [10].
In this paper, we propose a real time feature extraction framework that leverages a structure enhanced morphological watershed segmentation algorithm to analyze FMS in gastroscopy images. The method extracts geometric descriptors, identifies the most representative features, and integrates them into machine learning pipelines to differentiate between EGC and non-cancerous tissues. The ultimate goal is to support AI-driven, real time clinical decision making and provide clinicians with more accurate diagnostic assistance during endoscopic examinations.

2. Image Preprocessing

For this study, gastroscopic images were collected from 12 patients who underwent endoscopy at a hospital in Hebei between 2022 and 2023. The dataset consisted of images from six patients diagnosed with type II-b early gastric cancer (EGC) and six patients with non atrophic gastritis. To generate region of interest (ROI) samples for analysis, each image was cropped into two to four smaller rectangular patches, and the patches were labeled according to anatomical location.
To prepare the images for segmentation, the original RGB data were first converted into 8-bit grayscale using a weighted luminance transformation:

I = 0.299 × R + 0.587 × G + 0.114 × B (1)

This representation retains essential intensity information while simplifying subsequent gradient calculations (Fig.2). To further improve visibility of fine mucosal structures (FMS), contrast enhancement and brightness normalization were applied by rescaling the pixel intensity range:

This transformation highlights structural details in the ROI while suppressing less relevant background regions (Fig. 2 Right).
Noise suppression in endoscopic images is challenging due to the irregular texture of gastric mucosa. Conventional filters such as Gaussian, median, and mean smoothing were found to be insufficient. Instead, a directional morphological filtering approach was adopted. Here, each pixel is adaptively enhanced by computing the maximum morphological response over multiple structuring elements, each oriented at an angle

where L is the structuring element and O denotes the morphological operation. By using 32 orientations with a line length of five pixels, this filtering method amplifies the net like white patterns of FMS while preserving their geometric fidelity.
To address discontinuities introduced by noise, morphological closing was further applied:

C(I) = (Ib) ⊖ b

where and (5) denote dilation and erosion, respectively. This operation smooths boundaries and connects fragmented structures without distorting their shape. A comparison across Gaussian, median, mean, and directional filters (Fig. 3) shows that directional filtering produces the clearest representation of FMS, facilitating subsequent watershed segmentation.
The complete preprocessing workflow comprising grayscale conversion, contrast normalization, directional filtering, and morphological closing is illustrated in Fig. 4. These steps ensure that subtle structural patterns are preserved and enhanced in real time, providing a robust foundation for feature extraction and classification.

3. Morphological Watershed Segmentation

Watershed segmentation partitions an image by treating pixel intensity as a topographic surface and identifying catchment basins. The process begins by computing the gradient to detect local minima, which act as initial seeds for flooding. Directly marking local minima, however, is highly sensitive to noise and fine textures, often resulting in severe over segmentation. To address this, an extended minima transform is applied. A threshold value t is defined, and pixels with gray values below
t are marked and set to zero, producing a binary mask. This mask is then superim posed on the grayscale image, suppressing irrelevant regions while emphasizing structural detail (Fig. 5).
To further refine boundaries, a marker controlled watershed algorithm is employed. Flooding begins from the extended minima, merging homogeneous regions into candidate targets. Each region is assigned a distinct label to form a mask, which is subsequently cleaned using morphological dilation and erosion to remove spurious or noisy labels. The refined mask is then used to guide the final watershed segmentation, producing robust region delineation.
Because the fine mucosal structures (FMS) often appear as bright zones of finite thickness, a morphological gradient is applied to enhance edge clarity. The gradient is defined as

G(I) = Ib-Ib ------(6)

No Feature Definition
1 Label Label Number
2 Area The area of the region
3 Perimeter The perimeter of the region
4 Circularity The normalized ratio of area over the square of the perimeter
5 Centroid X The x coordinate of centroid
6 Centroid Y The y coordinate of centroid
7 Ellipse Radius 1 The length of short diameter of the inertia ellipse
8 Ellipse Radius 2 The length of long diameter of the inertia ellipse
9 Convex Area The sum of the area of the region over the area of its convex hull
10 Convexity The ratio of the area of the region over the area of its convex hull
11 Max Feret Diameter The value of the largest Feret diameter
12 OBox length The length of the oriented box with smallest width
13 OBox Width The width of the oriented box with smallest width
14 Geodesic Diameter The length of the geodesic diameter
15 Inscribe Radius The radius of the largest circle that can be inscribed within the region
16 Average Thickness The average thickness of the region
17 Class NEC or EC

From each segmented region, geometric features are computed to quantitatively characterize mucosal structures. These include basic descriptors such as area, perimeter, and centroid, as well as advanced shape and texture indicators like circularity, convexity, Feret diameter, oriented box dimensions, geodesic diameter, and average thickness. A total of 17 features are extracted, as summarized in Table 1. These descriptors provide a compact yet discriminative representation of FMS, supporting downstream classification of normal (NEC) and cancerous (EC) tissues.

4. Results and Discussion

The final dataset contained 7,379 labels from non-cancerous (NEC) regions and 3,595 labels from early cancerous (EC) regions, with each label described by 17 geometric features. To evaluate classification performance, we applied six machine learning models Support Vector Machine (SVM), Decision Tree, Random Forest, Naive Bayes, Logistic Regression, and Neural Network using five fold cross validation. As shown in Table 2, the Neural Network achieved the best performance on the unfiltered dataset, reaching an AUC of 0.716, outperforming traditional classifiers such as Random Forest and Logistic Regression. However, segmentation artifacts were observed, particularly elongated or narrow labels caused by edge blurring in endoscopic images. These artifacts introduced noise into the dataset and reduced classification accuracy.

Model AUC CA F1 Precision Recall MCC
Neural Network 0.716 0.706 0.674 0.686 0.706 0.261
Tree 0.565 0.626 0.629 0.632 0.626 0.164
Naive Bayes 0.656 0.639 0.646 0.658 0.639 0.222
Logistic Regression 0.672 0.697 0.642 0.675 0.697 0.212
Random Forest 0.675 0.683 0.669 0.665 0.683 0.235
SVM 0.501 0.504 0.518 0.543 0.504 -0.036

To address this, we leveraged the maximum Feret diameter a descriptor measuring the maximum span of each segmented object:

Fmax = max d (x, y), x, yX

By ranking samples based on Feret diameter and removing the top and bottom 20% in both EC and NEC groups, segmentation outliers were reduced. Figures 7 and 8 illustrate the distribution of Feret diameters and the effect of range selection on classification performance.
The refined dataset yielded substantially improved results, as summarized in Table 3. Neural Networks again achieved the highest accuracy, with an AUC of 0.813 and classification accuracy of 0.772. Logistic Regression and Random Forest also showed competitive performance, both surpassing 0.78 in AUC.Permutation based feature importance analysis further revealed that the maximum Feret diameter is the most discriminative feature, followed by shape and convexity related descriptors. This indicates that structural geometry plays a key role in distinguishing EGC from NEC tissues. The ranking of feature importance is presented in Figure 9.

Model AUC CA F1 Precision Recall MCC
Neural Networks 0.813 0.772 0.750 0.772 0.772 0.447
Logistic Regression 0.789 0.760 0.750 0.751 0.760 0.426
Random Forest 0.785 0.761 0.745 0.753 0.761 0.422
Naive Bayes 0.772 0.700 0.705 0.714 0.700 0.349
Tree 0.704 0.715 0.716 0.718 0.715 0.369
SVM 0.499 0.645 0.623 0.616 0.645 0.124
Table 3. Classification results after removal of segmentation outliers based on Feret diameter.

These findings demonstrate that carefully filtering segmentation outliers and lever aging geometric descriptors can significantly enhance real time classification accuracy. In particular, the integration of Feret diameter into the preprocessing pipeline strengthens the interpretability of the system, ensuring that the extracted features align with clinically relevant mucosal changes.

5. Conclusion

This paper presented a real time feature extraction framework for analyzing fine mucosal structures (FMS) in gastroscopy images using a structure enhanced morphological watershed segmentation algorithm. Through systematic preprocessing, segmenta tion, and geometric analysis, we extracted 17 quantitative descriptors to represent the structural properties of FMS. Among these, the maximum Feret diameter emerged as the most discriminative feature, consistently improving classification performance across six machine learning models. After filtering segmentation outliers, the Neural Network achieved the highest accuracy (AUC = 0.813), demonstrating the effectiveness of this approach in distinguishing early gastric cancer (EGC) from noncancerous tissues.
Beyond classification accuracy, this study emphasizes the interpretability of geometric descriptors, particularly Feret diameter, which directly reflects clinically meaningful alterations in mucosal patterns such as miniaturization and irregularity. These findings highlight the potential of combining morphological segmentation with intelligent feature selection to build reliable and transparent diagnostic tools.
Future work will focus on extending this framework to larger and more diverse datasets, integrating deep learning models for end to end real time analysis, and embedding the system into clinical decision support platforms. By advancing both the efficiency and interpretability of AI-assisted endoscopy, this research contributes to the development of real time intelligent healthcare systems that can enhance early detection of gastric cancer and ultimately improve patient outcomes.
Acknowledgments. This research was funded by the Guangzhou Development Zone Science and Technology Project (2023GH02), the University of Macau (MYRG2022-00271- FST) and research grants by the Science and Technology Development Fund of Macau (0032/2022/A) and (0019/2025/RIB1).
Disclosure of Interests . The authors have no competing interests to declare that are relevant to the content of this article.

References

[1] Li, J., Zhu, Y., Dong, Z., et al. (2022). Development and validation of a feature extraction based logical anthropomorphic diagnostic system for early gastric cancer: A case-control study. eClinicalMedicine 53, 101716.
[2] Liu, X., Zhang, Y., Zhang, Y., et al. (2022). Deep learningbased computer aided diagnosis for early gastric cancer using magnifying endoscopy images. Diagnostics 12 (8), 1996.
[3] Li, J., Zhu, Y., Dong, Z., et al. (2022). Development and validation of a feature extraction based logical anthropomorphic diagnostic system for early gastric cancer: A case-control study. eClinicalMedicine 53, 101716.
[4] Shi, Y., Fan, H., Li, L., et al. (2024). The value of machine learning approaches in the diagnosis of early gastric cancer: A systematic review and meta analysis. World J. Surg. Oncol. 22, 40
[5] Klang, E., Soroush, A., Nadkarni, G. N., et al. (2023). Deep learning and gastric cancer: Systematic review of AIassisted endoscopy. Diagnostics 13 (24), 3613.
[6] Uedo, N., Ishihara, H., Iishi, T., Tatsuta, M. (2006). Diagnosis of early gastric cancer by magnifying endoscopy with narrow-band imaging: correlation of vascular patterns with histopathology. Endoscopy 38 (10), 1030–1034
[7] Manasseh, M., Mithany, R. (2024). Gastric cancer: a comprehensive literature review. Br. J. Surg. 111 (Suppl. 9), znae271.170.
[8] Doi, K., Mahon, Mac., H., Giger, M. L. (1998). Computer-aided diagnosis in medical imaging. IEEE Trans. Inf. Technol. Biomed. 2 (3), 161–174.
[9] Doi, K. (2007). Current status and future potential of computer-aided diagnosis in medical imaging. Comput. Med. Imaging Graph. 31 (4–5), 198–211.
[10] Zhang, Y., Wang, Y., Liu, Y., et al. (2023). A novel deep learning framework for gastric cancer detection using endoscopic images. Multimed. Tools Appl.