Sr.No 123Program
Write a program in C for scaling of images. Write a program in C for translation of images. Write a program in C for rotation of images.





Write a program in C to use arithmetic mean filter for image processing. Write a program in C to use low pass filter for image processing. Write a program in C to use high pass filter for image processing.


#include "Stdio.char line_color). getch(). of lines:-µ). fill_poly(poly. void display_cordinate(char bg_color.Cos.points. .points.BLUE).Sin. Identity(Matrix).h" void intgraph().Xdis.i.h" #include "conio. void main() { int poly[3][2]. void Identity(float Matrix[3][3]). Translate_to_Relative(poly. display_cordinate(DARKGRAY.WHITE).char fill_color).int Xdis. scanf(´%dµ.int Ydis).h" #include "math.h" #include "graphics. Xdis=0-poly[0][0]. setfillstyle(8. int Create_poly(int poly[][2]).Sy.&n).Xdis.Program1:. char ch.char line_color. void fill_poly(int poly[][2].Matrix[3][3]. void Translate_to_Relative(int poly[][2].int points. points=Create_poly(poly).points.Ydis). printf(´Enter the no.Ydis. float points.GREEN). Ydis=0-poly[0][1].WHITE. intgraph().Write a program in C for scaling of images.

&Sy).&Sx).printf(´Enter the co-ordinates:-´).-Ydis). .CYAN. printf(" Sx:.i<3. scanf("%f". fill_poly(poly.char line_color.char fill_color) { int pol[20]. Matrix[i][1]=Matrix[i][1]*Sy.d. exit(0).int points. printf(" Sy:. } getch(). } setgraphmode(2). for(i=0.-Xdis. scanf("%f".points.BLUE). Translate_to_Relative(poly. initgraph(&g. printf(" Enter Scaling Ratio:.&d."). getch()."c:\tc\bgi")."). void intgraph() { int g=DETECT. display_cordinate(DARKGRAY.i. } void fill_poly(int poly1[][2].i++) { Matrix[i][0]=Matrix[i][0]*Sx.points."). closegraph().BLUE).

