Sei sulla pagina 1di 30

Institute of Business & Technology (Artificial Intelligence)

Artificial Intelligence

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


LIST OF EXPERI E!TS
1. 2. To learn how to select coins from groins. To learn how to identify round objects.

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


I!"EX S.N O. NAME O T!E E"#E$%MENT #E$ O$ME& &ATE S'(M%TTE& &ATE #A)E NO. $EMA$*S

########################## SI$!AT%RE OF FA&%LT'

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

EXPERIMENT NO. 01
Title: - To learn ho( to select coins fro) groins* Objective: + To learn ho( to select coins fro) ,ifferent coins in atla-* It.s si)/le atla- /rogra) (hich selects an, ,is/lay a single circle of an original coin* (I) Co pete!cy "#ill: + generic & hence shoul, -e re/eate, in se0eral e1/eri)ents* (II) E$pe%i e!t Objective: 2* To learn -asic 0aria-les ,eclaration in ata- for Artificial Intelligence an, co)/uter 0isions* 3* To learn ho( o-4ects (ill -e selecte, in atla-* 5* &on0ert intensity i)age to -inary i)age* (III) T&eo%etic'l ('c#)%o*!d: + 1-+i,io!.-*tot&%e,&olde%: &on0ert intensity i)ages to -inary i)ages* Autothreshol,ing uses Otsu6s )etho,7 (hich ,eter)ines the threshol, -y s/litting the histogra) of the in/ut i)age to )ini)i8e the 0ariance for each of the /i1el grou/s* "y!t'$: ./ vi,io!.-*tot&%e,&olde% %et*%!, ' "y,te object0 .0 t&'t '*to 'tic'lly co!ve%t, '! i!te!,ity i ')e to ' bi!'%y i ')e. -l)o%it& : This o-4ect i)/le)ents the algorith)7 in/uts7 an, out/uts ,escri-e, in the Autothreshol, u/co)ing e1a)/le* The o-4ect /ro/erties corres/on, to the -loc9 /ara)eters7 e1ce/t: 'ou can only s/ecify a 0alue of Ignore or Saturate for the In/utRange;iolationAction /ro/erty of the Syste) o-4ect* The o-4ect ,oes not su//ort the Error an, <arn an, Saturate o/tions that the corres/on,ing (hen ,ata range is e1cee,e, -loc9 /ara)eter offers* E$' ple:
>>X=imread('peppers.png'); >>imshow(X); >>img = im2single(rgb2gray(imread('peppers.png'))); >>figure, imshow(img); >>hautoth = vision. utothresholder; >>bin = step(hautoth,img); >>pause(2); >>figure;imshow(bin);

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

1-"tep : Play 0i,eo or i)age se=uence* "y!t'$: ,tep(.0I) "escri/tion: ste/(>7I) sen,s one fra)e of a )ulti,i)ensional 0i,eo I7 or i)age se=uence to the 0i,eo /layer* 2-3i!d(): The fin, function ,eter)ines the in,ices of array ele)ents that )eet a gi0en logical con,ition* In its si)/lest for)7 fin, returns a colu)n 0ector of in,ices* Trans/ose that 0ector to o-tain a ro( 0ector of in,ices* (I+) M'tl'b E$pe%i e!t Code: ! sele"ting "oin from goins hautoth = vision. utothresholder; hboundtra"e = vision.#oundary$ra"er; ! %ead in the image & = imread('"oins.png'); imshow(&); ! othresholding to binari'e the image. bw = step(hautoth,&); ! (erive the start points )row, "ol*= find(bw,+); startpts = )row,2;"ol*; ! (etermine the boundaries y = step(hboundtra"e,bw,startpts); y(y == -) = )*; ! (isplay the results figure, imshow(bw); hold('on'); plot(y(2.2.end,.)/+,y(+.2.end, .)/+,'r','0inewidth',2);

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

(+) Re,o*%ce %e4*i%ed: -

atla- 0ersion ? Release 2@ or a,0ance 0ersion

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


(+I) P%ec'*tio!,: 2* 3* 5* @* It.s case sensiti0e soft(are* For scri/ting use &trlA! an, for ren,ering /ress FB* Se)i colon is necessary after each line -ut not in the )i,,le of the loo/* &trlAR is use, for co))ents*

(+II) P%oced*%e: 2* <rite a /rogra) as /er )entione, in the la-* 3* &trlA! for ne( atla- /rogra)* 5* FB for co)/ilation an, e1ecution* @* Re=uire, i)age is as follo(s* B* Follo(ing is the )ain )enu of atla-*

