0% found this document useful (0 votes)
284 views

Image Processing and Counting Using MATLAB PDF

The document provides instructions for performing image processing and object counting using MATLAB. It describes 7 steps: 1) Read an image, 2) Convert it to grayscale, 3) Threshold the image, 4) Complement the image, 5) Find boundaries of objects, 6) Draw the boundaries, and 7) Count the number of objects. The tutorial uses functions like imread(), rgb2gray(), im2bw(), bwboundaries() to process an image of lines and count the number of objects found.

Uploaded by

SelvaGanapathy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
284 views

Image Processing and Counting Using MATLAB PDF

The document provides instructions for performing image processing and object counting using MATLAB. It describes 7 steps: 1) Read an image, 2) Convert it to grayscale, 3) Threshold the image, 4) Complement the image, 5) Find boundaries of objects, 6) Draw the boundaries, and 7) Count the number of objects. The tutorial uses functions like imread(), rgb2gray(), im2bw(), bwboundaries() to process an image of lines and count the number of objects found.

Uploaded by

SelvaGanapathy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Explore (/tag/typeid/)

(/)
(/)

Create (/about/submit.jsp)

Login(/account/login)
Contests
Community (/community/)
let's
make (/contest/) | SignUp(/account/gopro?sourcea=header)

share what you make >


(/editInstructable/)

ImageProcessingandCountingusingMATLAB byadityareddy(/member/adityareddy/)
Download(/id/ImageProcessingandCountingusingMATLAB/?download=pdf)
(/id/ImageProcessingandCountingusingMATLAB/?ALLSTEPS)

7Steps

