Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Image analysis (emulsion droplet size)

Subject: Image analysis (emulsion droplet size)

From: traynor85

Date: 20 Aug, 2010 13:47:16

Message: 1 of 14

Does anybody have any codes written for analysing images of emulsion
droplets, i have gotten as far as i can by myself following the
procedure laid out in a few pieces of literature and the Image
Processing Toolbox user guide. The sequence of operations in the
literature papers are as follows:

(a) conversion of a RGB (red–green–blue) image to an intensity image
with previous subtraction
of the background;
(b) creation of a binary image from an intensity image based on a
luminance threshold;
(c) use of a median filtering to remove salt and pepper noise;
(d) suppression of the structures connected to image border;
(e) erosion of the binary image and morphological reconstruction using
a mask previously created

im looking to find the average droplet size of the emulsions and i
know that 15 pixels = 1 micron and that 1 micron is the minimum size
of the emulsion drioplets possible using the equipment i have to
produce the emulsions.

step (a) and (b) i can do no problem, here is the procedure:

a = imread('1a day0 (11).jpg');
%convert the true color (rgb) image to grayscale image
ag= rgb2gray(a); imtool(ag)

% To adjust the treshold Click Adjust Contrast in the Image Tool
toolbar, or select the Adjust Contrast option from the Image Tool
Tools menu.
%save new adjusted image under new file name ('atresh') or export the
new image to workspace under new file name, show image


%Use the im2bw function to convert the grayscale image into a binary
image
level = graythresh(atresh);
bw = im2bw(atresh,level);
bw = bwareaopen(bw, 50);
figure, imshow(bw)


as forusing the median filter i dont seem to be able to remove much
noise, heres the codes i have:

%Add noise to it.
J = imnoise(atresh,'salt & pepper',0.02);
figure, imshow(J)

%Filter the noisy image with an averaging filter and display the
results.
K = filter2(fspecial('average',3),J)/255;
figure, imshow(K)

%Now use a median filter to filter the noisy image and display the
results.
L = medfilt2(J,[3 3]);
figure, imshow(L)

im also not having any luck with steps (d) and (e) the morphological
operations.
 can anybody please help me? thanks.

Subject: Image analysis (emulsion droplet size)

From: Sean

Date: 20 Aug, 2010 14:12:04

Message: 2 of 14

traynor85 <markptraynor@eircom.net> wrote in message <7e364a63-bf58-4449-88df-f55b52e34197@a36g2000yqc.googlegroups.com>...
> Does anybody have any codes written for analysing images of emulsion
> droplets, i have gotten as far as i can by myself following the
> procedure laid out in a few pieces of literature and the Image
> Processing Toolbox user guide. The sequence of operations in the
> literature papers are as follows:
>
> (a) conversion of a RGB (red–green–blue) image to an intensity image
> with previous subtraction
> of the background;
> (b) creation of a binary image from an intensity image based on a
> luminance threshold;
> (c) use of a median filtering to remove salt and pepper noise;
> (d) suppression of the structures connected to image border;
> (e) erosion of the binary image and morphological reconstruction using
> a mask previously created
>
> im looking to find the average droplet size of the emulsions and i
> know that 15 pixels = 1 micron and that 1 micron is the minimum size
> of the emulsion drioplets possible using the equipment i have to
> produce the emulsions.
>
> step (a) and (b) i can do no problem, here is the procedure:
>
> a = imread('1a day0 (11).jpg');
> %convert the true color (rgb) image to grayscale image
> ag= rgb2gray(a); imtool(ag)
>
> % To adjust the treshold Click Adjust Contrast in the Image Tool
> toolbar, or select the Adjust Contrast option from the Image Tool
> Tools menu.
> %save new adjusted image under new file name ('atresh') or export the
> new image to workspace under new file name, show image
>
>
> %Use the im2bw function to convert the grayscale image into a binary
> image
> level = graythresh(atresh);
> bw = im2bw(atresh,level);
> bw = bwareaopen(bw, 50);
> figure, imshow(bw)
>
>
> as forusing the median filter i dont seem to be able to remove much
> noise, heres the codes i have:
>
> %Add noise to it.
> J = imnoise(atresh,'salt & pepper',0.02);
> figure, imshow(J)
>
> %Filter the noisy image with an averaging filter and display the
> results.
> K = filter2(fspecial('average',3),J)/255;
> figure, imshow(K)
>
> %Now use a median filter to filter the noisy image and display the
> results.
> L = medfilt2(J,[3 3]);
> figure, imshow(L)
>
> im also not having any luck with steps (d) and (e) the morphological
> operations.
> can anybody please help me? thanks.
>