(+III) Ob,e%v'tio! o% C'lc*l'tio!,: 2* Ty/e your o-ser0ation CDDDDDDDDDDD* 3* ############################################################################### ############################################################################### ############################################################################### ############################################################################### Developed by:Adnan Alam
Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


############################################################################### ########################################################################* (IX) Re,*lt: 2* Stu,ent )ust ty/e the result or out/ut of the /rogra)CDDDDDDDDDDDDDD** 3* ################################################################################### #####################################################################* (X) INTERPRET-TION O3 RE"56T: -

(XI) CONC65"ION: -

(XII) E$pe%i e!t Rel'ted 7*e.2* "efine the follo(ing ter)s an, (rite your ans(ers in o-ser0ation* vi,io!.-*tot&%e,&olde%8 vi,io!.(o*!d'%yT%'ce%8 i %e'd()8i ,&o9()8,tep()8 :i!d()8:i)*%e8 plot()8 &old(;o!;)8 3* "efine co)/uter 0ision* 5* <hy (e use i)ages in co)/uter 0isionEArtificial Intelligence* (XIII) -,,e,, e!t:S*!o* E1/eri)ent a1* ar9 O-taine, Process 2 3 Sa)/le co,e Algorith) 3 3 Developed by:Adnan Alam
Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


5 @ B 2 3 5 @ Flo( chart Synta1 Tea) Lea,ershi/ "esire, Result Inter/retation of Result atla- han,ling ;i0a 3 3 3 Pro,uct 3*B 3*B 3*B 3*B

(XI+)De,i%ed O*tp*t:-

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


