View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Image Segmentation Tutorial

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.73118
4.7 | 96 ratings Rate this file 894 Downloads (last 30 days) File Size: 6.57 KB File ID: #25157 Version: 1.6
image thumbnail

Image Segmentation Tutorial

by

Image Analyst (view profile)

 

27 Aug 2009 (Updated )

Image Processing Tutorial to demonstrate the basic concepts to beginner users.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

Perfect for the beginner, this demo illustrates simple object detection (segmentation, feature extraction), measurement, and filtering. Requires the Image Processing Toolbox (IPT) because it demonstrates some functions supplied by that toolbox, plus it uses the "coins" demo image supplied with that toolbox. If you have the IPT (you can check by typing ver on the command line), you should be able to run this demo code simply by copying and pasting this code into a new editor window, and then clicking the green "run" triangle on the toolbar.
First finds all the objects, then filters results to pick out objects of certain sizes. The basic concepts of thresholding, labeling, and regionprops are demonstrated with a simple example.

It's a good tutorial for those users new to MATLAB's image processing capabilities to learn on, before they go on to more sophisticated algorithms.

Tested with R2008b through R2011b.

Acknowledgements

This file inspired Extraction Of Hemorhhages, Extraction Of Exudates, Detection Of Microaneurysms, Simple Color Detection By Hue(), and Cell Analyzer.

Required Products Image Processing Toolbox
MATLAB release MATLAB 8.5 (R2015a)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (156)
08 Nov 2016 Boson Saya  
04 Nov 2016 MAI BAC  
21 Oct 2016 Purushottam Ekande  
28 Sep 2016 Arthur Gallina  
09 Sep 2016 Suresh Kumar Jetti

Dear Image analyst,

Thank you very much for the codes again. I am a neuroscientist from MIT and I'm really impressed by your recent code. I have an example neural calcium imaging tiff file (stack a tiff files from one video). I have to extract calcium signals (peaks, ROIs) from individual synaptic site. The goal is to map the synapses when they are active. I really believe that your code can solve of my problem. Could you please help more in this regard?

Thank you so much,

Kind regards
Suresh

09 Sep 2016 Suresh Kumar Jetti

I really enjoyed this code. I have some back ground in image analysis yet these codes are very informative.
Please post more advance example as well. Thank you

03 Sep 2016 xuan du

Good demon to novice like me. Thanks alot

25 Aug 2016 Moj

Moj (view profile)

Hello Image Analyst, I am going to do some analysis on an image and i need to write a code to recognize the coordinates of different points of red color automatically without human interfering. I will be grateful if you propose some methods. Thanks in advance.

Comment only
24 Aug 2016 preethika sanil  
10 Aug 2016 Ken Cheung

Nice job.Thanks for your sharing.

15 Jul 2016 sumana

sumana (view profile)

Nice tutorial. Thank you

22 Jun 2016 andhavarapu lokesh

sairam to all members ,
can anyone give me the code of otsu thresolding for applying on to thyroid dicom images

Comment only
21 Jun 2016 Robert Garnett

Excellent!

I did it the hard way until I saw this and then it was so-easy.

Thanks

02 Jun 2016 Aaron Greenbaum  
19 May 2016 srijan sharma  
12 May 2016 Steve Cohen  
08 May 2016 Tim-Van Ho  
15 Apr 2016 LEVENT TASCI  
08 Apr 2016 ainzul hafiz

GUD

Comment only
03 Apr 2016 Manu BN

Manu BN (view profile)

Awesome work. Inspired by you I have also uploaded 13 of my projects for sharing knowledge. Plz checkout https://in.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A620308&sort=ratings_desc

22 Mar 2016 Himanshu Tyagi

anyone help me? In my thesis work on content image retrieval using HSV CCV and LBP ..please provide me email id if possible mine is himanshu.atra@gmail.com

22 Mar 2016 Ashok Tripathi

Quite helpful. And so nicely documented.

