View License

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

» Watch video

Highlights from
Image segmentation & Extraction

  • seg.mThis is a program for extracting objects from an image. Written for vehicle number plate segmentation and extraction
  • View all files
3.0 | 97 ratings Rate this file 209 Downloads (last 30 days) File Size: 19.5 KB File ID: #8031 Version: 1.0

Image segmentation & Extraction


Jeny Rajan (view profile)


14 Jul 2005 (Updated )

This program segments and extracts objects from an image.

Editor's Notes:

Popular File 2008 2009 2010 2011

| Watch this File

File Information

A simple program for object extraction from images.

Required Products Image Processing Toolbox
MATLAB release MATLAB 6.1 (R12.1)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (155)
15 Feb 2017 ilamparithi E

Hi I'm doing project on "text extraction from image using ensemble methods"...I need a matlab code for decision tree..plz do consider this and help u...

Comment only
13 Feb 2017 siva prakash

tumor size measurement after segmentation in matlab source code

Comment only
30 Jan 2017 qais ahmed

thank you in advance

27 Dec 2016 pei liu

many many thanks, I'll have a try!

19 Dec 2016 rami mohsen

30 Oct 2016 Oh Farid !

Hello everyone. im doing my project which is extracting wound image using Dynamic Color Distribution Entropy of Neighborhoods technique. Anyone have seen or using this technique? please help me find out this coding.

thanx in advance.

Comment only
21 Sep 2016 ramin barati

Hello everyone.. im doing my project in Image Processing(brain tumor seg.) using ACO tech.(ant colony optimization)
so can anyone pls help me find out the codings of it..
im urgently in need of it...

Comment only
11 Aug 2016 Hui Zhou

thank you

05 Jul 2016 lucky

lucky (view profile)

i have a project on traffic sign detection..plz provide me code for the same

Comment only
02 Feb 2016 shodhan gk

Anybody having code for hand written circuit recognition using matlab...thank u in advance..
if hav means plz send me(

30 Dec 2015 monika shah

hello, i am having problem extracting features from segmented mammogram images. can anybody provide me code for feature extraction? my email id is,, thankyou!

Comment only
14 Aug 2014 NITHYA

NITHYA (view profile)

pls guide me to form the fitness function in PSO for brain tumor detection using gray value of the image

22 Jul 2014 MALU P

MALU P (view profile)

Pls get me the code for segmentation

Comment only
05 May 2014 swathi

swathi (view profile)

05 Apr 2014 MUFIX

MUFIX (view profile)

04 Apr 2014 sindhu

sindhu (view profile)

02 Mar 2014 Himani Chaudhary

plz tell me after extracting building and their shadow using envi how we calculate the length of shadow automatically?
Is their any code for obtaining this length?
thanx a lot in advance

Comment only
16 Feb 2014 komal

komal (view profile)

hey everyone, can i get the code for deep segmentation of an image using kn-n algorithm..
my email id is please do forward.

04 May 2013 hoang

hoang (view profile)


18 Apr 2013 Harold

Harold (view profile)

Is it possible to store the logical array of each segment into a 3 dimensional array? I need to be able to call up the logical array representation of each segment.

Comment only
02 Dec 2012 Antonio

27 Nov 2012 prinston

hi , your code was easy to underestand , thanx :) but i hav ea question plz answer it as soon as possible : how can i extract all of components by loop? i tried so many ways but in every single of them i faced an error , may you pleas explain it to us? thax alot

Comment only
19 Oct 2012 raj

raj (view profile)

Hello everyone.. im doing my project in Image Processing(brain tumor seg.) using ACO tech.(ant colony optimization)
so can anyone pls help me find out the codings of it..
im urgently in need of it...

Comment only
28 May 2012 Jandial

hello, my email is If anybody can have code regarding Text Extraction From images using DWT.please send me

Comment only
28 May 2012 Jandial

hello sir, i am doing my research work in Text Extraction From images using DWT.Can I get matlab coding regarding this project .I mainly face problem to remove non- text regions, help me sir.

25 Apr 2012 endlessdesiresenator

13 Apr 2012 pankaj soni

is this program worked only for given image?
What is the application of this program beyond the test image "car3.jpg" ?

18 Mar 2012 Mehmet Erdem

does anyone studied 'The Pixon Method Image Segmentation' with MATLAB? any ideas about how should i proceed?

Comment only
11 Feb 2012 priswe kumari