EXPERIMENT NO. 01
Title: - To learn ho( to i,entify roun, o-4ects* Objective: + To learn ho( to i,entify roun, o-4ects fro) ,ifferent sha/e o-4ects in atla-* It.s si)/le atla- /rogra) (hich selects an, ,is/lay roun, o-4ects* (I) Co pete!cy "#ill: + generic & hence shoul, -e re/eate, in se0eral e1/eri)ents* (II) E$pe%i e!t Objective: @* To learn -asic 0aria-les ,eclaration in ata- for Artificial Intelligence an, co)/uter 0isions* B* To learn ho( o-4ects (ill -e selecte, in atla-* F* &on0ert intensity i)age to -inary i)age* (III) T&eo%etic'l ('c#)%o*!d: + 1-+i,io!.-*tot&%e,&olde%: &on0ert intensity i)ages to -inary i)ages* Autothreshol,ing uses Otsu6s )etho,7 (hich ,eter)ines the threshol, -y s/litting the histogra) of the in/ut i)age to )ini)i8e the 0ariance for each of the /i1el grou/s* "y!t'$: ./ vi,io!.-*tot&%e,&olde% %et*%!, ' "y,te object0 .0 t&'t '*to 'tic'lly co!ve%t, '! i!te!,ity i ')e to ' bi!'%y i ')e. -l)o%it& : This o-4ect i)/le)ents the algorith)7 in/uts7 an, out/uts ,escri-e, in the Autothreshol, u/co)ing e1a)/le* The o-4ect /ro/erties corres/on, to the -loc9 /ara)eters7 e1ce/t: 'ou can only s/ecify a 0alue of Ignore or Saturate for the In/utRange;iolationAction /ro/erty of the Syste) o-4ect* The o-4ect ,oes not su//ort the Error an, <arn an, Saturate o/tions that the corres/on,ing (hen ,ata range is e1cee,e, -loc9 /ara)eter offers* E$' ple:
>>X=imread('peppers.png'); >>imshow(X); >>img = im2single(rgb2gray(imread('peppers.png'))); >>figure, imshow(img); >>hautoth = vision. utothresholder; >>bin = step(hautoth,img); >>pause(2); >>figure;imshow(bin);

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


1-"tep : Play 0i,eo or i)age se=uence* "y!t'$: ,tep(.0I) "escri/tion: ste/(>7I) sen,s one fra)e of a )ulti,i)ensional 0i,eo I7 or i)age se=uence to the 0i,eo /layer* 2-3i!d(): The fin, function ,eter)ines the in,ices of array ele)ents that )eet a gi0en logical con,ition* In its si)/lest for)7 fin, returns a colu)n 0ector of in,ices* Trans/ose that 0ector to o-tain a ro( 0ector of in,ices* <. %)b1)%'y(): &on0ert R$B i)age or color )a/ to grayscale* I C rg-3gray(R$B) con0erts the true color i)age R$B to the grayscale intensity i)age I* rg-3gray con0erts R$B i)ages to grayscale -y eli)inating the hue an, saturation infor)ation (hile retaining the lu)inance* Algo: rg-3gray con0erts R$B 0alues to grayscale 0alues -y for)ing a (eighte, su) of the R7 $7 an, B co)/onents: 0.1=>= ? R @ 0.A>B0 ? C @ 0.11<0 ? (
E.g.1. GG IC i)rea,(6-oar,*tif6)H GGI C rg-3gray(I)H GGfigure7 i)sho((I)7 figure7 i)sho((I)H E.g.2. +on,ert the colorma- to a grayscale colorma-. GGJX7)a/K C i)rea,(6trees*tif6)H GGg)a/ C rg-3gray()a/)H GGfigure7 i)sho((X7)a/)7 figure7 i)sho((X7g)a/)H A. )%'yt&%e,&(): $lo-al i)age threshol, using Otsu6s )etho,* le,el . graythresh/%0 co)/utes a glo-al threshol, (le0el) that can -e use, to con0ert an intensity i)age to a -inary i)age (ith i)3-(* Le0el is a nor)ali8e, intensity 0alue that lies in the range JL7 2K* E.g.1. GGI C i)rea,(6coins*/ng6)H GGle0el C graythresh(I)H GGB< C i)3-((I7le0el)H GGi)sho((B<)

(I+) M'tl'b E$pe%i

e!t Code: -

! 1tep +. %ead 2mage ! %ead in pills3et".png. %4# = imread('pillset".png'); imshow(%4#); ! 1tep 2. $hreshold the 2mage

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


