Mạng thần kinh nhân tạo cho phân lớp màu sắc part 2
Số trang: 11
Loại file: pdf
Dung lượng: 172.22 KB
Lượt xem: 11
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Lấy rất nhiều các giá trị từ một loạt các điểm trên miền đã lựa chọn sắc màu bằng cách nhắp đơn nút trái chuột. Chú ý là màn hình VGA sẽ hiện lên biểu đồ màu và cường độ màu tại nơi mà bạn trỏ tới. Nơi mà bạn kích vào sẽ đánh dấu bằng một dấu thập màu đỏ trên biểu đồ màu vẽ trên màn hình VGA (xem hình 12.6) và lưu nó vào một mảng. Nếu bạn muốn dời dấu thập đi chỗ khác trong trường hợp các điểm nhập vào lớn hơn một, thì nhắp...
Nội dung trích xuất từ tài liệu:
Mạng thần kinh nhân tạo cho phân lớp màu sắc part 2 LÊy rÊt nhiÒu c¸c gi¸ trÞ tõ mét lo¹t c¸c ®iÓm trªn miÒn ®· lùa chän s¾c mµu b»ng c¸ch nh¾p ®¬n nót tr¸i chuét. Chó ý lµ mµn h×nh VGA sÏ hiÖn lªn biÓu ®å mµu vµ cêng ®é mµu t¹i n¬i mµ b¹n trá tíi. N¬i mµ b¹n kÝch vµo sÏ ®¸nh dÊu b»ng mét dÊu thËp mµu ®á trªn biÓu ®å mµu vÏ trªn mµn h×nh VGA (xem h×nh 12.6) vµ lu nã vµo mét m¶ng. NÕu b¹n muèn dêi dÊu thËp ®i chç kh¸c trong trêng hîp c¸c ®iÓm nhËp vµo lín h¬n mét, th× nh¾p nót tr¸i chuét nhiÒu lÇn. Hµnh ®éng nµy sÏ lµm dêi ®i rÊt nhiÒu ®iÓm tuú theo b¹n chän (b¾t ®Çu tõ ®iÓm cuèi cïng) tõ biÓu ®å mµu vµ lu trong m¶ng. Khi b¹n Ên ESC, con trá sÏ xuÊt hiÖn trªn mµn h×nh VGA. §a con trá vµo s¬ ®å mµu vÏ trªn mµn h×nh VGA, b»ng c¸ch kÝch l¹i nót tr¸i chuét ta sÏ thu ®îc d÷ liÖu cho mét líp mµu kh¸c. Nh¾p nót tr¸i chuét, nh tríc ®©y, sÏ lµm dÞch chuyÓn ®Õn ®Çu vµo cuèi cïng. Chó ý r»ng mét dÊu thËp mµu xanh sÏ xuÊt hiÖn bÊt cø khi nµo b¹n nh¾p tr¸i chuét, vµ sÏ bÞ dêi ®i khi b¹n nh¾p ph¶i chuét. NhÊn ESC ®Ó tho¸t. B¹n sÏ ®îc hái tªn file cho chøa d÷ liÖu. D÷ liÖu ®îc lu tr÷ bao gåm 3 sè: sè ®Çu tiªn biÓu diÔn cho x, sè thø hai biÓu diÔn cho y, vµ sè cuèi cïng x¸c ®Þnh líp. Gi¸ trÞ líp nµy ®îc g¸n b»ng 1 trong trêng hîp lùa chän s¾c mµu vµ 0 trong c¸c trêng hîp cßn l¹i. D÷ liÖu ®îc cho díi d¹ng %f%f%d. KÕt qu¶ ta thu ®îc lµ mét cung mµu trªn biÓu ®å mµu ®îc t¸ch ra tõ phÇn cßn l¹i cña phæ mµu. H×nh 12.6 Thu thËp d÷ liÖu cho ph©n líp mµu s¾c. 266 Ch¬ng tr×nh 12.2 COLORRDM.C . Ch¬ng tr×nh thu thËp d÷ liÖu; §îc dïng víi PIB. /************************************ * Developed by M.A.Sid_Ahmed. * * ver. 1.0, 1992. * * @ 1994 *************************************/ /* Program to read color from PIB screen. It also classifies color according to colors in Chromaticity diagram. Use mouse left button to enter x.y coordinates and right button to erase as many previous entries as you wish. The cursor will initially point to the PIB screen, use the mouse to enter the tone you wish to classify as one color set. Press ESC to exit from PIB screen. The cursor mouse will appear on VGA screen. Use mouse to point at points in the Chromaticity diagram that do not belong to the set of colors you wish to classify. Use left button to enter a point, right button to erase previous entry or entries. Press ESC again to exit and store data. */ #include #include #include #include #include #include #define white (circ#define green (l[0]&&l[6]) #define yellow ((!l[0])&&l[1]) #define skin_tone ((!l[1])&&l[2]) #define red ((!l[2])&&l[3]) #define magenta ((!l[3])&&l[4]) #define blue ((!l[4]&&(!l[53)) #define cyan (l[5]&&(!l[6])) #define ESC 0x1B #define LBUTTON 0x01 #define RBUTTON 0x02 void make_cursor(int,int); void find_color(int,int); void move_cursor(int,int); void get_video_mode(int *,int *); void set_video_mode(int); void mouse_cursor_on(void); void mouse_cursor_off(void); void read_mouse(int *, int *, int *); void draw_line(int,int,int,int,int); void draw_circle(int,int,int,int); void set_pixel(int,int,int); void mouse_vrange(int,int); void mouse_hrange(int,int); void set_mouse(int,int); void CIE(void); void draw_cross(float,float,int); int kount=-1; float xold[200],yold[200]; int set[200]; void main() { int mode,page,row,col,button,ind,i; float x,y; char ch,file_name[14]; FILE *fptr; clrscr(); InitPIB(); 268 SetScreen(0); SetInDispMode(); get_video_mode(&mode,&page); set_video_mode(0x12); CIE(); for(i=0;i xold[kount]=x; yold[kount]=y; set[kount]=0; gotoxy(1,3); printf(x=%f y=%f set=%2d total number of points=%4d, xold[kount],yold[kount],set[kount],kount); } else if(button==RBUTTON) { delay(150); draw_cross(xold[kount],yold[kount],BLACK); if(kount>-1) kount--; gotoxy(1,3); printf(x=%f y=%f set=%2d total number of points=%4d, xold[kount],yold[kount],set[kount],kount); } if(kbhit()!=0) { if(getch()==ESC) ind=0; } } gotoxy(1,5); printf(Do you wish to save data? (y or n)-->); while(((ch=getch())!='y')&&(ch!='n')); switch(ch) { case 'y': printf(\n Enter file name -->); scanf(%s,file_name); ind=access(file_name,0); while(!ind) { printf(File exists. Wish to overwrite? (y or n)-->); while(((ch=getch())!='y')&&(ch!='n')); switch(ch) { case 'y': 270 ind=1; break; case 'n': gotoxy(1,6); printf(\n Enter file name --> ); scanf(%s,file_name); ind=access(file_name,0); } } fptr=fopen(file_name,w); for(i=0;ivoid find_color(x1,y1) { unsigned int color,R,G,B; float X,Y,Z,D,x,y; int row,col,button; float m[]={3.3600, 1.260274, 0.663317, - 1.029762, -61.75, 0.384, -0.875}; float c[]={-0.785880, -0.086671, 0.112116, 0.675911, 20.89575, 0.205128, 0.624375}; float r=0.01; float lt,circ; int l[7], i; GetPixel(&color,x1,y1); B=(0x001F & color); G=(0x03E0 & color)>>5; R=(0x7C00 & color)>>10; gotoxy(1,1); printf( blue= %5u, oreen=%5u, red=%5u ,B,G,R); if(R+G+B) { X=2.769*R+1.7518*G+1.1300*B; Y=R+4.5907*G+0.0601*B; Z=0.0565*G+5.5943*B; D=X+Y+Z ; x=X/D; y=Y/D; circ=sqr(x-0.333)+sqr(y-0.333)-sqr(r); for(i=0;i printf(white. ); } else if(green) { gotoxy(11,2); printf(green. ); } else if(yellow) { gotoxy(11,2); printf(yellow. ); } else if(skin_tone) { gotoxy(11,2); printf(Skin tone.); } else if(red) { gotoxy(11,2); printf(red. ); } else if(magenta) { gotoxy(11,2); printf(magenta. ); } else if(blue) { gotoxy(11,2); printf(blue. ); } else if(cy ...
Nội dung trích xuất từ tài liệu:
Mạng thần kinh nhân tạo cho phân lớp màu sắc part 2 LÊy rÊt nhiÒu c¸c gi¸ trÞ tõ mét lo¹t c¸c ®iÓm trªn miÒn ®· lùa chän s¾c mµu b»ng c¸ch nh¾p ®¬n nót tr¸i chuét. Chó ý lµ mµn h×nh VGA sÏ hiÖn lªn biÓu ®å mµu vµ cêng ®é mµu t¹i n¬i mµ b¹n trá tíi. N¬i mµ b¹n kÝch vµo sÏ ®¸nh dÊu b»ng mét dÊu thËp mµu ®á trªn biÓu ®å mµu vÏ trªn mµn h×nh VGA (xem h×nh 12.6) vµ lu nã vµo mét m¶ng. NÕu b¹n muèn dêi dÊu thËp ®i chç kh¸c trong trêng hîp c¸c ®iÓm nhËp vµo lín h¬n mét, th× nh¾p nót tr¸i chuét nhiÒu lÇn. Hµnh ®éng nµy sÏ lµm dêi ®i rÊt nhiÒu ®iÓm tuú theo b¹n chän (b¾t ®Çu tõ ®iÓm cuèi cïng) tõ biÓu ®å mµu vµ lu trong m¶ng. Khi b¹n Ên ESC, con trá sÏ xuÊt hiÖn trªn mµn h×nh VGA. §a con trá vµo s¬ ®å mµu vÏ trªn mµn h×nh VGA, b»ng c¸ch kÝch l¹i nót tr¸i chuét ta sÏ thu ®îc d÷ liÖu cho mét líp mµu kh¸c. Nh¾p nót tr¸i chuét, nh tríc ®©y, sÏ lµm dÞch chuyÓn ®Õn ®Çu vµo cuèi cïng. Chó ý r»ng mét dÊu thËp mµu xanh sÏ xuÊt hiÖn bÊt cø khi nµo b¹n nh¾p tr¸i chuét, vµ sÏ bÞ dêi ®i khi b¹n nh¾p ph¶i chuét. NhÊn ESC ®Ó tho¸t. B¹n sÏ ®îc hái tªn file cho chøa d÷ liÖu. D÷ liÖu ®îc lu tr÷ bao gåm 3 sè: sè ®Çu tiªn biÓu diÔn cho x, sè thø hai biÓu diÔn cho y, vµ sè cuèi cïng x¸c ®Þnh líp. Gi¸ trÞ líp nµy ®îc g¸n b»ng 1 trong trêng hîp lùa chän s¾c mµu vµ 0 trong c¸c trêng hîp cßn l¹i. D÷ liÖu ®îc cho díi d¹ng %f%f%d. KÕt qu¶ ta thu ®îc lµ mét cung mµu trªn biÓu ®å mµu ®îc t¸ch ra tõ phÇn cßn l¹i cña phæ mµu. H×nh 12.6 Thu thËp d÷ liÖu cho ph©n líp mµu s¾c. 266 Ch¬ng tr×nh 12.2 COLORRDM.C . Ch¬ng tr×nh thu thËp d÷ liÖu; §îc dïng víi PIB. /************************************ * Developed by M.A.Sid_Ahmed. * * ver. 1.0, 1992. * * @ 1994 *************************************/ /* Program to read color from PIB screen. It also classifies color according to colors in Chromaticity diagram. Use mouse left button to enter x.y coordinates and right button to erase as many previous entries as you wish. The cursor will initially point to the PIB screen, use the mouse to enter the tone you wish to classify as one color set. Press ESC to exit from PIB screen. The cursor mouse will appear on VGA screen. Use mouse to point at points in the Chromaticity diagram that do not belong to the set of colors you wish to classify. Use left button to enter a point, right button to erase previous entry or entries. Press ESC again to exit and store data. */ #include #include #include #include #include #include #define white (circ#define green (l[0]&&l[6]) #define yellow ((!l[0])&&l[1]) #define skin_tone ((!l[1])&&l[2]) #define red ((!l[2])&&l[3]) #define magenta ((!l[3])&&l[4]) #define blue ((!l[4]&&(!l[53)) #define cyan (l[5]&&(!l[6])) #define ESC 0x1B #define LBUTTON 0x01 #define RBUTTON 0x02 void make_cursor(int,int); void find_color(int,int); void move_cursor(int,int); void get_video_mode(int *,int *); void set_video_mode(int); void mouse_cursor_on(void); void mouse_cursor_off(void); void read_mouse(int *, int *, int *); void draw_line(int,int,int,int,int); void draw_circle(int,int,int,int); void set_pixel(int,int,int); void mouse_vrange(int,int); void mouse_hrange(int,int); void set_mouse(int,int); void CIE(void); void draw_cross(float,float,int); int kount=-1; float xold[200],yold[200]; int set[200]; void main() { int mode,page,row,col,button,ind,i; float x,y; char ch,file_name[14]; FILE *fptr; clrscr(); InitPIB(); 268 SetScreen(0); SetInDispMode(); get_video_mode(&mode,&page); set_video_mode(0x12); CIE(); for(i=0;i xold[kount]=x; yold[kount]=y; set[kount]=0; gotoxy(1,3); printf(x=%f y=%f set=%2d total number of points=%4d, xold[kount],yold[kount],set[kount],kount); } else if(button==RBUTTON) { delay(150); draw_cross(xold[kount],yold[kount],BLACK); if(kount>-1) kount--; gotoxy(1,3); printf(x=%f y=%f set=%2d total number of points=%4d, xold[kount],yold[kount],set[kount],kount); } if(kbhit()!=0) { if(getch()==ESC) ind=0; } } gotoxy(1,5); printf(Do you wish to save data? (y or n)-->); while(((ch=getch())!='y')&&(ch!='n')); switch(ch) { case 'y': printf(\n Enter file name -->); scanf(%s,file_name); ind=access(file_name,0); while(!ind) { printf(File exists. Wish to overwrite? (y or n)-->); while(((ch=getch())!='y')&&(ch!='n')); switch(ch) { case 'y': 270 ind=1; break; case 'n': gotoxy(1,6); printf(\n Enter file name --> ); scanf(%s,file_name); ind=access(file_name,0); } } fptr=fopen(file_name,w); for(i=0;ivoid find_color(x1,y1) { unsigned int color,R,G,B; float X,Y,Z,D,x,y; int row,col,button; float m[]={3.3600, 1.260274, 0.663317, - 1.029762, -61.75, 0.384, -0.875}; float c[]={-0.785880, -0.086671, 0.112116, 0.675911, 20.89575, 0.205128, 0.624375}; float r=0.01; float lt,circ; int l[7], i; GetPixel(&color,x1,y1); B=(0x001F & color); G=(0x03E0 & color)>>5; R=(0x7C00 & color)>>10; gotoxy(1,1); printf( blue= %5u, oreen=%5u, red=%5u ,B,G,R); if(R+G+B) { X=2.769*R+1.7518*G+1.1300*B; Y=R+4.5907*G+0.0601*B; Z=0.0565*G+5.5943*B; D=X+Y+Z ; x=X/D; y=Y/D; circ=sqr(x-0.333)+sqr(y-0.333)-sqr(r); for(i=0;i printf(white. ); } else if(green) { gotoxy(11,2); printf(green. ); } else if(yellow) { gotoxy(11,2); printf(yellow. ); } else if(skin_tone) { gotoxy(11,2); printf(Skin tone.); } else if(red) { gotoxy(11,2); printf(red. ); } else if(magenta) { gotoxy(11,2); printf(magenta. ); } else if(blue) { gotoxy(11,2); printf(blue. ); } else if(cy ...
Tìm kiếm theo từ khóa liên quan:
kỹ thuật xử lý ảnh công nghệ xử lý ảnh phương pháp xử lý ảnh hướng dẫn xử lý ảnh kinh nghiệm xử lý ảnhGợi ý tài liệu liên quan:
-
Giáo trình Khai thác phần mềm ứng dụng
247 trang 111 0 0 -
65 trang 87 3 0
-
51 trang 79 0 0
-
21 trang 61 0 0
-
8 trang 48 0 0
-
Ứng dụng phương pháp xử lý ảnh bằng Matlab để phân tích ảnh chuyển động của một vật thể
8 trang 47 0 0 -
393 trang 47 0 0
-
Đồ án tốt nghiệp: Thiết kế, thi công bãi giữ xe ứng dụng công nghệ RFID và xử lý ảnh
85 trang 44 0 0 -
Xây dựng hệ thống nhận dạng lỗi tự động của tấm pin năng lượng mặt trời
3 trang 40 0 0 -
Bài giảng Xử lý ảnh: Chương 6 - Ths. Trần Thúy Hà
38 trang 40 0 0