hey!i m doing my final year project on Multivariate image segmentation using semantic region growing with adaptive edge penalty by A.k can i get source code of it.i want it for reference.?if any one has kindly mail it to

02 Feb 2012 NAVIN

NAVIN (view profile)


Comment only
17 Jan 2012 sunil Kumar

how to use loop to extract all number

Comment only
21 Nov 2011 hemanth kumar

i got the output.. it's really good.... i need the algorithm how to extract the features from the segmented images ... Anybody can help me plz my id

02 Jun 2011 paramveer sran


Comment only
02 Jun 2011 Jyothilekshmi

please give me the code for marching cubes.

Comment only
04 May 2011 paramveer sran

wht should i enter when it asks for 'enter the file name'car3.jpg is giving error Undefined variable "car3" or class "car3.jpg".

19 Apr 2011 zheli hairan

im=imread(k)is wrong ,it should be im=imread('k');

29 Mar 2011 raj kumar

hi jeny rajan i am rajesh doing my final semester project can i able to get code for number plate location using contour algorithm thanks in advance.just for reference i think it will help me to build my code with regards rajesh

Comment only
25 Feb 2011 mimi phuong

Hello Jeny,
How does it work for 3D case? for the msk and B?

Comment only
30 Dec 2010 siri mendu

sir im doing project on face recognition plz send me the code for face feature extraction

Comment only
13 Dec 2010 Narendra Ravilla

01 Dec 2010 Tranos

Tranos (view profile)

I am trying to code the use of local median in active contour without edges but I don't understand the following: Correspondingly, f1 and f2 are computed with
f1 = median(u0 ∗ H(φ) ∗W) (10)
f2 = median(u0 ∗ (1 − H(φ)) ∗W) (11)
How do f1 and f2 look like?
Can some1 help?

Comment only
10 Nov 2010 Kasun Karunathilake

10 Nov 2010 Ganesh Prasad Kashyap

28 Sep 2010 Jay Moothy

Can i get matlab code for watershed segmentation???

Comment only
13 Sep 2010 lalitha


Comment only
03 Sep 2010 dileep kumar

Enter the file nameseg.m
??? Error using ==> imread at 357
Can't open file "C:\Users\ghost\Documents\MATLAB\seg" for reading;
you may not have read permission.

Error in ==> seg at 8

plz help me overcome this error.......................

i wish to detect specific fungi colonies that are of black/white coloured......these colonies have different patterns......plz help me in dis regard

Comment only
14 Jul 2010 valli

valli (view profile)

10 Jul 2010 Dalal

Dalal (view profile)

i am trying to segment the image of signature
is it possible to apply the same code ? if not ,, can anyone help me plz
thank you

02 Jul 2010 Damien Garcia

Damien Garcia (view profile)

06 Jun 2010 Ben

Ben (view profile)

please dont forget mail id is.....

Comment only
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
05 Jun 2010 Prashant Somani

26 May 2010 Examples Learn By

Thank you for your great effort

19 May 2010 saurabh pandey

plzzz send me a matlab code for image segmentation using morphology.......plzzzz somebody help me...

Comment only
12 May 2010 saurabh pandey

pls send some matlab code(.m file) for image segmentation using mail id is.......

Comment only
30 Apr 2010 Matt

Matt (view profile)

12 Apr 2010 Airballman


I don't really see what use could ber done by such a code beyond the example... It is good I think in order to have a first approach of basic functions use if you are a Matlab newbie (rgbtogray, bwlabel, ...) that you sometimes search for hours.

However, I don't really see who may use taht in the future...

Comment only
19 Mar 2010 Mark Hayworth

Mark Hayworth (view profile)

I'm truly baffled why this poorly commented, poorly coded, piece of ad hoc code is the third most downloaded in the last 30 days. It just must be self perpetuating - people see it at the top of the list and download it so it stays at the top of the list. It is so bad in too many ways to list. The author clearly doesn't know how to use the Image Processing Toolbox functions. If you want a much, much better image segmentation demo/tutorial, check out this one: (A pick of the week)

27 Feb 2010 nonie ideris

dear sir,
i have a picture of a horse with human, but i only need to extract an image of a horse, thus, i decided to try doing region of interest method. can u please show me the coding to do image segmentation using ROI? thank you so much for your help. =)

12 Feb 2010 michael scheinfeild

its good idea but not so general since the number of the connected labels can be change and the id i think should be added information of shape of digits for improvr rate of recognition