01 Mar 2016 arrjun balaratnam

Hello, I currently have an image of the veins binarized. I've tried using parts of your code so that i could then find the coordinates of the the edges/nodes of the image but have had no luck. Any tips would be appreciated.

Comment only
27 Feb 2016 Image Analyst

Image Analyst (view profile)

If anyone has specific questions about how to adapt this demo to their specific image, post the image and problem description to the Answers forum here on the Mathworks website.

Comment only
27 Feb 2016 haider alnaqeeb

hello dear i need your kind support to find the center of an object in a binary image in order to i can crop that object from the binary image, note that the binary image has only one object no more so that ow can i determine the center of that object

30 Jan 2016 Imanalyst  
23 Jan 2016 RahulDate

Thanks, the file helped me to understand segmentation.

How can same be used with the DICOM images? Can you help me with the feature extraction of the images?

Comment only
31 Dec 2015 Nasr Gharaibeh  
30 Dec 2015 Mugabi Samuel

Wow; I agree you are the best teach at Image analysis and processing; This tutorial helped me a lot indeed THANK YOU VERY MUCH;

I would like to learn from you more as I also approach my project; Please write to me at: powellorenz@gmail.com

So I can ask you some questions.

THANKS

08 Dec 2015 askaryaqs askaryaqs

thanks for your sharing, this is helping me

30 Nov 2015 Fatin S

hye. can i ask u some private question on how i can detect the circle like u do but my circle not really circle because the picture i snap was a tennis ball and pingpong ball.can u give me a solution please.i try your coding but it didn't seem work.really need your help.and please email me at fatinsarah31@gmail.com if u feel free.tyvm

Comment only
22 Nov 2015 Nasr Gharaibeh

Excellent, thank you

Comment only
19 Nov 2015 Bergercookie  
06 Nov 2015 Image Analyst

Image Analyst (view profile)

Ramses, you just flip the sign of the > sign to < so that it finds dark objects instead of bright objects.

Comment only
06 Nov 2015 Philip Fischer  
14 Sep 2015 Ramses Herrera

How would one handle images where the object intensities are much lower, say segmentation of organs in a CT?

Cheers,
Ramses H.

14 Sep 2015 Pradeep Bhaskar

Thank you, this is excellent.

25 Aug 2015 Raga dinesh

its very useful for me.. thank you..

04 Aug 2015 slickbot

Thank you for the amazing tutorial. what do i do if i have to extract a certain section from image who's orientation can be anyway.

29 Jul 2015 Abdullah

I have a question,
is there an automatic way to filter the unwanted regions from a binary image , where the wanted regions are character candidates in different scales (sometimes big letters and sometimes small)?
please help me out

23 Jul 2015 marwan saeed

important

02 Jul 2015 manasvin upadhyay  
29 Jun 2015 eyp say

Perfect!!! thank you for sharing.

21 Jun 2015 majed majed

great work !!
thank you a lot.

30 Apr 2015 Su

Su (view profile)

 
16 Apr 2015 Ardhi Santoso  
04 Apr 2015 Sergei Paleichuk  
17 Mar 2015 izyan hanum  
15 Mar 2015 Haidar

Haidar (view profile)

 
18 Feb 2015 Nisha S Rani

please send us the code

Comment only
05 Feb 2015 Ridho

Ridho (view profile)

thank for sharing

30 Dec 2014 Abdur Rahmaan  
07 Dec 2014 amruta

amruta (view profile)

 
19 Nov 2014 Salaheddin Hosseinzadeh

Thanks a lot for sharing ;)

18 Oct 2014 Akash Ghode  
22 Sep 2014 Dakala Jayachandra  
20 Sep 2014 Durga

Durga (view profile)

 
12 Sep 2014 Rushikesh Tade

Nice work!

11 Sep 2014 alex yang  
22 Apr 2014 Shien Kwun Leong

Dear Image Analyst,

