Vous êtes sur la page 1sur 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/)

Vous aimerez peut-être aussi