INDEX Sr. No. 01

Date

Topic (a) Transformation of Geometric objects (b) Drawing output primitives

02

Image enhancement

03

Basic Transformation

04

Signature

Different Filters(LPF, HPF, Laplacian,LOG, etc)

05

Plot a Histogram

06

Histogram Equalization

07

Gaussian filter on grey level image

08

Morphological operation on Image

1

2

3

4

5

Practical No: 01

(a)Transformation of Geometric objects Aim: Write a program to apply transformation on geometric objects. a) Translation b) Rotation c) Scaling

Translation: Source Code: #include #include #include void main() { int gdriver = DETECT, gmode, xy[4],t[4]; initgraph(&gdriver, &gmode, "c:\\tc"); setcolor(15); printf("Enter the original coordinates : "); scanf("%d %d %d %d",&xy[0], &xy[1],&xy[2],&xy[3]); printf("Enter the translation factor : "); scanf("%d %d",&t[0], &t[1]); rectangle(xy[0],xy[1],xy[2],xy[3]); outtextxy(xy[0],xy[1]-10, "Original Figure"); rectangle(xy[0]+t[0],xy[1]+t[1],xy[2]+t[0],xy[3]+t[1]); outtextxy(xy[0]+t[0],xy[1]+t[1]-10, "Translated Figure"); getch(); closegraph(); }

6

Output:

7

Rotation: Source Code: #include #include #include #include void main() { int i,gdriver=DETECT,gmode; float x1,y1,x2,y2,x3,y3,rot,theta; clrscr(); initgraph(&gdriver,&gmode,"E:\\TC\\TC\\BGI"); printf("Enter the value of x1,y1,x2,y2::"); scanf("%f%f%f%f",&x1,&y1,&x2,&y2); line(x1,y1,x2,y2); printf("Enter the rotational angle::"); scanf("%f",&theta); rot= (theta/180)*3.14; x3=(x2*cos(rot)) - (y2*sin(rot)); y3=(x2*sin(rot)) + (y2*cos(rot)); line(x1,y1,x3,y3); getch(); closegraph(); }

8

Output:

Enter the value of x1,y1,x2,y2:: 100 200 300 400 Enter the rotational angle:: 50

Scaling: Source Code: #include #include #include void main() { int gdriver = DETECT, gmode, xy[4], crScaled[4]; float scaling; initgraph(&gdriver, &gmode, "c:\\tc"); setcolor(15); printf("Enter the original coordinates : "); 9

scanf("%d %d %d %d",&xy[0], &xy[1],&xy[2],&xy[3]); printf("Enter the scaling factor : "); scanf("%f", &scaling); crScaled[0] = xy[0]+320; crScaled[1] = xy[1]; crScaled[2] = (int)((xy[2] - xy[0]) * scaling) + xy[0]+320; crScaled[3] = (int)((xy[3] - xy[1]) * scaling) + xy[1]; rectangle(xy[0],xy[1],xy[2],xy[3]); outtextxy(10,50, "Original Figure"); line(320,50,320,479); rectangle(crScaled[0],crScaled[1],crScaled[2],crScaled[3]); outtextxy(330,50, "Scaled Figure"); getch(); closegraph(); } Output:

10

11

12

13

14

(a)Drawing Output Primitives Aim: Write a program for drawing output primitives. a) Mid-point circle algorithm b) Bresenham line algorithm

Mid Point Circle Algorithm: Source Code: #include #include #include void main() { float d; int gd,gm,x,y,r; printf("Enter the radius of a circle :"); scanf("%d",&r); detectgraph(&gd,&gm); initgraph(&gd,&gm,"e:\\tc\\bgi"); x = 0,y = r; d = 3 - 2 * r; do { putpixel(200+x,200+y,15); putpixel(200+y,200+x,15); putpixel(200+y,200-x,15); putpixel(200+x,200-y,15); putpixel(200-x,200-y,15); putpixel(200-y,200-x,15); putpixel(200-y,200+x,15); putpixel(200-x,200+y,15); if (d <= 0) d = d + 4*x + 6; else { d = d + 4*(x-y) + 10; y = y - 1; } x = x + 1; }while(x < y); getch(); closegraph(); }

15

Output:

16

