Borrar filtros
Borrar filtros

Detecting bubbles from images

14 visualizaciones (últimos 30 días)
Sander Khowaja
Sander Khowaja el 28 de Jun. de 2016
Comentada: Vidya Viswanathan el 11 de Jul. de 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 comentario
Vidya Viswanathan
Vidya Viswanathan el 11 de Jul. de 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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by