🏥 Detecting Gallbladder Stones with AI: A Deep Learning Approach Using Ultrasound

So during one of my deep learning projects, I came across the idea of using medical images — specifically ultrasound scans — to detect gallbladder stones. The challenge was clear: ultrasounds are noisy, vary a lot from patient to patient, and stones don’t always look the same.
But the goal was also straightforward: can we train an AI to spot what radiologists look for — and maybe even assist doctors in faster diagnosis?
That’s where this project started: building a deep learning-based detection system for gallbladder stones using ultrasound images.
🧩 What I Was Trying to Solve
Manual detection of stones through ultrasound can be time-consuming and prone to errors due to low contrast, image noise, and the variability in how stones appear. And since MRI or CT scans are expensive, if we could improve accuracy from ultrasound alone — it would make diagnosis cheaper and faster.
So the question I asked was: Can we build a model that automates this using deep learning and computer vision?
🔧 What I Used to Build It
Python
OpenCV – for image cleaning and preprocessing
TensorFlow / PyTorch – for model experimentation
CNNs: VGG16, ResNet50, MobileNetV2
Second-order pooling – for learning fine-grained textures
🛠️ How I Built It
Here’s how the project was structured:
1️⃣ Preprocessing the Ultrasound Images
Used OpenCV to clean the images: grayscale conversion, contrast stretching
Applied adaptive histogram equalization (CLAHE) to improve local contrast
Removed noise with Gaussian filters and thresholding
2️⃣ Gallbladder ROI Detection
Used a U-Net based segmentation approach to localize the gallbladder
Followed up with contour detection and morphological operations to isolate the region
3️⃣ Deep Learning for Stone Detection
Tried multiple CNNs — VGG16, ResNet50, and MobileNetV2 — on the processed ROI
Also added a second-order pooling layer, which helped with fine-grain pattern recognition
4️⃣ Evaluation & Results
Improved detection accuracy by 30% compared to basic CNNs
System could detect stones with high confidence across varied ultrasound quality
🧪 What Made It Work
Second-order pooling really helped — it learns texture-like patterns better than regular max pooling
ROI localization using U-Net meant the classifier wasn’t looking at the entire image — only the useful part
Combining OpenCV-based preprocessing with DL models made the whole pipeline lighter and more accurate
💡 What I Learned
Medical images need a lot of preprocessing — unlike ImageNet-style datasets, you can’t just resize and feed it to the model
It’s super important to define your region of interest clearly — otherwise the model just learns noise
Even small architectural tweaks like second-order pooling can make a big difference in domains like healthcare
🧠 Why This Project Matters
In real-world settings — especially in healthcare — you can’t always rely on perfect data or fancy devices. So if a deep learning system can make diagnosis more accessible, that’s a massive win.
This kind of system, with the right clinical validation, could one day be used in low-resource hospitals where advanced scans aren’t available.
✉️ Open to Collaborate
Still working on optimizing parts of this, but if you're into AI in healthcare — or have ideas to improve clinical-grade models — let’s talk!
Subscribe to my newsletter
Read articles from Khushal Jhaveri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