Bresenham Line Algorithm: Source Code: #include #include #include #include void main() { float x,y,x1,y1,x2,y2,dx,dy,e; int i,gd,gm; printf("Enter the value of x1 :\t"); scanf("%f",&x1); printf("Enter the value of y1 :\t"); scanf("%f",&y1); printf("Enter the value of x2 :\t"); scanf("%f",&x2); printf("Enter the value of y2 :\t"); scanf("%f",&y2); detectgraph(&gd,&gm); initgraph(&gd,&gm,"C:\\TC\\BGI"); dx=abs(x2-x1); dy=abs(y2-y1); x = x1; y = y1; e = 2 * dy-dx; i = 1; do { putpixel(x,y,15); while(e >= 0) { y = y + 1; e = e - 2 * dx; } x = x + 1; e = e + 2 * dy; i = i + 1; }while( i <= dx); getch(); closegraph(); }

17

Output:

18

19

20

21

Practical No: 02

Image enhancement Aim: Image Enhancement a) Thresholding b) Contrast adjustment c) Brightness adjustment d) Gray level slicing Source Code: % Thresholding clear all clc p = imread('cameraman.tif'); a = p; [row col] = size(a); maximum_value = max( max(a) ); maximum_value; row; col; thresholding_value = input('Enter a thresholding value : '); for i=1 : 1 : row for j=1 : 1 : col if (a(i,j) < thresholding_value) a(i,j) = 255; else a(i,j) = 0; end end end subplot(3,2,1), imshow(p) title('Original Image'); subplot(3,2,2), imshow(uint8(a)) title('Thresholding'); %Contast r1=100; s1=150; r2=140; s2=240; l=s1/r1; m=(s2-s1)/(r2-r1); n=(255-s2)/(255-r2); s=size(p); for x=1:s(1); for y=1:s(2); if((p(x,y)>0) && (p(x,y)r1) && (p(x,y)r2) && (p(x,y)<256)) o(x,y)=(n*(p(x,y)-150))+s2; end end

22

end subplot(3,2,3),imshow(o); title('contrast image'); %Brightness B=double(p)+100; subplot(3,2,4) imshow(uint8(B)); title('Brightness Adjusted'); %Graylevel u = imread('cameraman.tif'); a = u; s=size(u); a = input('Enter a value A : '); b = input('Enter a value B : '); for x=1:s(1) for y=1:s(2) if(u(x,y)>=a && (u(x,y)<=b)) g(x,y)=255; else g(x,y)=0; end end end for x=1:s(1) for y=1:s(2) if(u(x,y)>=a && (u(x,y)<=b)) v(x,y)=255; else v(x,y)=u(x,y); end end end subplot(3,2,5),imshow(g); title('graylevel slicing without background'); subplot(3,2,6),imshow(v); title('graylevel slicing with background');

23

Output: Enter a thresholding value : 100 Enter a value A : 50 Enter a value B : 100

24

25

26

Practical No: 03

Basic Transformation Aim: Basic transformations a) Log transformation b) Power law transformation c) Negation Source Code: clear all; clc; img=imread('cameraman.tif'); subplot(3,2,1) imshow(img); title('Original Image'); L=255; c=L/log10(1+L); d = c*(log10(1+ double(img))); a =uint8(d); subplot(3,2,2) imshow(uint8(a)); title('Log Transformed Image'); s=size(img); c1=1; img=double(img); gamma=0.5; for x=1:s(1) for y=1:s(2) j(x,y)=c*(img(x,y)^gamma); end end subplot(3,2,3); imshow(j,[]); title('Power Law Transformed Image'); for x=1:s(1) for y=1:s(2) img(y,x)=255-img(y,x); end end img=uint8(img); subplot(3,2,4); imshow(img); title('Image Negative');

27

Output:

28

29

30

31

Practical No: 04

Different Filters Aim: Different filters(LPF,HPF,Laplacian,LOG,etc)

Low Pass Filter: Source Code: clear all; clc; a=imread('cameraman.tif'); a=double(a); [row col k]=size(a); while(1) rc=input('Enter size of mask'); remain=mod(rc,2); if remain==0 disp('Enter the ODD value'); continue else break end end z=(rc+1)/2; msk=ones(rc)/(rc*rc); a1=a; for d=1:1:k for x=z:1:row-z+1 for y=z:1:col-z+1 for i=1:1:rc for j=1:1:rc a1(x,y,d)=a1(x,y,d)+msk(i,j)*a(x-z+i,y-z+j,d); end end end end end subplot(1,2,1); imshow(uint8(a)); title('original image'); subplot(1,2,2); imshow(uint8(a1)); title('Image after Low Pass Filter');

32

Output: Enter size of mask6 Enter the ODD value Enter size of mask5

33