It would be really helpful if you could post a sample image.

http://drop.io

Subject: Image analysis (emulsion droplet size)

From: ImageAnalyst

Date: 20 Aug, 2010 16:45:36

Message: 3 of 14

Try this:
http://www.mathworks.com/matlabcentral/fileexchange/25157
It does basically just that, except for coins on a background, but
they just as well could have been droplets in an emulsion. It may
work well with your images, which you can post to http://drop.io if
you want more help.

Subject: Image analysis (emulsion droplet size)

From: traynor85

Date: 15 Sep, 2010 12:50:35

Message: 4 of 14

On Aug 20, 3:12 pm, "Sean "
<sean.dewol...@nospamplease.umit.maine.edu> wrote:
> traynor85 <markptray...@eircom.net> wrote in message <7e364a63-bf58-4449-88df-f55b52e34...@a36g2000yqc.googlegroups.com>...
> > Does anybody have any codes written for analysing images ofemulsion
> > droplets, i have gotten as far as i can by myself following the
> > procedure laid out in a few pieces of literature and the Image
> > Processing Toolbox user guide. The sequence of operations in the
> > literature papers are as follows:
>
> > (a) conversion of a RGB (red–green–blue) image to an intensity image
> > with previous subtraction
> > of the background;
> > (b) creation of a binary image from an intensity image based on a
> > luminance threshold;
> > (c) use of a median filtering to remove salt and pepper noise;
> > (d) suppression of the structures connected to image border;
> > (e) erosion of the binary image and morphological reconstruction using
> > a mask previously created
>
> > im looking to find the average droplet size of the emulsions and i
> > know that 15 pixels = 1 micron and that 1 micron is the minimum size
> > of theemulsiondrioplets possible using the equipment i have to
> > produce the emulsions.
>
> > step (a) and (b) i can do no problem, here is the procedure:
>
> > a = imread('1a day0 (11).jpg');
> > %convert the true color (rgb) image to grayscale image
> > ag= rgb2gray(a); imtool(ag)
>
> > % To adjust the treshold Click Adjust Contrast in the Image Tool
> > toolbar, or select the Adjust Contrast option from the Image Tool
> > Tools menu.
> > %save new adjusted image under new file name ('atresh') or export the
> > new image to workspace under new file name, show image
>
> > %Use the im2bw function to convert the grayscale image into a binary
> > image
> > level = graythresh(atresh);
> > bw = im2bw(atresh,level);
> > bw = bwareaopen(bw, 50);
> > figure, imshow(bw)
>
> > as forusing the median filter i dont seem to be able to remove much
> > noise, heres the codes i have:
>
> > %Add noise to it.
> > J = imnoise(atresh,'salt & pepper',0.02);
> > figure, imshow(J)
>
> > %Filter the noisy image with an averaging filter and display the
> > results.
> > K = filter2(fspecial('average',3),J)/255;
> > figure, imshow(K)
>
> > %Now use a median filter to filter the noisy image and display the
> > results.
> > L = medfilt2(J,[3 3]);
> > figure, imshow(L)
>
> > im also not having any luck with steps (d) and (e) the morphological
> > operations.
> >  can anybody please help me? thanks.
>
> It would be really helpful if you could post a sample image.
>
> http://drop.io- Hide quoted text -
>
> - Show quoted text -

hi sean, thanks for the reply, i dont know how to post images on this
site, i have tried to email you directly with images attached however
sending failed as it said your domain name is not found.

Subject: Image analysis (emulsion droplet size)

From: traynor85

Date: 15 Sep, 2010 13:26:58

Message: 5 of 14

On Aug 20, 5:45 pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> Try this:http://www.mathworks.com/matlabcentral/fileexchange/25157
> It does basically just that, except for coins on a background, but
> they just as well could have been droplets in anemulsion.  It may
> work well with your images, which you can post tohttp://drop.ioif
> you want more help.

hi,

thanks for the reply and the info, didnt work to well for me. i would
really appreciate some more help with this if i can email you with
some of my images? also im looking to create' stacks' or an image
sequences. the matlab manual only shows howe to creak this from video
not still images.

Subject: Image analysis (emulsion droplet size)