Thank you for this beautiful code. I'm trying to use it for oil palm ripeness detection.

13 Apr 2014 ramin bba

Looks simple and sophisticated at the same time! Full of comments and as such easy to follow the chain of thoughts of the author. One can simply make adjustments based on his/her needs. Great job Image Analyst!

28 Mar 2014 fereshte

hi

i get an error...please help me.

??? Error using ==> cd
Cannot CD to (Name is nonexistent or not a directory).

Comment only
26 Mar 2014 xsfeng

xsfeng (view profile)

Dear Image Analyst,

Thanks for this beautiful code. I have a minor question concerning about the 'keeper' blob image. Is that possible that we segment the keeper blobs while still keep their numbers on it? Like tracing which number of blobs are the brightest and which number are the darkest? How should I write the code?

Thanks for your help!

Comment only
24 Mar 2014 Yogesh Babu

Hello,
I used this code to find the Area of the each object this file does,But I am in need of number occurrence of same object should be known and that should be plotted..

24 Feb 2014 Scott

Scott (view profile)

Works perfectly - very helpful!!

29 Dec 2013 Onesmo

Onesmo (view profile)

 
25 Dec 2013 Explorer

I also got the same errors as xsfeng when I run it.

Error using fileparts
Too many output arguments.

Error in BlobsDemo (line 191)
[thisFolder, baseFileName, ext, version] = fileparts(thisFile);

Comment only
14 Dec 2013 Lourdes

dghgfh

12 Dec 2013 raviraja  
04 Dec 2013 xsfeng

xsfeng (view profile)

Dear Image Analyst,

I got the error information when I run this scripts:

Error using fileparts
Too many output arguments.

Error in BlobsDemo (line 191)
[thisFolder, baseFileName, ext, version] = fileparts(thisFile);

Could you please help me with this? Many thx!

Comment only
02 Dec 2013 adan flores

ok good programing

Comment only
23 Sep 2013 Image Analyst

Image Analyst (view profile)

mustafs, the more sophisticated algorithms are more dependent on image content. More complicated content requires more complicated algorithms. I did add some demos on color segmentation, but I want to stick to fairly standard kinds of segmentation since there are an infinite number of unique, peculiar ones.

Comment only
23 Aug 2013 hilal

hilal (view profile)

 
21 Jul 2013 Mario Garcia  
19 Jul 2013 mangood UK

dear image analyst,
can you please make to us more advance segmentation algorithms for different industrial application
the segmentation process is the most hard operation for all

19 Jul 2013 Valeska Pearson  
19 Jul 2013 Valeska Pearson

Hello image analyst,

How did you obtain the values to divide between foreground and background, at your thresholding code.

for example, why 70 and 0.94
thresholdValue - 70), double(0.94 * maxYValue(2))

Comment only
24 May 2013 Jean Bilheux

Looking at the code taught me a few new tricks ...very nice.

12 May 2013 Chethan

Awesome, a nice presentation on feature extraction.

06 May 2013 Arul

Arul (view profile)

 
12 Apr 2013 Charles

This is so helpful. Thank you so much!

02 Mar 2013 brahim ouali

Excellent!!!

16 Feb 2013 vo danh  
16 Feb 2013 MOHD

MOHD (view profile)

 
15 Feb 2013 Image Analyst

Image Analyst (view profile)

Nina, to do that exactly, you'd need to use John D'Errico's interparc program. Look for it in the File Exchange. You can also subsample, like thisBoundary(1:10:end,2) though these won't necessarily be evenly spaced in distance.

Comment only
08 Feb 2013 Nina

Nina (view profile)

Very useful demo. I do have a question Image Analyst - I hope you see this! For the part of the code:

boundaries = bwboundaries(binaryImage);
numberOfBoundaries = size(boundaries);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
hold off;

Is it possible to plot say only 10 points equally spaced around the boundary? Are they in order say clockwise or anticlockwise?

06 Jan 2013 Richi

Richi (view profile)