High Pass Filter: 4b)Source Code: clear all; clc; a=imread('cameraman.tif'); a=double(a); [row col k]=size(a); rc=input('Enter size of mask'); z=(rc+1)/2; msk=ones(rc)/(rc*rc); a1=a; for i=1:1:rc for j=1:1:rc if(i==z)&&(j==z) msk(i,j)=(rc*rc)-1; else msk(i,j)=-1; end end end a1=a; for d=1:1:k for x=z:1:row-z+1 for y=z:1:col-z+1 a1(x,y,d)=0; end end end j=1; for d=1:1:k for x=z:1:row-z+1 for y=z:1:col-z+1 for i=1:1:rc for j=1:1:rc a1(x,y,d)=a1(x,y,d)+msk(i,j)*a(x-z+i,y-z+j,d); end end if a1(x,y,d)<0 a1(x,y,d)=0; end end end end subplot(1,2,1); imshow(uint8(a)); 34

title('original image'); subplot(1,2,2); imshow(uint8(a1)); title('Image after High Pass Filter'); Output: Enter size of mask 5

35

Laplacian Filter 4c)Source Code clc; clear all; close all; m=3; a1=input('enter the value of alpha between 0 and 1='); w=[(a1/4),(1-a1)/4,(a1/4);(1-a1)/4, -1,(1-a1)/4; a1/4,(1-a1)/4, (a1/4)]; w=w*4/(a1+1); aa=imread('cameraman.tif'); a=double(aa); [row,col,d]=size(a); s=(m+1)/2; for k=1:1:d for x=1:1:row for y=1:1:col b(x,y,k)=a(x,y,k); end end end for k=1:1:d for x=s:1:row-s for y=s:1:col-s b(x,y,k)=0; end end end for k=1:1:d for x=s:1:row-s for y=s:1:col-s for i=1:1:m for j=1:1:m b(x,y,k)=a(x-s+i,y-s+j,k)*w(i,j)+b(x,y,k); end end if b(x,y,k)<0 b(x,y,k)=0; end end end end subplot(1,2,1); imshow(uint8(a)); title('original image'); subplot(1,2,2); imshow(uint8(b)); 36

title('Image after Laplacian Filter'); Output: Enter the value of alpha between 0 and 1=0.5

37

Laplacian of Gaussian 4d) Source Code: clc; clear all; a=imread('cameraman.tif'); a=double(a); [row col]=size(a); lap=[0 1 0;1 -4 1; 0 1 0]; m=5; s=m/2; s=floor(m/2); log5=[0 0 -1 0 0;0 -1 -2 -1 0; -1 -2 16 -2 -1;0 -1 -2 -1 0;0 0 -1 0 0]; m=5; s=m/2; s=floor(m/2); for x=3:1:row-2 for y=3:1:col-2 t=1; B(x,y)=0; for i=-s:1:s for j=-s:1:s B(x,y)=B(x,y)+log5(t)*a(x+i,y+j); t=t+1; end end end end subplot(1,2,1); imshow(uint8(a)); title('Original image'); subplot(1,2,2); imshow(uint8(B)); title('Laplacian of Gaussian');

38

Output:

39

40

5) Source Code: clear all; clc; a=imread('cameraman.tif'); a=double(a); [row col]=size(a); h=zeros(1,300); for n=1:1:row for m=1:1:col if a(n,m)==0 a(n,m)=1; end end end for n=1:1:row for m=1:1:col t=a(n,m); h(t)=h(t)+1; end end figure(1); subplot(1,2,1); imshow(uint8(a)); title('Original Image') subplot(1,2,2); bar(h); title('Image histogram');

41

Output:

42

43

44

45

6) Source Code: clear all; clc; a =imread('Cameraman.tif'); a=double(a); big=256; [row col d]=size(a); c=row*col; h=zeros(1,300); z=zeros(1,300); for e=1:1:d for n=1:1:row for m=1:1:col if a(n,m,e)==0 a(n,m,e)=1; end end end end for n=1:1:row for m=1:1:col t=a(n,m); h(t)=h(t)+1; end end pdf=h/c; cdf(1)=pdf(1); for x=2:1:big cdf(x)=pdf(x)+cdf(x-1); end new=round(cdf*big); new=new+1; for r=1:1:d for p=1:1:row for q=1:1:col temp=a(p,q,r); b(p,q,r)=new(temp); t=b(p,q,r); z(t)=z(t)+1; end end end b=b-1; subplot(2,2,1); imshow(uint8(a)); title('original image'); 46

subplot(2,2,2); bar(h); title('Image Histogram'); subplot(2,2,3); imshow(uint8(b)) title('Image after histogram '); subplot(2,2,4); bar(z); title('Image histogram equalization'); Output:

47

48