20 Jan 2010 TIAN RUONAN

thank you

Comment only
25 Nov 2009 Renji

Renji (view profile)

well good work

25 Sep 2009 hendra togi

hi sir..
I have a project in Digital Image Processing.
My project title is : Robust DWT-SVD Domain Image Watermarking.
I have a problem. after applying SVD to cover image and the visual watermark, I have no idea hoe to modify the singular values of the cover image in each subband with the singular values of the visual watermark
Thank you.

16 Sep 2009 Ashar

Ashar (view profile)

Dear Jenny rajan,
here in my case first i need to read an image from the expm then need to normalize the concentrations in the chamber from 1 to 0, 1 for brighter image and 0 for dark they are black and white and to compute the standard deviation along some lines perpendicular to the chamber axis to see the mixing in that chamber. how to write a program to calculate this. Your feed back will be highly appreciated. Thanks in advance

Comment only
21 Jun 2009 bhuvaneswari

i want to know how this program cuts a certain portion and also i want to know how to make this extract with true colour. pls give me solution soon

Comment only
15 Jan 2009 Michael Jordan

07 Jan 2009 kumar kumar

how to give the value if i want to get all the text objects. if i give 17 i get only one , if i give any other i get only some dot.....

Comment only
18 Dec 2008 Rushmi

Rushmi (view profile)

What if I want to extract the plate from image of high resolution.
Also I want to extract the whole frame from the image.

Comment only
02 Dec 2008 Chung-yeon Lee

thanks for the simple code.
it's exactly what i wanted!

26 Nov 2008 Saravanan

its working fine, great. is there any technique to find automatically ROI. I am working on fingerprint compression.

Comment only
16 Oct 2008 gourav kumar soni

thank you ,, it helhs me.

27 Sep 2008 majid uwanoich

hi, I can not download it?!!!

Comment only
24 Sep 2008 huang etoun

Comment only
17 Sep 2008 florin raja

27 Aug 2008 javid ullah


18 Aug 2008 Al F

sorry i'm a complete idiot, it does what it's supposed to. Ignore the last comment!

18 Aug 2008 Al F

??? The function, script, or class seg
cannot be indexed using {} or . indexing.

24 Jul 2008 jiang maple


19 Jul 2008 chenna rao


Comment only
16 Jul 2008 RC Choong

i got ant error in this
??? Attempt to execute SCRIPT edge as a function.
Error in ==> car at 11
BW = edge(im1,'sobel'); %finding edges
can u help me find out what is problem, thank you

Comment only
05 Jun 2008 mohammad amin abou harb

extremely specific i mean you chose the 17th object in L==17 no intelligence as far as im concerned

31 May 2008 mes liste

20 May 2008 Sujeong You


Comment only
19 May 2008 Shashank Tyagi

gr8 it worked for me ...

19 May 2008 oodbae adriano

it didn't work by me. all commands would be described as unknown

Comment only
15 May 2008 sunil samant

12 May 2008 chuleeporn Kan

Thanks .

05 May 2008 krishna patteti

19 Mar 2008 Phyu Moe

For teaching and learning

13 Mar 2008 Lev Che

05 Mar 2008 Francois Appert

12 Feb 2008 fizz aq


04 Feb 2008 rama prad

26 Jan 2008 benchalgo SAMY

goood software...

Comment only
24 Jan 2008 manoj kannan

23 Jan 2008 manoj kumar


23 Jan 2008 manoj kumar

good for software implementation

Comment only
19 Jan 2008 Xz Xz


02 Jan 2008 Diego Barragán

very good

19 Dec 2007 martin ruzek

I think you should connect all the commands that are needed, for example I am not able to run it because I dont have command rgb2gray and others

09 Dec 2007 yuanquan wang

01 Dec 2007 ko soe


Comment only
14 Nov 2007 yousef mowaswasah


04 Oct 2007 paresh patel

02 Oct 2007 liao zhijian

thank you

27 Sep 2007 Aya kh


Comment only
27 Sep 2007 amy lia

22 Sep 2007 selma salem

When i use quadtree program to segmente my grayscale image, i get in the result a binary image segmented!, can you help me to obtain a grayscale one.

Comment only
31 Aug 2007 Soumen Barik

I think it will help us in our project..

27 Aug 2007 Zahra Chaghazardi