From: Sean

Date: 15 Sep, 2010 13:57:05

Message: 6 of 14

traynor85 <traynor85@gmail.com> wrote in message <4fa9066a-b88f-46af-83c1-8200a0a07edc@c21g2000vba.googlegroups.com>...
> On Aug 20, 5:45 pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> > Try this:http://www.mathworks.com/matlabcentral/fileexchange/25157
> > It does basically just that, except for coins on a background, but
> > they just as well could have been droplets in anemulsion.  It may
> > work well with your images, which you can post tohttp://drop.ioif
> > you want more help.
>
> hi,
>
> thanks for the reply and the info, didnt work to well for me. i would
> really appreciate some more help with this if i can email you with
> some of my images? also im looking to create' stacks' or an image
> sequences. the matlab manual only shows howe to creak this from video
> not still images.

Hi,
Most of our email addresses on here are either fake, temporary, or modified. If you look at the first part after the @ in mine you'll see what you have to delete to get the real email address. Unless our own code is used most CSSMers prefer to talk on here. On this topic there are many people who probably know what to do and so private email excludes them.

As for your image stack question:
If the images are all the same size and grayscale or binary (not RGB) the best way to 'stack' them is to make each image (nth image) the nth slice of a 3D matrix. E.g.
you have images :
'I1.jpg','I2.jpg'...'In.jpg'
Isample = imread('I1.jpg')
Istack = zeros(size(Isample,1),size(Isample,2),n,class(Isample)); %Preallocate zeros of size and class of the whole stack
for ii = 1:n
    Istack(:,:,ii) = imread(['I' num2str(n) '.jpg']);
end

See FAQ 4.12, 4.6
http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Image analysis (emulsion droplet size)

From: ImageAnalyst

Date: 15 Sep, 2010 14:44:14

Message: 7 of 14

On Sep 15, 9:26 am, traynor85 <trayno...@gmail.com> wrote:
> thanks for the reply and the info, didnt work to well for me. i would
> really appreciate some more help with this if i can email you with
> some of my images? also im looking to create' stacks' or an image
> sequences. the matlab manual only shows howe to creak this from video
> not still images.
--------------------------------------------------
Report back here any problems you have with blobsdemo. Maybe you
didn't follow the instructions where it tells you to make certain
modifications if you have older versions of MATLAB.

I'm surprised you don't know how to use http://drop.io. Seriously, it
doesn't GET any easier than that. You just choose any name you want
for your drop, such as traynor, then browse for the files you want to
upload. Then come back here and tell us the URL that you created. No
account to create, plus ability to upload images and other types of
files. Images are right there for us to look at immediately without a
bunch of click-throughs, plus we can easily download the files without
us creating accounts. It can't get any easier than this. Just a few
clicks to locate your file and you're done - very trivial. Where was
your difficulty?

I don't do email. Plus that would deprive you of suggestions from
other talented people here.
-ImageAnalyst

Subject: Image analysis (emulsion droplet size)

From: traynor85

Date: 16 Sep, 2010 09:05:22

Message: 8 of 14

again tahnks very much for te reply, i never even heard of or used
drop.io before and i thought i had to sign up and pay a annual fee
etc. but i followed your simple instructions, and your right, it
couldnt be any simpler. here is the url with a few of the images of
the emulsions: http://drop.io/traynor

im looking to measure the droplet diameter of the emulsion droplets.
when i adjust the threshold of the image and change it to binary i
either lose parts of the droplets or complete droplets.

Subject: Image analysis (emulsion droplet size)

From: ImageAnalyst

Date: 16 Sep, 2010 09:54:26

Message: 9 of 14

Try extracting just the blue channel of the image, thresholding it to
get the rings, then doing imfill to fill in the droplets. Something
like

blueChannel = rgbImage(:,:,3);
binaryImage = blueChannel < 127; % or whatever #
filledImage = imfill(binaryImage, 'holes');
labeledImage = bwlabel(filledImage);
measurements = regionprops(labeledImage);

Subject: Image analysis (emulsion droplet size)

From: traynor85

Date: 16 Sep, 2010 12:14:16

Message: 10 of 14

hi Sean, thanks for the replies, i have posted some of the images up
on http://drop.io/traynor if you can have a look at them and see if
you can do anything with them, thanks again.

mark.

Subject: Image analysis (emulsion droplet size)

From: Sean

Date: 16 Sep, 2010 14:38:04