Very nice, saved me at least one day!

06 Jan 2013 mustafa alnasser  
12 Nov 2012 Nad

Nad (view profile)

is the actual tutorial available to watch online? cannot seem to locate it.

Comment only
21 Oct 2012 Image Analyst

Image Analyst (view profile)

If anyone has any questions about their own specific images, they should ask in the Answers forum (look at the menu above). Do not put your specific question here as a comment on this program. I can help there in Answers. This page is not meant to be a discussion forum.

Comment only
19 Oct 2012 microF

microF (view profile)

Hello Image Analyst ,

your demo is excatly what I am looking for to analyse my fluorescence images. However my images are taken with a 12 bit peltier cooled fluorescence camera and saved as .tif. I can hence not display their histograms without getting an error:
" Warning: Image is too big to fit on screen; displaying at 67% "

I tried to plot the histogram using

plot_size = get(0,'ScreenSize');
fg1 = figure(1);
set(fg8, 'Color', [1 1 1], 'Position', plot_size, 'Visible', 'on');
[pixelCount grayLevels] = imhist(orginalimage);
bar(pixelCount); title('Histogram of orginalimage');
xlim([0 grayLevels(end)]);

but it didnt help. I would really appreciate any help and comments.

Cheers
microF

Comment only
21 Sep 2012 abhinav gupta

Hey this demo has been very useful.....my project is wavelength calculation using diffraction grating, so we get an image which will be a series of round dots and we should find the distance between two successive points.......so with this blob i can find the dots but how to find the centres of those dots?????? plz help me anyone... i would be greatful......ty in advance

21 Sep 2012 Steven

Steven (view profile)

Thanks for showing us a basic demo. It helped a lot!

11 Sep 2012 MML

MML (view profile)

thanks for sharing this demo. This provides a very good example for beginners.

Comment only
11 Sep 2012 MML

MML (view profile)

 
22 Aug 2012 Image Analyst

Image Analyst (view profile)

Christie, when you adapted it, you had it read in a color image, even if it doesn't look like it. Do this to prove: [rows columns NumberOfColorChannels] = size(yourImage). Use rgb2gray() right after you call imread() to convert your color image into a gray scale image.

Comment only
24 Jul 2012 Christie

Hey, Image Analyst,

Sorry, I tried to send this as a message first but kept getting an error from the site. Anyway, I am using your BlobsDemo to find the area of leaf surfaces traced onto a piece of graph paper. The code has no problem translating it into a binary image with clearly defined leaves and no graph paper grid, but when it tries to label each blob I get the following error:

??? Error using ==> iptcheckinput
Function BWLABEL expected its first input, BW, to
be two-dimensional.

