Bubble Analyser
A Python application for detecting, measuring, and analyzing bubbles in images
Description
Bubble Analyser 2.0
Overview
Bubble Analyser 2.0 is a robust Python application for detecting, measuring, and analyzing bubbles in images. It provides advanced image processing capabilities using watershed segmentation algorithms and Deep Learning to accurately identify and measure bubbles of various sizes and distributions. It also offers manual adjustment tools for fine-tuning segmentation results when needed, and high-fidelity ML data export to help researchers train their own custom models.
This project is significantly improved based on the first version of Bubble Analyser (Mesa et al., 2022).
Key Features
- Image Processing: Preprocess images with various transformations.
- Bubble Detection Methods:
- Normal Watershed: Standard watershed algorithm with triple threshold.
- Iterative Watershed: Advanced algorithm that iteratively applies thresholds to detect objects at different intensity levels.
- Peak-Based Watershed: Feature-based segmentation using local maxima.
- BubMask (Deep Learning): Integrated Mask R-CNN model based on BubMask (Kim & Park, 2021) for superior accuracy in complex lighting or overlapping conditions.
- YOLO Segmentation (optional): Any Ultralytics YOLO segmentation model (
.pt). It needspip install ultralytics(AGPL-3.0) and a weights file set inweights_path; the device can be CPU or GPU (CUDA).
- Interactive Ellipse Adjuster: Manual adjustment interface for pixel-perfect refinement of detected bubbles.
- Measurement & Calibration: Calculate sizes, shape distributions, and convert pixel measurements to real-world units (mm) using reference images.
- Streamlined Workflow: Linear processing workflow (Batch -> Finalise -> Export) with no mid-process interruptions.
- Versatile Data Exports:
- Excel + Graph: Comprehensive descriptive size data alongside PDF/CDF distribution plots.
- Annotated Images: High-quality visual outputs with drawn ellipses for document reporting.
- ML Training Data: Export raw images alongside perfect integer ID masks (
.npy) allowing users to easily build new machine learning datasets from their manual corrections.
Installation
1. Windows Installation (Recommended)
A fully featured Windows Installation Wizard is now available.
- Download
BubbleAnalyser_Setup_v2.exefrom the Latest Release. - Run the installer.
- Important: During installation, ensure the "Download Deep Learning weights (~250MB)" option is checked if you plan to use the BubMask (Deep Learning) method.
- Launch "Bubble Analyser 2.0" from your Start Menu or Desktop.
2. MacOS Executable
A standalone executable for MacOS is also available in the releases section. (Note: If using the Deep Learning method on MacOS, the application will prompt you to download the required weights upon your first analysis).
3. From Source (Developers)
To run from source or contribute to the project:
-
Download and install Poetry following the instructions for your OS.
-
Clone this repository and navigate into the directory.
-
Install dependencies and activate the virtual environment:
poetry install poetry shell -
Install the pre-commit hooks (for code quality):
pre-commit install -
Run the application:
python -m bubble_analyser
[!NOTE] Using CNN Detection from Source: If you attempt to use the BubMask method from source without the weights, the app will display a prompt offering to download the
mask_rcnn_bubble.h5file automatically into thebubble_analyser/weights/directory.
Exporting Results
Once your batch analysis is finalised, navigate to the Results tab to extract your data:
-
Save Results (Excel + Graph): Creates an Excel file containing all bubble metrics (major/minor axis, equivalent diameter, area, eccentricity) and a
.pngof the generated histogram. -
Export Annotated Images: Select a folder to dump all the visual previews (images overlaid with the detected ellipses) for inclusion in reports.
-
Export Dataset (choose format): Pick a format, then a root folder. Every format uses your manual edits, writes bubbles at the original image resolution (manual polygon when there is one, fitted ellipse otherwise), and copies the images next to the annotations. Images with no bubbles are skipped.
Format Output Typical use YOLO segmentation images/,labels/*.txt(class x1 y1 x2 y2 ..., normalised),data.yamlTraining Ultralytics -segmodelsYOLO detection images/,labels/*.txt(class x_center y_center width height, normalised),data.yamlTraining box detectors COCO instance segmentation images/,annotations.json(pixel polygons, boxes, areas)Detectron2, MMDetection, pycocotools Pascal VOC JPEGImages/,Annotations/*.xml,ImageSets/Main/trainval.txt(boxes only)Box-based VOC tooling Masks ( .npy)images/,masks/*_mask.npy(integer label image at the processed resolution)The export of earlier versions The YOLO
data.yamlpointstrainandvalat the same folder: no train/validation split is made, so split the images before training.
Dependencies
- Python 3.12
- PySide6 (Qt for Python)
- TensorFlow & Keras
- NumPy, SciPy, Pandas
- scikit-image, OpenCV
- Matplotlib
Reference
Kim, Y., Park, H. Deep learning-based automated and universal bubble detection and mask extraction in complex two-phase flows. Sci Rep 11, 8940 (2021). https://doi.org/10.1038/s41598-021-88334-0
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. If you would like to add more image processing algorithms, please see the guidance under the directory Methods.
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Authors
- Dr Diego Mesa (Main Author) - Department of Earth Science and Engineering, Imperial College London, United Kingdom
- Mr Yiyang Guan - Curtin University, Australia
- Mr Bastian Valdivia-Muñoz - Universidad de Talca, Chile
Past Collaborators
- Dr Diego Alonso Álvarez - Imperial College London RSE Team, Imperial College London, United Kingdom
- Dr Paulina Quintanilla - Department of Chemical Engineering, Brunel University, United Kingdom
- Dr Francisco Reyes - IntelliSense.io, Queensland, Australia
- Dr Luis Vinnett - Universidad Tecnica Federico Santa Maria, Chile
Reference papers
Mentions
- 1.Author(s): Liangyong Wang, Junxiang Ning, Peng Fu, Xuezhong WangPublished in Powder Technology by Elsevier BV in 2027, page: 12336810.1016/j.powtec.2026.123368
- 2.Author(s): Alaa A. Najim, Safa A. NajimPublished in Information Sciences by Elsevier BV in 2026, page: 12316410.1016/j.ins.2026.123164
- 3.Author(s): Chintan Prajapati, Anshuman Vyas, David MacPheePublished in International Journal of Multiphase Flow by Elsevier BV in 2026, page: 10575110.1016/j.ijmultiphaseflow.2026.105751
- 4.Author(s): Karshyga Akishev, Alexandr Podvalov, Abdikarim Zeinullin, Yelaman Aibuldinov, Arman Nurmaganbetov, Nursultan Toktar, Sabina KhussainovaPublished in Sensors by MDPI AG in 2026, page: 556010.3390/s26175560
- 5.Author(s): Chunlong Zhang, Jiakun Tan, Yaoli Peng, Guangyuan XiePublished in International Journal of Coal Preparation and Utilization by Informa UK Limited in 2026, page: 1-4110.1080/19392699.2026.2666894
- 6.Author(s): Eric Thompson Brantson, Mukhtar Abdulkadir, Emmanuel Epelle, Francis Adjei, Fuseini Naziru Issaka, Zainab Ololade Iyiola, Adu-Awuku Joel, Nannan Liu, Laliri Bright NtebuPublished in Experimental and Computational Multiphase Flow by Springer Science and Business Media LLC in 2026, page: 395-41910.1007/s42757-025-0257-y
- 7.Author(s): Jiarui Xu, Wu Zhou, Tianyi Cai, Luhaibo ZhaoPublished in International Journal of Multiphase Flow by Elsevier BV in 2026, page: 10550710.1016/j.ijmultiphaseflow.2025.105507
- 8.Author(s): Hao Wang, Ao Hu, Mingjing Fan, Youjun LuPublished in Chemical Engineering Science by Elsevier BV in 2026, page: 12447310.1016/j.ces.2026.124473
- 9.Author(s): Saptarshi Dey, Abhishek Sahu, Vivek Dalvi, Biswajit Samir De, Anushree MalikPublished in Frontiers in Chemical Engineering by Frontiers Media SA in 202510.3389/fceng.2025.1701857
- 10.Author(s): P. K. Mall, H. K. Paliwal, Amit Medhavi, Shafiq AhmadPublished in AIP Advances by AIP Publishing in 202510.1063/5.0251734
- 11.Author(s): Hong Jiang, Ziyang Chen, Ziqin Xu, Wenyi Pei, Zhenchen Tang, Jiuxuan Zhang, Zhengyan Qu, Weihong Xing, Rizhi ChenPublished in Chemical Engineering Science by Elsevier BV in 2025, page: 12094310.1016/j.ces.2024.120943
- 12.Author(s): Jakub Augustyniak, Dariusz M. PerkowskiPublished in International Communications in Heat and Mass Transfer by Elsevier BV in 2025, page: 10850410.1016/j.icheatmasstransfer.2024.108504
- 13.Author(s): Dengfeng Han, Chuanyao Sun, Tichang Sun, Jingpeng Zhao, Shuaixing ShiPublished in Processes by MDPI AG in 2025, page: 121810.3390/pr13041218
- 14.Author(s): Yicong Wang, Ehecatl Antonio del Río Chanona, Paulina QuintanillaPublished in Industrial & Engineering Chemistry Research by American Chemical Society (ACS) in 2025, page: 13307-1332210.1021/acs.iecr.5c00660
- 15.Author(s): Yicong Wang, Antonio del Río Chanona, Paulina QuintanillaPublished in IFAC-PapersOnLine by Elsevier BV in 2025, page: 109-11410.1016/j.ifacol.2025.07.130
- 16.Author(s): Arbey De Jesús Urrego Cortés, Hernando Carlos Oñate Barrasa, Gridis Yulieth Cortés HenaoPublished in Tecnura by Universidad Distrital Francisco Jose de Caldas in 2025, page: 36-5810.14483/22487638.23958
- 17.Author(s): Paulina Quintanilla, Daniel Navia, Stephen J. Neethling, Pablo R. Brito-ParadaPublished in Chemical Engineering Research and Design by Elsevier BV in 2025, page: 467-48110.1016/j.cherd.2025.11.037
- 18.Author(s): Luis Vinnett, Roberto León, Diego MesaPublished in Physicochemical Problems of Mineral Processing by Politechnika Wroclawska Oficyna Wydawnicza in 202410.37190/ppmp/185759
- 19.Author(s): Xiaodi Liang, Suofang Wang, Wenjie ShenPublished in Processes by MDPI AG in 2024, page: 136410.3390/pr12071364
- 20.Author(s): Hyunsoo Kim, Eunji Myung, Chulhyun Park, Nagchoul Choi, Jaewon Lee, Kanghee ChoPublished in Results in Engineering by Elsevier BV in 2024, page: 10231210.1016/j.rineng.2024.102312
- 21.Author(s): Xiaodi Liang, Suofang Wang, Wenjie ShenPublished in Aerospace by MDPI AG in 2024, page: 65510.3390/aerospace11080655
- 22.Author(s): T. Polášek, A. Bureček, L. Hružík, M. Ledvoň, F. Dýrr, R. Olšiak, D. KolářPublished in Physics of Fluids by AIP Publishing in 202410.1063/5.0237338
- 23.Author(s): Luis VinnettPublished in Physicochemical Problems of Mineral Processing by Politechnika Wroclawska Oficyna Wydawnicza in 202310.37190/ppmp/174474
- 24.Author(s): C. A. Leiva, Jose Borjas, Claudio Acuña, Saija LuukkanenPublished in European Journal of Applied Sciences by Scholar Publishing in 2023, page: 645-66210.14738/aivp.112.14527
- 25.Author(s): Paulina Quintanilla, Daniel Navia, Stephen J. Neethling, Pablo R. Brito-ParadaPublished in Minerals Engineering by Elsevier BV in 2023, page: 10805010.1016/j.mineng.2023.108050
- 26.Author(s): Luis Vinnett, Diego MesaPublished in Minerals by MDPI AG in 2023, page: 80310.3390/min13060803
- 27.Author(s): Luis Vinnett, Iván Cornejo, Juan Yianatos, Claudio Acuña, Benjamín Urriola, Camila Guajardo, Alex EstebanPublished in Minerals by MDPI AG in 2022, page: 152810.3390/min12121528
- 28.Author(s): Luis Vinnett, Benjamín Urriola, Francisca Orellana, Camila Guajardo, Alex EstebanPublished in Minerals by MDPI AG in 2022, page: 114810.3390/min12091148
- 29.Author(s): T. N. Aleksandrova, V. V. KuznetsovPublished in Journal of Mining Science by Pleiades Publishing Ltd in 2022, page: 812-82210.1134/s106273912205012x
- 1.Author(s): Eric Thompson Brantson, Mukhtar Abdulkadir, Emmanuel I. Epelle, Fuseini Naziru Issaka, Nannan Liu, Zainab Ololade Iyiola, Eugene Jerry AdjeiPublished by Elsevier BV in 202410.2139/ssrn.4837935
- 2.Author(s): Lirong Yang, Cong SunPublished by Springer Science and Business Media LLC in 202410.21203/rs.3.rs-4439156/v1