Azzera filtri
Azzera filtri

Detecting bubbles from images

14 visualizzazioni (ultimi 30 giorni)
Sander Khowaja
Sander Khowaja il 28 Giu 2016
Dear Experts, I am trying to detect bubbles from a glass image which is attached with this post. I have written a piece of code, I am able to detect some bubbles but still some bubbles/circles are left out, somebody can help me out what to do in this case. I am also facing problems while I use different sized image, as the same threshold doesn't work for all images, threshold refers to all the values, related to sensitivity, edge threshold and radius of the circle in this case. Awaiting for the guidance from the experts.
close all clear all clc warning off
image = imread('STILL095.jpg'); % read image
% get image dimensions: an RGB image has three planes % reshaping puts the RGB layers next to each other generating % a two dimensional grayscale image
[height, width, planes] = size(image);
rgb = reshape(image, height, width * planes);
imagesc(rgb); % visualize RGB planes
r = image(:, :, 1); % red channel
g = image(:, :, 2); % green channel
b = image(:, :, 3); % blue channel
threshold = 100; % threshold value
imagesc(b < threshold); % display the binarized image
% apply the blueness calculation
blueness = double(b) - max(double(r), double(g));
imagesc(blueness); % visualize RGB planes
H = fspecial('average',125); % Creating a low pass filter
filtimg = imfilter(blueness,H); % applying a low pass filter to the image
imagesc(filtimg)
hfiltimg = filtimg - blueness; % converting it to a high pass filtered image for enhancing edges
imagesc(hfiltimg)
B = im2bw(hfiltimg); % converting the image in black and white
se = strel('disk',3); % creating a structure element of radius 3
er = imclose(B,se); % perfoming image closing operation
[centersBright2, radiiBright2, metricBright2] = imfindcircles(er,[6 90], ... 'ObjectPolarity','bright','Sensitivity',0.65,'EdgeThreshold',0.4);
imshow(image) %Plotting the circles on the original image
h2 = viscircles(centersBright2, radiiBright2);
  1 Commento
Vidya Viswanathan
Vidya Viswanathan il 11 Lug 2016
Hi,
I am not sure if you have come across this already, but for your specific use case, I would suggest you to try out active contour based segmentation technique. The following documentation link has the description of the function and an example for the same:
I hope this helps.
Regards,
Vidya Viswanathan

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by