(/id/ImageProcessingandCountingusingMATLAB/step6/DrawtheBoundaries/
Collection

(http://cdn.instructables.com/FSA/D5WS/GAA12G8Z/FSAD5WSGAA12G8Z.LARGE.jpg)

IMadeit!

Favorite

Share

AboutThisInstructable
82,331views

License:

33favorites
adityareddy
(/member/adityareddy/)
www.ingeniumblog.net
(http://www.ingeniumblog.net)

(http://cdn.instructables.com/FWN/SG85/GAA0EKMP/FWNSG85GAA0EKMP.LARGE.jpg)

(/member/adityareddy/)
Follow

(http://cdn.instructables.com/FIF/BB3A/GAA0WWI7/FIFBB3AGAA0WWI7.LARGE.jpg)

12

Bio: Oh,hithere!MynameisAditya
Reddy.IamanElectronicsEngineer,
Softwaredeveloperandatechblogger.
Youcanseemoreofmyworksatmy
websitewww.ingeniumblog.net.Ihavea
passionfordevel...readmore
(/member/adityareddy/)

(http://cdn.instructables.com/F45/UZ0U/GAA0EKMQ/F45UZ0UGAA0EKMQ.LARGE.jpg)

ThisisfunprojectbasedonimageprocessingwithMATLAB,herewewillcome
accrosslearinghowtocountthenumberofdistinguishableobjectsinanimage.
Soundsfun,dosentitSoletsgetstarted!
(http://cdn.instructables.com/FWT/FI1T/GAA12G9E/FWTFI1TGAA12G9E.LARGE.jpg)

Tags:
MATLAB(/tag/typeid/categorytechnology/keyword
matlab/)
image(/tag/typeid/categorytechnology/keyword

ThefollowingtutorialisperformedwiththehelpofMATLAB.MATLABstandsfor
MATrixLABoratoryandisanumericalcomputingenvironmentandfourth
generationprogramminglanguage,developedbyMathWorks.UsingMATLAB,
wecansolvetechnicalcomputingproblemsfasterthanwithtraditional
programminglanguages,suchasC,C++,andFortran.
(http://cdn.instructables.com/FR2/85VZ/GAA12G9L/FR285VZGAA12G9L.LARGE.jpg)
Thetutorialcanbeperformedbyexecutingthecommandsineachstep
sequentiallyinthecommandwindowofMATLAB.

image/)
processing(/tag/typeid/categorytechnology/keyword
processing/)
counting(/tag/typeid/categorytechnology/keyword
counting/)
threshold(/tag/typeid/categorytechnology/keyword
threshold/)

Related

CreatingaFunctionin
MATLAB(/id/Creatinga
FunctioninMATLAB/)
byJordanStolle
(/member/JordanStolle/)

PlottingDatausing
MATLAB(/id/Plotting
DatausingMATLAB/)
byColin_Gregg
(/member/Colin_Gregg/)
RemovetheseadsbySigningUp(/account/gopro?
sourcea=removeads&nxtPgName=Image+Processing+and+Counting+using+MATLAB&nxtPg=/id/ImageProcessingandCounting
usingMATLAB/)

InstrumentedSoda
Machine
(/id/InstrumentedSoda
Machine/)
byadarsh_murthy

Step1:ReadtheImage

MatlabMultithreading,
EASY(/id/Matlab
MultithreadingEASY/)
byleevonk(/member/leevonk/)

Harmonicanalysis(THD)
ofaRectifierusing
MATLABandPlotly
(/id/Harmonicanalysis
THDofaRectifier
SeeMore(/tag/typeid/?q=)

(http://cdn.instructables.com/FSA/D5WS/GAA12G8Z/FSAD5WSGAA12G8Z.LARGE.jpg)

Animageischoosensothatithasconsiderablecontrastwithitsbackgroundso
thattheobjectscanbeidentified.Thefunctionimreadreadstheimagefroma
givenlocationandstoresitinthematriximg1.Theimshowfunctiondisplaysthe
image.

img1=imread('Lines.jpg')
imshow(img1)

Step2:ConverttheImagetoGrayscale

(http://cdn.instructables.com/FWN/SG85/GAA0EKMP/FWNSG85GAA0EKMP.LARGE.jpg)

Thisstepremovesanycolorinformationintheimagetomakeiteasiertoidentify
objects.Thergb2grayconvertsthecolorimageintoagrayscaleimageand
storesitintothematriximg2.
img1=rgb2gray(img1)
imshow(img1)

Step3:Thresholdtheimage

(http://cdn.instructables.com/F45/UZ0U/GAA0EKMQ/F45UZ0UGAA0EKMQ.LARGE.jpg)

Thisstepthresholdstheimagebyconvertingthegrayscaleimageintoanimage
thatcontainsonlytwocolors.Thefunctionim2bw()assignsblackcolortoallthe
pixelsthathaveluminositythanathresholdlevelandtheothersaswhite.the
functiongraythresh()approximatelycalculatesthethresholdoftheimage.
img2=im2bw(img1,graythresh(img1))
imshow(img2)

Step4:Complementtheimage

(http://cdn.instructables.com/FIF/BB3A/GAA0WWI7/FIFBB3AGAA0WWI7.LARGE.jpg)

Inthisstepwecomplementtheimagebyusingthe~operator.Bythiswe
convertthewhitepatchesintoblackandviceversa.Weperformthisstepaswe
wantedtheareasofconcern(objects)tobecoloredwhite.
img2=~img2
imshow(img2)

Step5:FindtheBoundariesoftheObjects

(http://cdn.instructables.com/FWT/FI1T/GAA12G9E/FWTFI1TGAA12G9E.LARGE.jpg)

ThisstepfindstheboundariesofeachobjectthatitfindsandstoresitinB.The
textfunctionprintsthenumberofobjectsthatarefoundbybwboundaries.

B=bwboundaries(img2)
imshow(img2)
text(10,10,strcat('\color{green}ObjectsFound:',num2str(length(B))))
holdon

Previous
Next(/id/ImageProcessingandCountingusingMATLAB/step6/DrawtheBoundaries/)
ViewAllSteps(/id/ImageProcessingandCountingusingMATLAB/?ALLSTEPS)

Wehaveabenicecommentpolicy.
Pleasebepositiveandconstructive.

IMadeit!

mani.ranjh89(/member/mani.ranjh89/)

AddImages

MakeComment

2monthsago

Reply

hyguys
(/member/mani.ranjh89/)

ineedsomehelp
ihaveanimageofascannedtxtandiwanttodokmeanclustering....into3
clustersofbackground,upgroundanddityareas...

(http://cdn.instructables.com/FG6/LMKV/I1ETXW87/FG6LMKVI1ETXW87.LARGE.jpg)

akshaydhone(/member/akshaydhone/)

2monthsago

Reply

2monthsago

Reply

3monthsago

Reply

1yearago

Reply

thnxbuddy
(/member/akshaydhone/)

akshaydhone(/member/akshaydhone/)

thnxbuddy
(/member/akshaydhone/)

aeksaekhow(/member/aeksaekhow/)

Thanksyou:)
(/member/aeksaekhow/)

eman_anum(/member/eman_anum/)

thankyou..agreathelpforme..:)..ionlyfoundthiseasytoturialtodothat
taskaftersearching..Godblessudear
(/member/eman_anum/)

dean88(/member/dean88/)

1yearago

Reply

goodjob..
myquestion:howaboutvehicle...?howtocountingvehicle?
(/member/dean88/)
herethepicture:http://postimg.org/image/m1u3jyqlp/

dkz(/member/dkz/)

2yearsago

Reply

NIceworkdone.Likethiscanutellhowtodetectobjectsinanimageandfind
theirlocations.Itwillbeveryuseful.
(/member/dkz/)

kmittal2(/member/kmittal2/)

2yearsago

Reply

Itispossiblethattheobjectsappearoverlappedinimage.Isitstillpossibleto
counttheirnumbers?
(/member/kmittal2/)

JungleMugsy(/member/JungleMugsy/)

3yearsago

Reply

MygirlfriendhadtodosomethinglikethisforaclassusingMatlab.Toobad
shedidn'treadthisfirst!
(/member/JungleMugsy/)

arzoo105(/member/arzoo105/)

4yearsago

Reply

4yearsago

Reply

4yearsago

Reply

thxbro
(/member/arzoo105/)

naziabhi(/member/naziabhi/)

nicework
(/member/naziabhi/)

irtiq7(/member/irtiq7/)

Adityabhaithisisslick.........Iamlovingitgreatwork
(/member/irtiq7/)

adityareddy(/member/adityareddy/)(author) irtiq7

4yearsago

Reply

4yearsago

Reply

thanx!!
(/member/adityareddy/)

fuego316(/member/fuego316/)

Greatwork,Ithinkeveryoneshouldlearnthebasicslikethis!Youcouldalso
usethewatershedfiltertopickourobjectsnotsoclearlydefined.Itcouldbe
(/member/fuego316/)
usefultoshowsomethinglikethatasannextstepforpeoplewhowanttotryit
withanyblobstructuresthatmaytouch.

adityareddy(/member/adityareddy/)(author) fuego316
4yearsago

maybeimplanning2fillthoseupinmynext
instructable.Thanxanyway!!
(/member/adityareddy/)

tanmanknex(/member/tanmanknex/)

4yearsago

Reply

Reply

WhenIfirstlookedatthatfirstimage,IthoughtitlookedfamiliarbutIcouldn't
placeit.WhenIclosedoutofthebrowsertwentyminuteslater,irealizedthat
(/member/tanmanknex/)
mydesktophasthatasthebackground.That'sbasicallymylifeforyou.

adityareddy(/member/adityareddy/)(author) tanmanknex
4yearsago

Ya,icould'ntthinkofanythingwhenihavethaton
mydesktop.
(/member/adityareddy/)

bishopdante(/member/bishopdante/)

Reply

4yearsago

Reply

4yearsago

Reply

Matlabrules.Niceone.
(/member/bishopdante/)

Culturespy(/member/Culturespy/)

Morepeopleneedtoknowthisstuff!
(/member/Culturespy/)

AboutUs

FindUs

WhoWeAre(/about/)

Facebook(http://www.facebook.com/instructables)

Advertise(/advertise/)

Youtube(http://www.youtube.com/user/instructablestv)

Contact(/about/contact.jsp)

Twitter(http://www.twitter.com/instructables)

Jobs(/community/PositionsavailableatInstructables/)
Help(/id/howtowriteagreatinstructable/)

Pinterest(http://www.pinterest.com/instructables)
Google+(https://plus.google.com/+instructables)
Tumblr(http://instructables.tumblr.com)

Join our newsletter:

enteremail

Join!

TermsofService(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
PrivacyStatement(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
LegalNotices&Trademarks(http://usa.autodesk.com/legalnoticestrademarks/) | MobileSite(http://m.instructables.com)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
2014Autodesk,Inc.

English

Resources

Mobile

ForTeachers(/teachers/)

DownloadournewappsforiOS,

ArtistsinResidence(http://www.autodesk.com/artistinresidence/home)

AndroidandWindows8!

GiftProAccount(/account/give?sourcea=footer)
Forums(/community/)
Answers(/tag/typequestion/?sort=RECENT)
Sitemap(/sitemap/)

Android
(https://play.google.com/store/apps/details?
id=com.adsk.instructables)
iOS
(https://itunes.apple.com/app/instructables/id586765571)
Windows
(http://apps.microsoft.com/windows/en
us/app/7afc8194c771441a9590
54250d6a8300)

GoProToday(/account/gopro?sourcea=footer)

We'reHiring!(/community/PositionsavailableatInstructables/)

You might also like