pol[i*2+1]=poly1[0][1].0. for(i=0. } pol[i*2]=poly1[0][0]. for(i=0.i+'a'). for(i=0. setfillstyle(8.char str[2].i<=points."%c".j<=2.str). } } void Identity(float Matrix[3][3]) { int i.j++) { if(i==j) . setcolor(line_color). fillpoly(points+1. outtextxy(poly1[i][0].j.i++) { sprintf(str.pol). setcolor(fill_color). settextstyle(1.i++) { for(j=0.i<=2.i++) { pol[i*2]=poly1[i][0]. pol[i*2+1]=poly1[i][1].fill_color).i<=points.3).poly1[i][1].

else Matrix[i][j]=0.i+=50) { line(0.i<=480. setcolor(line_color). for(i=0. poly[2][1]=280. } for(i=0. poly[1][0]=300.i.640.480). } .i). poly[2][0]=130. return 2. } void display_cordinate(char bg_color.i+=50) { line(i.Matrix[i][j]=1. poly[1][1]=150.i<=640. poly[0][1]=20.char line_color) { int i.0. setbkcolor(bg_color). } } } int Create_poly(int poly[][2]) { poly[0][0]=200.i.

poly[i][1]=poly[i][1]+Ydis. } void Translate_to_Relative(int poly[][2].60 Sy:-60 . for(i=0. of Ydis) { int i. } } OUTPUT Enter the Xdis.i++) { poly[i][0]=poly[i][0]+Xdis.i<=points.639.rectangle(0.5 Enter the co-ordinates:.300 199 454 500 500 123 123 310 456 234 Enter the scaling points.479).

void display_cordinate(char bg_color. Identity(Matrix). fill_poly(poly. of lines:-µ).temp.GREEN. int Create_poly(int poly[][2]).points. scanf(´%dµ.char line_color).h" #include "math. printf(´Enter the co-ordinates:-´).Cos. setfillstyle(8.Write a program in C for translation of images. points=Create_poly(poly).h" void intgraph().char line_color. void Identity(float Matrix[3][3]). getch().int Xdis.h" #include "graphics. void fill_poly(int poly[][2].h" #include "conio.char fill_color).&n). printf(´Enter the no. void main() { int poly[3][2].Sin. #include "Stdio. . void Translate_to_Relative(int poly[][2]. float Sx. display_cordinate(DARKGRAY.Program2:. Ydis=0-poly[0][1].int points.BLUE) Ydis).points.RED). char ch.Ydis. Xdis=0-poly[0][0].GREEN).Sy.Matrix[3][3].i. intgraph().int points.

").&Sy). scanf("%f"."c:\tc\bgi"). char str[2].CYAN. } setgraphmode(2).i++) { .-Ydis).char fill_color) { int pol[20]. } void fill_poly(int poly1[][2].&d. printf(" Ty:.printf(" Enter Translation [Relative]:. void intgraph() { int g=DETECT. getch().int points.BLUE).").points.i. printf(" Tx:."). Matrix[2][0]=Matrix[2][0]+Sx.i<=points. display_cordinate(DARKGRAY.GREEN).d. getch(). scanf("%f". Matrix[2][1]=Matrix[2][1]+Sy. for(i=0.points. exit(0). initgraph(&g.-Xdis. fill_poly(poly.char line_color. closegraph(). Translate_to_Relative(poly.&Sx).

fillpoly(points+1.i++) { for(j=0. } pol[i*2]=poly1[0][0]. setfillstyle(8. pol[i*2+1]=poly1[0][1].pol[i*2]=poly1[i][0].fill_color). } } void Identity(float Matrix[3][3]) { int i.i<=points.i++) { sprintf(str.poly1[i][1]."%c".3).str). setcolor(fill_color). } .0.j++) { if(i==j) Matrix[i][j]=1. for(i=0.pol).i+'a'). pol[i*2+1]=poly1[i][1].i<=2.j<=2. outtextxy(poly1[i][0]. else Matrix[i][j]=0. for(i=0. setcolor(line_color). settextstyle(1.j.

int points.i+=50) { line(i. poly[0][1]=20.i). } void Translate_to_Relative(int poly[][2].i+=50) { line(0. poly[1][1]=150. for( Ydis) { . poly[2][1]=280. poly[2][0]=130.0. setcolor(line_color).} } int Create_poly(int poly[][2]) { poly[0][0]=200. } rectangle(0.i. setbkcolor(bg_color).480).char line_color) { int i.i<=480. poly[1][0]=300. return 2.i. } for( Xdis.639.479).i<=640. } void display_cordinate(char bg_color.640.0.

int i. for(i=0. } } OUTPUT Enter the no.i++) { poly[i][0]=poly[i][0]+Xdis. of lines:-4 Enter the co-ordinates:.200 100 100 200 200 200 100 100 Enter Translation [Relative]:Tx:-80 Ty:-30 .i<=points. poly[i][1]=poly[i][1]+Ydis.

void display_cordinate(char bg_color. void main() { int poly[3][2].Program3:.i. Xdis=0-poly[0][0]. int Create_poly(int poly[][2]).char line_color). intgraph(). Identity(Matrix). Translate_to_Relative(poly. printf(´Enter the no.&n).Matrix[3][3].int points.h" void intgraph().int Xdis.Write a program in C for rotation of images.GREEN.Sin.char line_color.BLUE).temp. getch(). setfillstyle(8.points.h" #include "math.points.Sy. points=Create_poly(poly).Ydis.Ydis). of lines:-µ).Cos. scanf(´%dµ. char ch.char fill_color). display_cordinate(DARKGRAY. fill_poly(poly.Xdis. Ydis=0-poly[0][1].GREEN). void Translate_to_Relative(int poly[][2].int Ydis).BLUE).Xdis.h" #include "graphics. .int points. #include "Stdio. void fill_poly(int poly[][2]. float Sx. void Identity(float Matrix[3][3]).h" #include "conio.points.

-Xdis.printf(´Enter the co-ordinates:-´). Matrix[i][0]=temp.14)/180.points.GREEN).points. do { Translate_to_Relative(poly.BLUE).CYAN.&Sx).i++) { temp=Matrix[i][0]*Cos-Matrix[i][1]*Sin. } getch(). } setgraphmode(2).Xdis. .i<=2.Ydis). Translate_to_Relative(poly. Sx=(Sx*3. Matrix[i][1]=Matrix[i][0]*Sin+Matrix[i][1]*Cos. exit(0).-Ydis)."). Cos=cos(Sx). closegraph(). } } void intgraph() closegraph(). for(i=0. printf(" Enter Rotation Angle [Degree]:.points. Sin=sin(Sx). scanf("%f". fill_poly(poly. getch(). display_cordinate(DARKGRAY. restorecrtmode().

char fill_color) { int pol[20].&d. for(i=0. setfillstyle(8. } pol[i*2]=poly1[0][0].int points. setcolor(fill_color). fillpoly(points+1. } void fill_poly(int poly1[][2]. pol[i*2+1]=poly1[i][1]."c:\tc\bgi").char line_color. char str[2].i<=points.{ int g=DETECT. settextstyle(1. outtextxy(poly1[i][0].i++) { pol[i*2]=poly1[i][0]."%c".3).str).0. setcolor(line_color).i++) { sprintf(str.fill_color).i. } } void Identity(float Matrix[3][3]) { .pol). initgraph(&g.poly1[i][1].i+'a'). pol[i*2+1]=poly1[0][1]. for(i=0.d.i<=points.

j<=2. poly[2][0]=130. return i.i+=50) { for(j=0. } void display_cordinate(char bg_color. setbkcolor(bg_color). poly[1][0]=300. poly[0][1]=20. poly[1][1]=150. for(i=0.i<=640. } } } int Create_poly(int poly[][2]) { poly[0][0]=200.i++) { { if(i==j) Matrix[i][j]=1.i<=2.j++) . poly[2][1]=280.j. else Matrix[i][j]=0. setcolor(line_color). for(i=0.char line_color) { int i.

480).639.i<=480.640.0.479). } for(i=0. } } line(0.i. OUTPUT Enter the Xdis.0.i++) { poly[i][0]=poly[i][0]+Xdis.line(i.i<=points. of lines:-3 Enter the co-ordinates:-200 100 200 350 220 100 Enter the rotation angle [Degree]:-50 .int Ydis) { int i.i+=50) { } rectangle(0. for(i=0. } void Translate_to_Relative(int poly[][2]. poly[i][1]=poly[i][1]+Ydis.i).i.

Sign up to vote on this title
UsefulNot useful