! 5onvert the image to bla"6 and white in order to prepare for boundary tra"ing using bwboundaries. 2 = rgb2gray(%4#); threshold = graythresh(2); bw = im2bw(2,threshold); figure,imshow(bw); ! 1tep 7. %emove the 8oise ! 9sing morphology fun"tions, remove pi&els whi"h do not belong to the ob:e"ts of interest. ! remove all ob:e"t "ontaining fewer than 7- pi&els bw = bwareaopen(bw,7-); ! fill a gap in the pen's "ap se = strel('dis6',2); bw = im"lose(bw,se); ! fill any holes, so that regionprops "an be used to estimate ! the area en"losed by ea"h of the boundaries bw = imfill(bw,'holes'); figure,imshow(bw); ! 1tep ;. <ind the #oundaries ! 5on"entrate only on the e&terior boundaries. =ption 'noholes' will a""elerate the pro"essing by preventing bwboundaries from sear"hing for inner "ontours. )#,0* = bwboundaries(bw,'noholes'); ! (isplay the label matri& and draw ea"h boundary figure , imshow(label2rgb(0, >:et, ).? .? .?*)),figure , imshow(label2rgb(0, >:et, ).? .? .?*)); hold on for 6 = +.length(#) boundary = #@6A; plot(boundary(.,2), boundary(.,+), 'w', '0ineBidth', 2) end ! 1tep ?. (etermine whi"h =b:e"ts are %ound ! Cstimate ea"h ob:e"t's area and perimeter. 9se these results to form a simple metri" indi"ating the roundness of an ob:e"t. ! metri" = ;DpiDareaEperimeterF2. ! $his metri" is eGual to one only for a "ir"le and it is less than one for any other shape. $he dis"rimination pro"ess "an be "ontrolled by setting an appropriate threshold. 2n this e&ample use a threshold of -.H; so that only the pills will be "lassified as round. ! 9se regionprops to obtain estimates of the area for all of the ob:e"ts. 8oti"e that the label matri& returned by bwboundaries "an be reused by regionprops. stats = regionprops(0,' rea','5entroid'); threshold = -.H;; ! loop over the boundaries for 6 = +.length(#) ! obtain (X,I) boundary "oordinates "orresponding to label '6' boundary = #@6A; ! "ompute a simple estimate of the ob:e"t's perimeter delta3sG = diff(boundary).F2; perimeter = sum(sGrt(sum(delta3sG,2))); ! obtain the area "al"ulation "orresponding to label '6' area = stats(6). rea; ! "ompute the roundness metri" metri" = ;DpiDareaEperimeterF2; ! display the results metri"3string = sprintf('!2.2f',metri");

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


! mar6 ob:e"ts above the threshold with a bla"6 "ir"le if metri" > threshold "entroid = stats(6).5entroid; plot("entroid(+),"entroid(2),'6o'); end te&t(boundary(+,2),7?,boundary(+,+)/+7,metri"3string,'5olor','y',... '<ont1i'e',+;,'<ontBeight','bold'); end title()'Jetri"s "loser to + indi"ate that ',... 'the ob:e"t is appro&imately round'*);

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

(+) Re,o*%ce %e4*i%ed: -

atla- 0ersion ? Release 2@ or a,0ance 0ersion

(+I) P%ec'*tio!,: B* F* ?* M*

It.s case sensiti0e soft(are* For scri/ting use &trlA! an, for ren,ering /ress FB* Se)i colon is necessary after each line -ut not in the )i,,le of the loo/* &trlAR is use, for co))ents*

(+II) P%oced*%e: Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


F* <rite a /rogra) as /er )entione, in the la-* ?* &trlA! for ne( atla- /rogra)* M* FB for co)/ilation an, e1ecution* N* Re=uire, i)age is as follo(s* 2L*Follo(ing is the )ain )enu of atla-*

(+III) Ob,e%v'tio! o% C'lc*l'tio!,: 5* Ty/e your o-ser0ation CDDDDDDDDDDD* @* ############################################################################### ############################################################################### ############################################################################### ############################################################################### Developed by:Adnan Alam
Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


############################################################################### ########################################################################* (IX) Re,*lt: 5* Stu,ent )ust ty/e the result or out/ut of the /rogra)CDDDDDDDDDDDDDD** @* ################################################################################### #####################################################################* (X) INTERPRET-TION O3 RE"56T: -

(XI) CONC65"ION: -

(XII) E$pe%i e!t Rel'ted 7*e,tio!,. @* "efine the follo(ing ter)s an, (rite your ans(ers in o-ser0ation or in Oui8* vi,io!.-*tot&%e,&olde%8 vi,io!.(o*!d'%yT%'ce%8 i %e'd()8i ,&o9()8,tep()8 :i!d()8:i)*%e8 plot()8 &old(;o!;)8 %)b1)%'y()8)%'yt&%e,&()8 i 1b9()8 b9'%e'ope!()8 ,t%el()8 i clo,e()8i :ill()8b9bo*!d'%ie,()8l'bel1%)b()8%e)io!p%op,()8 B* "efine co)/uter 0ision* F* <hy (e use i)ages in co)/uter 0isionEArtificial Intelligence* (XIII) -,,e,, e!t:S*!o* E1/eri)ent a1* ar9 O-taine, Process 2 3 Sa)/le co,e Algorith) 3 3 Developed by:Adnan Alam
Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


5 @ B 2 3 5 @ Flo( chart Synta1 Tea) Lea,ershi/ "esire, Result Inter/retation of Result atla- han,ling ;i0a 3 3 3 Pro,uct 3*B 3*B 3*B 3*B

(XI+)De,i%ed O*tp*t:-

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


EXPERIMENT NO. 02
Title: - To learn ho( to ,etect cancer cell* Objective: + To learn ho( to ,etect cancer cell of ,ifferent sha/e o-4ects in atla-* It.s si)/le atla- /rogra) (hich selects an, ,is/lay cancer cell as an o-4ect* This e1a)/le sho(s ho( to ,etect a cell using e,ge ,etection an, -asic )or/hology* An o-4ect can -e easily ,etecte, in an i)age if the o-4ect has sufficient contrast fro) the -ac9groun,* In this e1a)/le7 the cells are /rostate cancer cells* (I) Co pete!cy "#ill: + generic & hence shoul, -e re/eate, in se0eral e1/eri)ents* (II) E$pe%i e!t Objective: ?* To learn -asic 0aria-les ,eclaration in ata- for Artificial Intelligence an, co)/uter 0isions* M* To learn ho( o-4ects (ill -e selecte, in atla-* N* &on0ert intensity i)age to -inary i)age* (III) T&eo%etic'l ('c#)%o*!d: + 1-+i,io!.-*tot&%e,&olde%: &on0ert intensity i)ages to -inary i)ages* Autothreshol,ing uses Otsu6s )etho,7 (hich ,eter)ines the threshol, -y s/litting the histogra) of the in/ut i)age to )ini)i8e the 0ariance for each of the /i1el grou/s* "y!t'$: ./ vi,io!.-*tot&%e,&olde% %et*%!, ' "y,te object0 .0 t&'t '*to 'tic'lly co!ve%t, '! i!te!,ity i ')e to ' bi!'%y i ')e. -l)o%it& : This o-4ect i)/le)ents the algorith)7 in/uts7 an, out/uts ,escri-e, in the Autothreshol, u/co)ing e1a)/le* The o-4ect /ro/erties corres/on, to the -loc9 /ara)eters7 e1ce/t: 'ou can only s/ecify a 0alue of Ignore or Saturate for the In/utRange;iolationAction /ro/erty of the Syste) o-4ect* The o-4ect ,oes not su//ort the Error an, <arn an, Saturate o/tions that the corres/on,ing (hen ,ata range is e1cee,e, -loc9 /ara)eter offers* Ste/ 2: Rea, I)age Rea, in the cell*tif i)age7 (hich is an i)age of a /rostate cancer cell*

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

!1tep + 2 = imread('"ell.tif'); figure, imshow(2), title('original image'); te&t(si'e(2,2),si'e(2,+)/+?, ... 'Krostate "an"er "ell', ... '<ont1i'e',L,'Mori'ontal lignment','right'); te&t(si'e(2,2),si'e(2,+)/2?, .... ' dnan 5omputer Nision', ... '<ont1i'e',L,'Mori'ontal lignment','right');

! 1tep2 )O, threshold* = edge(2, 'sobel'); fudge<a"tor = .?; #Bs = edge(2,'sobel', threshold D fudge<a"tor); figure, imshow(#Bs), title('binary gradient mas6'); seH- = strel('line', 7, H-); se- = strel('line', 7, -); #Bsdil = imdilate(#Bs, )seH- se-*); figure, imshow(#Bsdil), title('dilated gradient mas6');

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

!1tep ; #Bdfill = imfill(#Bsdil, 'holes'); figure, imshow(#Bdfill); title('binary image with filled holes');

!1tep? #Bnobord = im"learborder(#Bdfill, ;); figure, imshow(#Bnobord), title('"leared border image');

!1tep P se( = strel('diamond',+); #Bfinal = imerode(#Bnobord,se(); #Bfinal = imerode(#Bfinal,se(); figure, imshow(#Bfinal), title('segmented image');

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

!1tep L #Boutline = bwperim(#Bfinal); 1egout = 2; 1egout(#Boutline) = 2??; figure, imshow(1egout), title('outlined original image');

(I+) M'tl'b E$pe%i

e!t Code: -

!1tep + 2 = imread('"ell.tif'); figure, imshow(2), title('original image'); te&t(si'e(2,2),si'e(2,+)/+?, ... 'Krostate "an"er "ell', ... '<ont1i'e',L,'Mori'ontal lignment','right'); te&t(si'e(2,2),si'e(2,+)/2?, .... ' dnan 5omputer Nision', ... '<ont1i'e',L,'Mori'ontal lignment','right'); ! 1tep2 )O, threshold* = edge(2, 'sobel'); fudge<a"tor = .?; #Bs = edge(2,'sobel', threshold D fudge<a"tor); figure, imshow(#Bs), title('binary gradient mas6'); seH- = strel('line', 7, H-); se- = strel('line', 7, -); #Bsdil = imdilate(#Bs, )seH- se-*); figure, imshow(#Bsdil), title('dilated gradient mas6'); !1tep ; #Bdfill = imfill(#Bsdil, 'holes'); figure, imshow(#Bdfill); title('binary image with filled holes'); !1tep? #Bnobord = im"learborder(#Bdfill, ;); figure, imshow(#Bnobord), title('"leared border image'); !1tep P se( = strel('diamond',+);

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


#Bfinal = imerode(#Bnobord,se(); #Bfinal = imerode(#Bfinal,se(); figure, imshow(#Bfinal), title('segmented image'); !1tep L #Boutline = bwperim(#Bfinal); 1egout = 2; 1egout(#Boutline) = 2??; figure, imshow(1egout), title('outlined original image');

(+) Re,o*%ce %e4*i%ed: (+I) P%ec'*tio!,: -

atla- 0ersion ? Release 2@ or a,0ance 0ersion

N* It.s case sensiti0e soft(are* 2L*For scri/ting use &trlA! an, for ren,ering /ress FB* 22*Se)i colon is necessary after each line -ut not in the )i,,le of the loo/* 23*&trlAR is use, for co))ents* (+II) P%oced*%e: 22*<rite a /rogra) as /er )entione, in the la-* 23*&trlA! for ne( atla- /rogra)* 25*FB for co)/ilation an, e1ecution* 2@*Re=uire, i)age is as follo(s* 2B*Follo(ing is the )ain )enu of atla-*

(+III) Ob,e%v'tio! o% C'lc*l'tio!,: B* Ty/e your o-ser0ation CDDDDDDDDDDD* F* ############################################################################### ############################################################################### Developed by:Adnan Alam
Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


############################################################################### ############################################################################### ############################################################################### ########################################################################* (IX) Re,*lt: B* Stu,ent )ust ty/e the result or out/ut of the /rogra)CDDDDDDDDDDDDDD** F* ################################################################################### #####################################################################* (X) INTERPRET-TION O3 RE"56T: -

(XI) CONC65"ION: -

(XII) E$pe%i e!t Rel'ted 7*e,tio!,. ?* "efine the follo(ing ter)s an, (rite your ans(ers in o-ser0ation or in Oui8* :*d)e3'cto% 0 ed)e 0 ,t%el() 0 i dil'te() 0 i :ill()0 i cle'%bo%de%() 0 i e%ode()0 b9pe%i () 0 ,e)o*t() M* "efine co)/uter 0ision* N* <hy (e use i)ages in co)/uter 0isionEArtificial Intelligence* (XIII) -,,e,, e!t:S*!o* E1/eri)ent a1* ar9 O-taine, Process 2 3 Sa)/le co,e Algorith) 3 3 Developed by:Adnan Alam
Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


5 @ B 2 3 5 @ Flo( chart Synta1 Tea) Lea,ershi/ "esire, Result Inter/retation of Result atla- han,ling ;i0a 3 3 3 Pro,uct 3*B 3*B 3*B 3*B

(XI+)De,i%ed O*tp*t:-

EXPERIMENT NO. 0<


Title: - To learn ho( to )easure /ro/erties of o-4ects in a grayscale i)age* Objective: + The function %e)io!p%op, is 0ery useful for )easuring the /ro/erties of o-4ects in a -inary i)age* There are ,ocu)entation e1a)/les an, /ro,uct e1a)/les sho(ing ho( to ,o this* But so)eti)es you nee, to /rocess /i1el 0alues in the PoriginalP grayscale i)age* In other (or,s7 su//ose your /rocess is so)ething li9e this: 2* Seg)ent grayscale i)age to get a -inary i)age of o-4ects* 3* Analy8e the original grayscale /i1el 0alues corres/on,ing to each o-4ect in the -inary i)age* This e1a)/le sho(s you ho( to acco)/lish this (or9flo( using %e)io!p%op,* (I) Co pete!cy "#ill: + generic & hence shoul, -e re/eate, in -io)etrics e1/eri)ents* (II) E$pe%i e!t Objective: 2* To learn -asic 0aria-les ,eclaration in ata- for Artificial Intelligence an, co)/uter 0isions* 3* To learn ho( o-4ects (ill -e selecte, in atla-* 5* &on0ert intensity i)age to -inary i)age* (III) T&eo%etic'l ('c#)%o*!d: +
$he fun"tion regionprops is very useful for measuring the properties of ob:e"ts in a binary image. $here are do"umentation e&amples and produ"t demos showing how to do this. #ut sometimes you need to pro"ess pi&el values in the QoriginalQ grays"ale image. 2n other words, suppose your pro"ess is something li6e this. +. 1egment grays"ale image to get a binary image of ob:e"ts.

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


2. naly'e the original grays"ale pi&el values "orresponding to ea"h ob:e"t in the binary image. $his demo shows you how to a""omplish this wor6flow using regionprops. 1tep +. 5reate 1yntheti" 2mage 1tep 2. 5reate a #inary 2mage 1tep 7. 5al"ulate =b:e"t Kroperties 9sing Ki&el Nalues of 4rays"ale 2mage 1tep ;. 5al"ulate 5ustom Ki&el Nalue,#ased Kroperties

(I+) M'tl'b E$pe%i

e!t Code: -

! 1tep +. 5reate 1yntheti" 2mage ! 5reate a grays"ale image that "ontains some distin"t regions. 2 = props1ynthesi'e2mage; imshow(2) title('1yntheti" 2mage'); ! 1tep 2. 5reate a #inary 2mage ! 1egment the grays"ale image by "reating a binary image "ontaining ! the ob:e"ts in the image. #B = 2 > -; figure , imshow(#B) title('#inary 2mage'); ! 1tep 7. 5al"ulate =b:e"t Kroperties 9sing Ki&el Nalues of 4rays"ale ! 2mage.$he regionprops fun"tion supports several properties that "an ! be used with grays"ale images, ! in"luding 'Beighted5entroid', ! 'Jean2ntensity', 'Jin2ntensity', and 'Ja&2ntensity'. ! $hese properties use the original pi&el values of the ob:e"ts for ! their "al"ulations. s = regionprops(#B, 2, @'5entroid','Beighted5entroid'A); ! $o "ompare the weighted "entroid lo"ations with the unweighted ! "entroid lo"ations, display the original image and then, using the ! holdand plot fun"tions, superimpose the "entroids on the image. figure, imshow(2) title('Beighted (red) and 9nweighted (blue) 5entroid 0o"ations'); hold on num=b: = numel(s); for 6 = + . num=b: plot(s(6).Beighted5entroid(+), s(6).Beighted5entroid(2), 'rD'); plot(s(6).5entroid(+), s(6).5entroid(2), 'bo'); end hold off ! 1tep ;. 5al"ulate 5ustom Ki&el Nalue,#ased Kroperties ! Iou "an use the 'Ki&elNalues' property to do "ustom "al"ulations ! based on the pi&el values of the original grays"ale image. ! $he 'Ki&elNalues' property returns ! a ve"tor "ontaining the grays"ale values of pi&els in a region. ! s an e&ample, "al"ulate the standard deviation of ea"h region. s = regionprops(#B, 2, @'5entroid','Ki&elNalues','#ounding#o&'A); figure, imshow(2); title('1tandard (eviation of %egions'); hold on for 6 = + . num=b: s(6).1tandard(eviation = std(double(s(6).Ki&elNalues)); te&t(s(6).5entroid(+),s(6).5entroid(2), ...

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


end hold off ! $his figure shows the standard deviation measurement superimposed on ea"h ! ob:e"t in the image. Iou "an also view the results in other ways, for ! e&ample as a bar plot showing the standard deviation by label number. figure bar(+.num=b:,)s.1tandard(eviation*); &label('%egion 0abel 8umber'); ylabel('1tandard (eviation'); ! Iou "an use the plot to determine how to partition the data. ! <or e&ample, the following "ode identifies ob:e"ts with a standard ! deviation lower than ?-. s1td = )s.1tandard(eviation*; low1td = find(s1td R ?-); imshow(2); title('=b:e"ts Maving 1tandard (eviation R ?-'); hold on; for 6 = + . length(low1td) re"tangle('Kosition', s(low1td(6)).#ounding#o&, ... 'Cdge5olor','y'); end hold off; sprintf('!2.+f', s(6).1tandard(eviation), ... 'Cdge5olor','b','5olor','r');

(+) Re,o*%ce %e4*i%ed: (+I) P%ec'*tio!,: -

atla- 0ersion ? Release 2@ or a,0ance 0ersion

25*It.s case sensiti0e soft(are* 2@*For scri/ting use &trlA! an, for ren,ering /ress FB* 2B*Se)i colon is necessary after each line -ut not in the )i,,le of the loo/* 2F*&trlAR is use, for co))ents* (+II) P%oced*%e: 2F*<rite a /rogra) as /er )entione, in the la-* 2?*&trlA! for ne( atla- /rogra)* 2M*FB for co)/ilation an, e1ecution* 2N*Re=uire, i)age is as follo(s* 3L*Follo(ing is the )ain )enu of atla-* (+III) Ob,e%v'tio! o% C'lc*l'tio!,: ?* Ty/e your o-ser0ation CDDDDDDDDDDD* M* ############################################################################### ############################################################################### ############################################################################### ############################################################################### #### (IX) Re,*lt: ?* Stu,ent )ust ty/e the result or out/ut of the /rogra)CDDDDDDDDDDDDDD** M* ################################################################################### #####################################################################* Developed by:Adnan Alam
Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


(X) INTERPRET-TION O3 RE"56T: -

(XI) CONC65"ION: -

(XII) E$pe%i e!t Rel'ted 7*e,tio!,. 2L*"efine the follo(ing ter)s an, (rite your ans(ers in o-ser0ation or in Oui8* :*d)e3'cto% 0 ed)e 0 ,t%el() 0 i dil'te() 0 i :ill()0 i cle'%bo%de%() 0 i e%ode()0 b9pe%i () 0 ,e)o*t() 22*"efine co)/uter 0ision* 23*<hy (e use i)ages in co)/uter 0isionEArtificial Intelligence* (XIII) -,,e,, e!t:S*!o* E1/eri)ent a1* ar9 O-taine, Process 2 3 5 @ B Sa)/le co,e Algorith) Flo( chart Synta1 Tea) Lea,ershi/ 3 3 3 3 3

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)


Pro,uct 2 3 5 @ "esire, Result Inter/retation of Result atla- han,ling ;i0a 3*B 3*B 3*B 3*B

(XI+)De,i%ed O*tp*t:-

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Institute of Business & Technology (Artificial Intelligence)

Developed by:Adnan Alam


Khan(Write2adnanalamkhan@gmail.com)

Department of Computer Science & Information Technology

Potrebbero piacerti anche