Error in ==> bwlabel at 67
iptcheckinput(BW, {'logical' 'numeric'}, {'real',
'2d', 'nonsparse'}, ...

Error in ==> LeafArea at 48
labeledImage = bwlabel(binaryImage, 8); % Label
each blob so we can make measurements of it

What does it mean when it says the image isn't 2-dimensional?

Thanks for your help,

Christie

02 Jun 2012 khalid

khalid (view profile)

 
30 May 2012 Aliyu Abdu

I'm finding your Demo quite very useful in my work. Thank you.

31 Mar 2012 zaidan

zaidan (view profile)

it's nice info for beginner thank's

22 Feb 2012 Ryan

Ryan (view profile)

 
19 Feb 2012 Tulips

Tulips (view profile)

 
20 Jan 2012 Image Analyst

Image Analyst (view profile)

Syahrul, it does do segmentation into several areas - each coin is a different area. How can you label something without having a binary image? You can't, but why would you want to avoid labeling even if you could?

Comment only
20 Jan 2012 Image Analyst

Image Analyst (view profile)

sivan, you must have a color image for some reason. You probably changed the filename to one of your images. Coins.png that my demo uses is a monochrome (gray scale) image.

Comment only
19 Jan 2012 Syahrul Niezam

is it possible to do segmentation into several areas, not binarization before labeling?

Comment only
06 Dec 2011 Fer

Fer (view profile)

 
05 Nov 2011 Image Analyst

Image Analyst (view profile)

If anyone wants to ask me a question, click my name above, then click the "Contact Author" link.

Comment only
24 Aug 2011 Nicolas  
13 Aug 2011 sivan saminathen

can any wan help me...why i got error in the code when i try to run it..in line 41-[pixelCount grayLevels] = imhist(originalImage);...this code..the error said

("??? Error using ==> iptcheckinput
Function IMHIST expected its first input, I or X, to be two-dimensional.")

why it said so...i just keep on follow the code given but suddenly it give error

Comment only
22 Jul 2011 Lim

Lim (view profile)

Hi I appreciate this demo very much. I modify your code to work along with watershed segmentation for my image (blood cell), and it turns out good. However, how do I filter the background after I plot the boundaries of the selected cell? (so that the resulting image only shows the blobs without the background) The cropping works very well too but I don't want to involve the background. Thank you.

05 Jun 2011 Image Analyst

Image Analyst (view profile)

German:
You ask this kind of question on the newsgroup or on Answers, not as a comment on people's File Exchange submissions. I'd be happy to answer it there.

Comment only
24 May 2011 German Espinal

Please I need some help !!! I need to capture a basic color card with my webcam, then I need to determine what color is it. Matlab code analize and gives the answer. Example: The card is yellow. Can someone of you Help me please with the MatLab code ???? TKS A lot !!!

Comment only
22 May 2011 German Espinal

Hi guys !!! I need to capture a primary color card with my webcam, then I need to determine what color is it ??? Can someone of you Help me please with the MatLab code ???? TKS A lot !!!

Comment only
10 May 2011 K

K (view profile)

Thanks!

10 May 2011 K

K (view profile)

I should read code comments more thoroughly. No need to answer. Thanks!

24 Apr 2011 akbarul

thank you

Comment only
10 Mar 2011 Jason

Jason (view profile)

 
01 Mar 2011 Pierre

Pierre (view profile)

Please can somebody send me the matlab code for gray scale image segmentation plzzzz...?I will be very greatful

Comment only
01 Mar 2011 shantha

Hello!

I'm pretty new to matlab.Can you offer some help regarding my issue?
I need a code to extract objects from a single image and write the extracted objects to separate images.As an example if an image consists of say an elephant and tree , I want to extract these two objects and write as separate images..

Comment only
22 Feb 2011 Nicolas

Very cool code.

Comment only
21 Feb 2011 Nicolas  
05 Feb 2011 Image Analyst

Image Analyst (view profile)

Manhal, I used Photoshop to create an image with 12 coins and it worked just fine. You must have done something wrong.

Comment only
05 Feb 2011 Image Analyst

Image Analyst (view profile)

Vivek, what is it about this that made you think it was a 1 star? Is there anything I could improve with it to help beginners understand it better?

Comment only
12 Jan 2011 Manhal

Manhal (view profile)

and one more thing, I tried to change the image that is used in the BlobsDemo, by adding 2 more coins, but still show that we already have 10 objects...
is there something should I change to make it works??

Comment only
03 Dec 2010 Naresh Pai

Useful and well-commented code that demonstrates image thresholding. Connected components, including real world objects, in an image is of interest to many and this code provides the starting point for such projects. Thanks IA.

12 Nov 2010 Anthony

An excellent demonstration of simple image segmentation. Also a nice introduction to the image toolbox in Matlab. The functions for dealing with connected components (centroid, mean, etc) should be extremely useful.

02 Nov 2010 Vivek Maik  
15 Oct 2010 Image Analyst

Image Analyst (view profile)

J.D, you need to get some model of skin color. I know that it's a boomerang- or banana-shaped cluster in HSV color space. You need to define parameters to model that, and then segment it, possibly with a 3D lookup table instead of a mathematical model, or with the mathematical model if you can come up with the formulas. But I know you can't simply do high and low thresholding in any color space to carve out a box that selects the skin color pixels.

Comment only
24 Sep 2010 J.D

J.D (view profile)

hello ~ i juz want to ask you what should i do if i want to recognize color of human skin~ i want to get its hsv value for every pixel of the human face ~ and then exlude the eye and mouth part~ i want to get the value as my input to train in neural network~ can u help me~ urgent.. tq~

Comment only
22 Sep 2010 Image Analyst

Image Analyst (view profile)

Christopher. Yes there are lots of more complicated images that could be used that would be more challenging. I work with many of those kinds of images. However I know from my newsgroup postings that even code as simple as this blows a lot of people away. So thanks for the suggestion but I think I'll keep it simple. I do have some color demos posted that are slightly more challenging.

Comment only
15 Aug 2010 Walaa Gouda

Hi I am working in my master about breast cancer mass detection the first step is to determine region of interest which is the breast contour and i need help in this step as i don't know how to do this so please if there is anyone who can help me
thanks

Comment only
01 Jul 2010 trypsin

i am just trying it

Comment only
01 Jul 2010 Christopher

Interesting demonstration ImageAnalyst. Fortunately the 'coins' sample image has high contrasting content which allows for easy selection of the threshold. Plus the coins allow for the 'imfill' operation to perform the majority of the work.

It would be interesting to see results on an image with a much smoother histogram but this is where image segmentation gets complicated I guess...

All in all, a nice demonstration of the capabilities that both the IPT and Mathematical Morphology can provide in image processing applications.

Comment only
01 Jul 2010 Nitin

Nitin (view profile)

 
06 Jun 2010 Ben

Ben (view profile)

hello every body, can you give me a code for building extraction using mathematical morphologie ?? and thanks a lot

Comment only
17 May 2010 Farie

Farie (view profile)

Hi, I've tried your demo but it's not working for 3D images. Is there any way to solve this problem? Thanks

Comment only
14 Apr 2010 aravind prajan  
25 Mar 2010 Image Analyst

Image Analyst (view profile)

Like other submissions that are meant to demonstrate certain toolboxes, you need to have the toolbox. If you don't have it, you can buy it, or write the necessary toolbox functions yourself. Generally they are the functions starting with the letters "im" or "bw".

Comment only
25 Mar 2010 John Brathwaite

What if I don't have the IPT??

Comment only
12 Mar 2010 David JL

I just realized I use Matalb R2007b, not R2008. I guess that is the problem. Sorry about that.

09 Mar 2010 Kris

Kris (view profile)

Very useful...great work...

12 Feb 2010 Yuvaraj

great work..I have one question for U. using my web cam i will capture a picture which will contain a ball in a room. now how can i separate the ball (circular shaped) from the background and i want to find the area of that ball(circle). how can i edit your code for this particular task.

Comment only
07 Feb 2010 Nitin

Nitin (view profile)

 
05 Feb 2010 Image Analyst

Image Analyst (view profile)

Jimmy - ask in the newsgroup. Let's take this conversation there.

Comment only
30 Jan 2010 Jimmy

Jimmy (view profile)

Ok let's forget about GUI, I am not even sure if I need to use it. The reason I asked if I can get more than one image read is than after I modified the code I got my the centroids of all objects in the images. The results are in vector form [x y]. For example
[29 134]. I want to make a loop going through all images and objects in them, reading those measurements. Can you give me an advice? Thank you

Comment only
28 Jan 2010 Husam Aldahiyat

Excellent!!!

27 Jan 2010 Image Analyst

Image Analyst (view profile)

Jimmy, just paste whatever code you want into line 1076 of that app after you've deleted lines 1076-1164. Then just run it with the green triangle. You need all the rest of the code because that is the GUI. To select images, you simply click on their names in the listbox like you'd do with any app. No code is needed from you to handle clicking on a listbox - that's already done for you. Just click on the images you want to process and click the analyze button and it will analyze only those that you've clicked on.

Comment only
25 Jan 2010 Jimmy

Jimmy (view profile)

Ok I did as you said Image Analyst.I got some errors. Now do I only use 1076 - 1164 code or the whole Magic code which is huge? And another thing how do I select images from a folder? Do I need to put that into the code? Thank you

Comment only
24 Jan 2010 Image Analyst

Image Analyst (view profile)

Jimmy, just follow these easy step by step instructions.
1. Open both his MAGIC code and my BlobsDemo code in MATLAB.
2. Copy all of my BlobsDemo code into the clipboard.
3. Go to AnalyzeSingleImage in his code, currently line 1075, and simply delete all of that function, which means delete lines 1076 - 1164. This is just like it says to do in the comments on line 1070 and 1071 of his code.
4. Now simply paste in my BlobsDemo code.
Now it should work. Adapt my/your code in that function as you see fit.

Comment only
23 Jan 2010 Jimmy

Jimmy (view profile)

Thank you for your reply Image Analyst. Yes, I know that I need to make changes according to the pictures regarding threshold etc.. What I don't understand is how to plug that code into AnalyzeSingleImage(). Is it possible for you to send me the example on testbest1@yahoo.com. Thank you

Comment only
22 Jan 2010 Image Analyst

Image Analyst (view profile)

Jimmy, sure - just copy the code into your own program. One way to do it might be to use this in conjunction with MAGIC (http://www.mathworks.com/matlabcentral/fileexchange/24224) which does batch processing. Just take this code and plug it into his AnalyzeSingleImage() function. Then you'll be able to select several images from your folder, and process them. Of course, my code has several things that are special for the coins image and you'd have to modify several things for your images, such as the thresholds, etc.

Comment only
17 Jan 2010 Jimmy

Jimmy (view profile)

Great Work Image Analyst, very useful indeed. I want to ask one question: is there any chance that it can be applied to more than one image simultaniously? And if there is how can it be done. Thank you

Comment only
05 Dec 2009 Image Analyst

Image Analyst (view profile)

Thomas, this is not an error in my code. sprint() is not a function - ParseInputs() should have called sprintf() instead. regionprops() and ParseInputs() are Mathworks code, not mine. I searched the R2008b version of ParseInputs and it no longer has sprint() in it, so they've fixed that bug.

Sorry that I can't test this with every prior version of MATLAB. I know it definitely works with R2008a and later. Since you are several years behind I suggest you get the most modern version of MATLAB.

Comment only
29 Nov 2009 ThomasKUL Knaepen

Not working for me:

Running BlobsDemo.m...
??? Undefined command/function 'sprint'.

Error in ==> regionprops>ParseInputs at 878
msg = sprint('This measurement is not a string: "%d".', list{k});

Error in ==> regionprops at 114
[L, requestedStats] = ParseInputs(officialStats, varargin{:});

Comment only
29 Nov 2009 ThomasKUL Knaepen

I got :

MATLAB Version 7.1.0.246 (R14) Service Pack 3
and the IPT

Comment only
29 Aug 2009 us

us (view profile)

an excellent and exceptionally well commented image processing demo by a seasoned ML user and senior CSSM citizen...

a few changes i'd make:
- put it into a function
-> no need for the bad CLEAR ALL...
- make the figure size smaller -and-
- put an ECHO ON/OFF at the beginning/end of the demo
-> for users to be able to enjoy the comments during run-time...

just a few thoughts
us

Updates
25 Mar 2010 1.1

Added label numbers to each blob. Extracted each blob to a separate image.

26 Mar 2010 1.3

Updated description and made change to how labeled image is displayed.

10 Apr 2010 1.4

Spelling correction in the description.

16 Mar 2012 1.5

Renamed main title and altered description slightly.

03 Apr 2015 1.6

Updated for R2015a.

Contact us