7) Source Code: clc; clear all; close all; m=input(' enter size'); s=input(' enter value of sigma'); sum1=0; a=m/2; p=0; q=0; r=1; t=1; w=floor(a); for i=-w:w for j=-w:w p=(i*i); q=(j*j); % disp(p); g(r,t)=exp(-(p+q)/(2*s*s)); sum1=sum(sum(g(r,t)+sum1)); t=t+1; % disp(r); % disp(t); end t=1; r=r+1; end disp(g); for r=1:m for t=1:m %disp(sum1); h(r,t)=g(r,t)/sum1; t=t+1; end t=1; r=r+1; end disp(h); img = imread('cameraman.tif'); %img=rgb2gray(im); s1=0; f = double(img); [M N]=size(f); for x=0:M-m for y=0:N-m 49

for s=1:m for z=1:m s1=(h(s,z)* (f(x+s,y+z)))+ s1; end end N_img(x+1,y+1)= s1; s1=0; end end disp(N_img); subplot(1,2,1); imshow(img); title('Original Image'); subplot(1,2,2); imshow(uint8(N_img)); title('Image after Gaussian filtering'); Output:

50

51

8a) Source Code: clc; clear all; BW1=imread('cameraman.tif'); SE=strel('square',3); disp(SE); BW2=imerode(BW1,SE); BW3=imdilate(BW2,SE); figure(1); subplot(1,2,1); imshow(BW1); title('Original image'); subplot(1,2,2); imshow(BW3); title('Morphological opening'); Output:

52

8b) Source Code: clc; clear all; BW1=imread('cameraman.tif'); SE=strel('square',3); disp(SE); BW2=imdilate(BW1,SE); BW3=imerode(BW2,SE); figure(1); subplot(1,2,1); imshow(BW1); title('Original image'); subplot(1,2,2); imshow(BW3); title('Morphological Closing'); Output:

8c) Source Code: clc; 53

clear all; BW1=imread('cameraman.tif'); SE=strel('square',3); disp(SE); BW2=imdilate(BW1,SE); BW3=imerode(BW1,SE); BW4=BW2-BW3; BW5=BW1-BW3; BW6=BW2-BW1; figure(1); subplot(2,2,1); imshow(BW1); title('Original image'); subplot(2,2,2); imshow(BW4); title('Morphological Gradient'); subplot(2,2,3); imshow(BW5); title('Internal Gradient'); subplot(2,2,4); imshow(BW6); title('External Gradient');

54

OUTPUT:

55

8d) Source Code: clc; clear all; BW1=imread('cameraman.tif'); SE=strel('square',3); disp(SE); BW2=imerode(BW1,SE); BW3=imdilate(BW2,SE); BW4=BW1-BW3; figure(1); subplot(1,2,1); imshow(BW1); title('Original image'); subplot(1,2,2); imshow(BW4); title('Top Hat Transform');

56

Output:

57

58

Sr. No. Date Topic Signature -

#includeh>. #includeh> void main(). { int gdriver = DETECT, gmode, xy[4],t[4]; initgraph(&gdriver, &gmode, "c:\\tc"); setcolor(15); printf("Enter the original coordinates : "); scanf("%d %d %d %d",&xy[0], &xy[1] ..... a1=input('enter the value of alpha between 0 and 1='); w=[(a1/4),(1-a1)/4,(a1/4);(1-a1)/4, -1 ...

3MB Sizes 1 Downloads 290 Views

Recommend Documents

Date Topic Overview Page # Date Topic Overview Page
Elasticity. Unit 2. -Elasticity of Demand. -Elasticity of Supply. 76-89. October 5. (19). Income Elasticity. Cross-Price Elasticity. Taxes. Unit 2. -Income and Cross ...

SR. NO.
9. ASHA SATISH TARDE. 29.09.2011. 7122. 15.10.2011 AT & POST CHINCHANI, TALUKA-DAHANU, DIST-THANE. 10. ASHOK DATTATRAYA LELE 13.04.2012. 5715. 04.06.2012. 11. 24.07.2012. 7440. 6.08.2012. 12. 04.04.2012. 5680. 04.06.2012. 13. AVINASH VINAYAK JOSHI 1.

Buletin SR No 1.pdf
Page 1 of 4. Penerbit: Biro Litkom PGI. Penanggungjawab: Henrek Lokra (Kabiro Litkom). Redaksi: Rainy Hutabarat (Editor), Jeirry Sumampouw Trisno Sutanto, ...

Sr. No. CGHS TREATMENT PROCEDURE ... -
Loop Colostomy Transverse Sigmoid. 11799. 13569 .... Balloon coronary angioplasty/PTCA without VCD. 80000 ... External Loop/event recording. 2563. 2947.