Dear Chris Shoemaker
I am working on the watermarking project in spread spectrum domain. I want to simulate it by matlab. can you help me about this?

Comment only
21 Jul 2007 wenjun wu

02 Jul 2007 Taner Ince

25 Jun 2007 loges waran

good work

19 Jun 2007 suresh siri


Comment only
05 Jun 2007 gelare ta

05 Jun 2007 Deepak Malani Malani

18 Apr 2007 yati mr

03 Apr 2007 mohan p


01 Apr 2007 Maoyuan Chen

Good work!

Comment only
13 Mar 2007 Anonymous Voter

12 Mar 2007 sneha latha

28 Feb 2007 RAVI RAVI


Comment only
26 Feb 2007 fucking crack

You cannot start the m-file with clear all. It doesn´t work.

21 Feb 2007 Özkan SARI

only reads your image. I tested with some other car images and your program fails.

14 Feb 2007 brijesh tripathi

31 Jan 2007 Gaurav Tripathi

This is a gud one.

28 Jan 2007 avinash pokhriyal


Comment only
26 Jan 2007 Maria Garcia

This is goooooood!

25 Jan 2007 Chunyi Chen


08 Jan 2007 s b

Good work!

06 Jan 2007 subasri muthalraj

24 Nov 2006 Lihardo Ranja


16 Nov 2006 kruthika rathinavel

im getting an error == > conv2

Comment only
15 Nov 2006 a moh

i tried to run it but i get this error
??? Error using ==> conv2
First and second arguments must be single or double.

Error in ==> seg at 20
B=conv2(BW,msk); %Smoothing image to reduce the number of connected components


Comment only
01 Nov 2006 gaurav santhalia

plz tell me what input should i when it is asked to give input i give as car3...but there is an error...plz suggest me...

Comment only
19 Oct 2006 Karthik Raja

Simply Padam... ok Good

10 Oct 2006 mohan reddy

06 Jun 2006 mohamed hassan

thank you

25 May 2006 Simon Lin

BW arguments must be single or double, if so, please update code.

Comment only
08 May 2006 Benamira Elias

Thanks Jeny! Simple and useful

03 May 2006 Mohamed Sami

nice work

21 Apr 2006 Mahdi Yazdian

10 Apr 2006 nejat rahman

04 Apr 2006 cool coolleen

i m doing my final year project of mini portions segmentation method in face recognition using matlab. may i know how to put my cropped small portions of the face into matrix (eg: 6x9 matrix, where 6 refer to number of photos, n 9 refer to the number of small portions). by the way, i also would like to know how can i compare the matrix column by column in order to get the eigenvalues. n i m new to matlab, so i hope u will help me to clear my doubts. if u have to source code, pls send a copy to me. thanks and really appreciate for your help. Hope can hear from u soon.

Comment only
15 Mar 2006 Tony Gladvin George

As Mr.Sergei KOptenko indicated, line no:17 "B=conv2(BW,msk)" will throw an error. Please use "B=conv2(double(BW),msk)", instead.

07 Mar 2006 Alex Denone

01 Mar 2006 boonrit pongsatitpat


Comment only
02 Feb 2006 venkatesh sundararaj

13 Jan 2006 Xin Huang

too simple and meaningless. more complex examples need to be added. and objects extraction can be subdivided to supervised method and Un-su one, this code is an Un-su algorithm, can it extract all the objects of interests in an Un-supervied approach?

07 Jan 2006 lissa anastasia

tq for the code.i try to run this code into matlab..but why the command 'imread' is going error?below is the error..

Enter the file nameseg.m
??? Attempt to execute SCRIPT imread as a function.

Error in ==> Untitled8 at 7

15 Oct 2005 mufid mufid

i used part of the porgram for detect license plate of the car but.. there many other object is there any one can help me to fill the other edge or object without effect the license plate?

Comment only
13 Sep 2005 Wang Bin

Well done.
The contour detection is good.But I am confused what does the last figure intend to show?

05 Aug 2005 Jagannath Reddy

19 Jul 2005 Ajimon S

Really good

15 Jul 2005 Sergei Koptenko

1) In Matlab R14(SP2) it gives:

??? Error using ==> conv2
First and second arguments must be single or double.

Error in ==> seg at 17
B=conv2(BW,msk); %Smoothing image to reduce the number of connected components

2) What is the application of this program beyond the test image "car3.jpg" ?

22 Apr 2016 1.0

adding BSD license

Contact us