Message: 11 of 14

traynor85 <traynor85@gmail.com> wrote in message <cd2dabc5-1acd-4a5d-bc24-b935a5db0575@k9g2000vbo.googlegroups.com>...
> hi Sean, thanks for the replies, i have posted some of the images up
> on http://drop.io/traynor if you can have a look at them and see if
> you can do anything with them, thanks again.
>
> mark.

I = imread('eb.jpg'); %The (4) image
%imtool(I)

%Map (aka Mask) (Convolution of Red Channel below an arbitrary threshold, determined from imtool-> adjust data)
M = (conv2(double(I(:,:,2)),ones(3),'same')<1650);

%Clear Border of Map
M = imclearborder(M);

%View just drops with Mask applied to see if they're what you want
imtool(bsxfun(@times,I,uint8(M)))

%Now do the analysis on the map.
%Connected Components
CC = bwconncomp(M);

%Since some aren't filled or connected and all are pretty round I'd give
%the convex hull a try. imfill(I,'holes') may be what you want but since
%a bunch of the rings aren't complete that wouldn't work.
RP = regionprops(CC,'ConvexImage','BoundingBox');
for ii = 1:length(RP)
    M(ceil(RP(ii).BoundingBox(2)):ceil(RP(ii).BoundingBox(2))+RP(ii).BoundingBox(4)-1,...
        ceil(RP(ii).BoundingBox(1)):ceil(RP(ii).BoundingBox(1))+RP(ii).BoundingBox(3)-1)...
        = RP(ii).ConvexImage;
end
imtool(M)

%The convex hull appeared to work on this image. Not sure if it'll work
%for all of them. It would yield bad results when two drops are touching
%forming an '8' or an infinity symbol
%
%Now redo regionprops() with the new map for whatever measurements you're looking for.
%

Subject: Image analysis (emulsion droplet size)

From: traynor85

Date: 26 Oct, 2010 13:42:24

Message: 12 of 14

hi Sean,

thanks for the previous scripts, they worked great for me. do you have
any scripts for measuring the area of the droplets in the B and W
images. i have uploaded three of the B and W images i generated with
the scripts to sent me, if you can help me with this i would be
grateful. Also if you know how to label the individual droplets in the
images that would be great too. heres the url for the images
http://drop.io/vb9yavq.

thanks again,

mark.

Subject: Image analysis (emulsion droplet size)

From: Sean

Date: 26 Oct, 2010 14:15:06

Message: 13 of 14

traynor85 <traynor85@gmail.com> wrote in message <d90bee5f-c7c1-4c4a-ab41-a0dfa46909c2@n26g2000yqh.googlegroups.com>...
> hi Sean,
>
> thanks for the previous scripts, they worked great for me. do you have
> any scripts for measuring the area of the droplets in the B and W
> images. i have uploaded three of the B and W images i generated with
> the scripts to sent me, if you can help me with this i would be
> grateful. Also if you know how to label the individual droplets in the
> images that would be great too. heres the url for the images
> http://drop.io/vb9yavq.
>
> thanks again,
>
> mark.

Compared to the last task this is easy:
Ibw = your_images;
Ibwinv = ~Ibw; %invert so drops are white background is black

use BWLABEL to label it:
ILabel = bwlabel(Ibwinv);

use REGIONPROPS to retrieve the area:
areas = regionprops(ILabel,'Area');

Subject: Image analysis (emulsion droplet size)

From: Sean

Date: 26 Oct, 2010 14:17:04

Message: 14 of 14

traynor85 <traynor85@gmail.com> wrote in message <d90bee5f-c7c1-4c4a-ab41-a0dfa46909c2@n26g2000yqh.googlegroups.com>...
> hi Sean,
>
> thanks for the previous scripts, they worked great for me. do you have
> any scripts for measuring the area of the droplets in the B and W
> images. i have uploaded three of the B and W images i generated with
> the scripts to sent me, if you can help me with this i would be
> grateful. Also if you know how to label the individual droplets in the
> images that would be great too. heres the url for the images
> http://drop.io/vb9yavq.
>
> thanks again,
>
> mark.

Compared to the last task this is easy:
Ibw = your_images;
Ibwinv = ~Ibw; %invert so drops are white background is black

use BWLABEL to label it:
ILabel = bwlabel(Ibwinv);

use REGIONPROPS to retrieve the area:
areas = regionprops(ILabel,'Area');

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us