Sr. No. Date Day Holiday Description 1 26-Jan-16 Tuesday ... - NSE
Dec 23, 2015 - Id-Ul-Fitr (Ramzan ID). 12. 15-Aug-16. Monday. Independence Day. 13. 17-Aug-16. Wednesday. Parsi New Year. 14. 05-Sep-16. Monday.

Sr. No. Date Day Holiday Description 1 26-Jan-16 Tuesday ... - NSE
Dec 23, 2015 - 25-Dec-16. Sunday. Christmas. Yours faithfully,. For National Securities Clearing Corporation Ltd. Sunil Bhatia. Manager. Toll Free No. Fax No.

Date Applicant's signature Exchange of Scientists under Estonian
Exchange of Scientists under Estonian-Taiwanese Agreements of Scientific. Cooperation. Travel Grant Application 2016. 1. Applicant. Name: Position: E-mail.

Date Applicant's signature Exchange of Scientists under Estonian
Exchange of Scientists under Estonian-Taiwanese Agreements of Scientific. Cooperation. Travel Grant Application 2016. 1. Applicant. Name: Position: E-mail.

Sr. No. CGHS TREATMENT PROCEDURE/INVESTIGATION LIST Non ...
PROCEDURE/INVESTIGATION LIST ...... Perforation of Uterus after D/E Laparotomy &. Closure. 13800 ...... Mastoids: Towne view, oblique views (3 films). 225.

Sr. No.Case No. Party Petitioner Advocates ... -
MR. PUKHRAMBAM. RAMESH KUMAR. 9. C.A. No. 8129-. 8130/2004. M/S MANIYAR PLAST. LTD. AND ANR. Vs. MS. BINA GUPTA. MR. B. KRISHNA. PRASAD ...... PUKHRAMBAM. RAMESH KUMAR. 56. C.A. No. 1107/2009. AVAS EVAM VIKAS. PARISHAD. Vs. BHOPENDRA SINGH & ORS. MR.

Sr. No. Designation Job Description 1 Mechanical ... -
-The Electrical Engineer will primarily perform all aspects of electrical engineering in ... preparation for bidding, cost estimating, value engineering exercises, and ...

Sr. Accountant.pdf
Filling of FCRA returns, TDS returns, Income tax return, GST, Employee Provident fund, Profession Tax, etc. 13. Submission of accurate & timely financial reports ...

SR BOYS.pdf
H S S Kannadiparamba 0:0:0 sec. II 141 AKASH.K 13012-Govt. H S S Pallikkunnu 0:0:0 sec. III 488 ABHIRAG KOKKADAN 13040-KPRGSGHSS Kalliasseri ...

SR Brochure.pdf
Page 1 of 2. Framed! A T.O.A.S.T. Mystery. by James Ponti Mystery. Florian is 12 and has just moved to. Washington D.C. He's perfecting. TOAST, the Theory of All Small Things, a. technique he invented to solve life's little. mysteries such as: where

Sr'. F'H.
PAN LIPUNAN. Date: February 28, 2018. Please be informed that there will be an urgent meeting of Secondary. Key/Head Teachers in Araling Panlipunan ...

Signature Page.pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

LD TYPIST –VARIOUS-(SR FOR SC/ST) EXAM DATE:6 ...
Jun 2, 2014 - Who invented Neutron? ... Indian National Congress founded on: ... D.S.Radhakrishnan. Ans:B. 10.The king of fruits: A.Apple. B.Banana.

(sr)s.(Irric:v..)
Public School District Supervisors (PSDS),. Coordinating Principals,. Elementary Principals and Clinic teachers. January 4, 2016. Rv: I Z1-4. DATE & TIM.

sr cheat sheets.pdf
Attacker fi ring burst or semi-auto burst –2. Defender in melee targeted by ranged. attack. –3. Targeted by area-eff ect attack –2. ENVIRONMENTAL MODIFIERS [p. 175]. VISIBILITY LIGHT/GLARE WIND RANGE MODIFIER. Clear Full Light/No Glare None or

Topic Segmentation with Shared Topic Detection and ...
Jul 23, 2007 - †College of Information Sciences and Technology. The Pennsylvania State University. University Park, PA 16802. ‡College of Computing.

TFB24-SR CUTSHEET.pdf
Actuator sizing should be. done in accordance with the damper manufacturer's specifications. The actuator is mounted directly to a damper shaft from 1/4” up to ...

Sr. Accountant temp.pdf
Creates forms and manuals for accounting and bookkeeping personnel. Supports monthly close process, as well as quarterly and year-end close as needed. Competencies. Financial Management and Reporting. Problem Solving/Analysis. Strategic Thinking. Tec