TEOライブラリによる画像処理プログラミング入門
|
|
- こおが さんきち
- 5 years ago
- Views:
Transcription
1 Image Processing Program using TEO library A Beginners s Guide TEO ライブラリによる画像処理プログラミング入門 菅谷保之著 THE TEO PROJECT
2 PROGRAMMER S NOTEBOOK TEO THE TEO PROJECT
3
4 iii libteo. libteo, TEO C TEO. TEO,. TEO. TEO. TEO, TEO. TEO,, MMX,.. 1, Linux TEO. Linux Vine Linux 3.2,. TEO 2, TEO. TEO. TEO TEO..
5 iv TEO - 4, TEO.,. TEO - 5, TEO.. 6, 5,,,. A libteo A TEO libteo. B TEO B TEO, TEO,. C TEO TeoEyes C TEO teoeyes. D TEO D libteo TEO. E MMX E MMX., Vine Linux 3.2., Vine Linux 3.2,. 1 Vine Linux 3.2 TEO, Vine Linux 3.2,.,. sugaya@suri.it.okayama-u.ac.jp.
6 v libteo libteo TAR RPM TEO TeoEyes TEO TEO TEO TEO libteo TEOFILE TEOIMAGE TEO RGB YCrCb
7 vi TEO A libteo 73 A A A A B TEO 89 B.1 pnm2teo B.2 teo2pnm B.3 teo2avi B.4 teogzip B.5 teo get extension B.6 teocast
8 vii B.7 teodiff B.8 teorange C TEO TeoEyes 95 D TEO 97 D.1 libteopp D.2 ruby-teo D.3 libteo2ipl D.4 libteo D.5 libteo draw D.6 libteo2gdk-pixbuf E MMX
9
10 1 1, TEO libteo., libteo. 1.1 libteo libteo, TEO C.,.,, Windows Linux., TEO,,., BMP, JPEG, PNG, GIF.,.,,,. BMP JPEG,. TEO. TEO, libteo, (Tsukuba), *1 (ETL), (Okayama) TEO. TEO, libteo *1,
11 2 1.,, The FreeBSD libteo 1997, TEO., libteo,. SourceForge WEB, TEO SourceForge, ( 1.1). TEO 1.1 sourceforge TEO 1.2 libteo libteo. libteo sourceforge.jp/project/teo/ ,. TAR rpm
12 1.2 libteo TAR TAR libteo tar.gz,.,,.. % cd /tmp % tar xvfz libteo tar.gz configure Makefile., /usr/local., /usr/local/include, /usr/local/lib. % cd libteo %./configure --prefix=/usr/local configure make,. % make % su [ ] % make install OK. /usr/local/include +--- teo.h +--- teo_debug.h /usr/local/lib +--- libteo.a +--- libteo.la +--- libteo.so +--- libteo.so libteo.so /usr/local/lib/pkgconfig +--- teo.pc
13 RPM rpm libteo vl1.src.rpm,. /usr/local. rpm ( rpmbuild ). rpm VineLinux3.2 % rpm --rebuild libteo vl1.src.rpm rpm, % rpmbuild --rebuild libteo vl1.src.rpm ( 1.2). % rpm -ivh libteo vl1.src.rpm % cd $HOME/rpm/SPECS % emacs libteo.spec libteo.spec prefix. 1.2 libteo.spec
14 1.3 TEO TeoEyes 5. % rpm -ba libteo.spec rpm, % rpmbuild -ba libteo.spec. libteo vl1.i386.rpm, libteo devel-1vl1.i386.rpm. $HOME/rpm/RPMS/i libteo vl1.i386.rpm +--- libteo-devel vl1.i386.rpm rpm libteo vl1.i386,rpm. % rpm -qpl../rpms/i386/libteo-devel vl1.i386.rpm /usr/local/include/teo.h /usr/local/include/teo_debug.h /usr/local/lib/libteo.la. % rpm -ivh../rpms/i386/libteo vl1.i386.rpm % rpm -ivh../rpms/i386/libteo-devel vl1.i386.rpm 1.3 TEO TeoEyes TEO TeoEyes., TeoEyes teo/ TeoEyes,. gtk+-2.2 (ftp://ftp.gtk.org/pub/gtk/v2.2/) GNOME-2.2 (
15 6 1 GConf libgnomeui libgnomeprint libgnomeprintui gtkhtml gtk+, GNOME.. % cd /tmp % tar xvfz teoeyes tar.bz2 % cd teoeyes %./configure --prefix=/usr/local % make % su [ ] % make install teoeyes, 1.3. % teoeyes 1.3 TeoEyes
16 Vine Linux 3.2. C, (GCC). glibc gcc-3.3.2, libteo /usr/local., pkg-config.
17
18 9 2 TEO TEO,. TEO,. 2.1,. 2.1, () (). 3,... ( 2.2),.,., , 2.2 X, Y.,, X, Y,.
19 10 2 TEO 2.1 ( 0, 0) x y 2.2, JPEG, GIF, PNG, PPM, BMP. (),., Linux Free BSD UNIX OS PPM, Windows BMP., 2.1. JPEG (Joint Photographic Experts Group)., DCT. GIF (Graphic Interchange Format) 8 (256 ) 256., ().. GIF, GIF, GIF. PNG (Portable Network Graphics), ( ).,, *1. PPM (Portable PixMap) Linux Free BSD UNIX OS. *1
20 2.2 TEO 11. BMP (Windows Bitmap) Windows. Device Independent Bitmap DIB., RLE., BMP. 2.2 TEO TEO PPM. TEO,., , TEO.,.,,. PPM ,.,. TEO, , X, Y. TEO, ( ),. PPM (PGM) 1, 3., TEO,,.,.. ()., TEO. TEO. TEO,. (User Extension) TEO,.
21 12 2 TEO 2.3 TEO 2.3,, , ( 2.5).. <D>, (0x20) TAB(0x09), <CR> (0x0a). [ ]. 0x54, 0x45, 0x4f 3, T, E, O., 0, 1. 1.,,., (0, 0)., U/S/F,, U, S, F. 1, 8, 16, 32, 64.,,. 2. #.. #. #. #%. -. "#! $ %'& " (" ')+*+, 2.3 TEO
22 TEO 1 # generated by TEO library version Version U ;b2>g5Aj7Cl5Aj0;h2=j2:h5Bg7Di:Fo:Fo9Bl9Bl7Bo5@m5@m5@m:Er<Al7<g9Bl9Bl7@j7Cl5Aj7Cl 7Cl9Bl9Bl5@m5@m2?d<Fl7Ag4=g7@j9Ci<Fl7Di:Gl5Bg2<b0: 5Bg5Bg2?d5Bg7Di9Ci<Fl5Aj5Aj?El 7=d9Ci:@g7=d:@g<Bi5Bg5Bg:Fo7Cl2>g4>d9Ci4?a4?a7Ag9Ci<Bi9Bl9Bl5Aj2>g:Fo5Aj0;h2=j>Ft ENx<Eo2<b4>d:@g5;b:Ad4>d4>d5Bg5Bg7Bd7Bd:@g<Bi9Ao7@j9Bl5Bg:Gl7=d<Bi<>g<Gi9Df2=_2=_ )4V0;]?ElFLs7>a+6T2=[5<_:Ad:Ad:Ad:Ad:@g<Bi9Df9Df<Gi9Df7Bd9Df7B 2@]5C 9Df4?a7Bd9Df <Cf<Cf?Fi<Bi:@g:@g<Bi7Ag7Ag7=d7>a:Ad7Ag7Ag7Di7Di?El5;b:@g7Bd4?a9Df7Bd:A :A 7Bd7Bd 7Bd2@a2@a2=_7Bd:@g:@g7=d7=d:@g:@g:@g:@... -.;8-B?4B?4LI0> NL=XVGZXIZXIXVG_]NcaR^WNWQDWQD]TD_VF_VF_VFSN=SN=a\KUTAUTA\WF\WF\WF\WFdZN^XK\VI\[H ZYFWQDZTGWPGWPG\YN_\Q\YNXUNXUNWWSYYUTYSMQSAEG07@$+4+0A).?)2E,5H)2E 2.4 TEO <D> [<D>#]<CR> [#<CR>[#<CR>...]] <D> [<D>X <D>Y ][<D>#]<CR> [#<CR>[#<CR>...]] <D> [<D>#]<CR> [#<CR>[#<CR>...]] <D> [<D>#]<CR> (/8) [ ] (2.1) 1. ( ) ( 1)/8 + 1 [ ] (2.2), (floor). RGB 3, 2.3, RGB.,.
23 14 2 TEO 16, 32, 64,, TEO., 1, 8., 8. 8, TEO TEO GZIP yes, TEO., libteo TEO. TEO,, teogzip, teogunzip.
24 15 3 TEO. libteo,., Makefile , libteo teo.h. libteo libteo, TEO. TEO TeoOpenFile. 16 TEO TEO. TeoCreateSimilarFile TEO (TEOFILE ), TEO. 19, 20 TeoAllocSimilarImage,
25 16 3 TEO. 23 TeoReadFrame,. TeoAllocSimilarImage, TeoXstart, TeoXend, TeoYstart, TeoYend,.,. TeoGetPixel, TeoPutPixel., 28. TeoPlane., TeoWriteFrame. TeoReadFrame,,,., (TeoFreeImage), (TeoClose- File). 3.1, copy.c,. % gcc copy.c -o copy -I/usr/local/include -L/usr/local/lib -lteo pkg-config,. % gcc copy.c -o copy pkg-config --cflags --libs teo, copy,. teoeyes.. %./copy color.teo color-copy.teo % teoeyes color-copy.teo # include <stdio. h> 2 #include <teo.h> /* T E O */ 3 4 int 5 main ( int argc, 6 char **argv) { 7 TEOFILE * src_ teofp, * dst_ teofp; 8 TEOIMAGE * src_img, * dst_ img; 9 int x, y, p; 10 TEO_ UINT8 val;
26 3.2 libteo /* */ 13 src_ teofp = TeoOpenFile ( argv[ 1]); /* */ 16 dst_ teofp = TeoCreateSimilarFile ( argv[2], src_ teofp); /* */ 19 src_ img = TeoAllocSimilarImage ( src_ teofp); 20 dst_ img = TeoAllocSimilarImage ( dst_ teofp); /* */ 23 TeoReadFrame ( src_ teofp, src_ img); /* */ 26 for ( y = TeoYstart ( src_ img); y <= TeoYend ( src_ img); y++) { 27 for ( x = TeoYstart ( src_ img); x <= TeoYend ( src_ img); x++) { 28 for ( p = 0; p < TeoPlane ( src_ img); p++) { 29 /* */ 30 val = TeoGetPixel ( src_img, x, y, p, TEO_ UINT8); 31 /* */ 32 TeoPutPixel ( dst_img, x, y, p, TEO_ UINT8, val); 33 } 34 } 35 } 36 /* */ 37 TeoWriteFrame ( dst_ teofp, dst_ img); /* */ 40 TeoCloseFile ( src_ teofp); 41 TeoCloseFile ( dst_ teofp); /* */ 44 TeoFreeImage ( src_ img); 45 TeoFreeImage ( dst_ img); return 0; 48 } 3.2 libteo libteo TEOFILE TEOFILE TEO.,. TEOFILE., TEOFILE,
27 18 3 TEO TEOIMAGE. TEOFILE 3.2. libteo TEOFILE ( ). 3.2 TEOFILE typedef struct { int width; /* */ int height; /* */ int xoffset; /* X */ int yoffset; /* Y */ int type; /* */ int bit; /* */ int plane; /* */ int frame; /* */ int current; /* */ int extc; /* */ char **extv; /* */ int fsize; /* 1 */ int hsize; /* */ FILE *fp; /* */ int ac_type; /* */ char *filename; /* */ char *tmpfile; /* */ } TEOFILE; TEOIMAGE TEOIMAGE 3.3. TEOIMAGE TEO. TEO, TEOFILE, 1 TEOIMAGE 2. TeoData.,.,. 3.3 TEOIMAGE typedef struct { int width; /* */ int height; /* */ int xoffset; /* X */ int yoffset; /* Y */ int type; /* */ int bit; /* */ int plane; /* */ char *data; /* */ int fsize; /* 1 */ } TEOIMAGE;
28 libteo,., libteo.,. TEO BIT... 0, 1 2 TEO UINT8... 8bit TEO SINT8... 8bit TEO UINT bit TEO SINT bit TEO UINT bit TEO SINT bit TEO FLOAT bit TEO FLOAT bit,. TeoCreateFile TeoAllocImage. TEO UNSIGNED... TEO SIGNED... TEO FLOAT libteo., TEO,. TEO GZIP TEO. yes, no (). % setenv TEO GZIP yes TEO GZIP COMMAND., (/usr/bin/gzip ). % setenv TEO GZIP COMMAND "/usr/bin/gzip -c" TEO GUNZIP COMMAND TEO. (/usr/bin/gzip
29 20 3 TEO ). % setenv TEO GUNZIP COMMAND "/bin/zcat" TEO TMP DIR., /tmp. % setenv TEO TMP DIR "$HOME/tmp",.login. 3.1.login. 3.1.login 3.4 libteo TeoGetPixel, TeoPutPixel, TeoGetPixel, TeoPutPixel TEOIMAGE NULL TeoAllocImage TeoGetPixel, TeoPutPixel, TeoGetBit, TeoPutBit 2 TeoCloseFile (TeoWriteFrame ) TeoAllocImage (100MB ) TeoOpenFile, TeoCreateFile *.teo 3
30 3.5 21,. -DTEO DEBUG1 -DTEO DEBUG2 -DTEO DEBUG3 -DTEO DEBUG ALL 1, 2, 3. -DTEO DEBUG ALL. -DTEO DEBUG3. -DTEO DEBUG ERROR,.,,. 3.5 libteo.,., 3.1, , argc, USAGE. 2., TeoOpenFile NULL.. 3. TEO UINT8 8., TeoIsUINT8. 4., TeoCreate{Similar}File NULL.. 5. TeoAlloc{Similar}Image, NULL
31 22 3 TEO 56, TeoXstart, TeoYstart, TeoXend, TeoYend, (x, y).,,., libteo, *1. TEO ERROR CODE. TEO ERROR MESSAGE. TEO ERROR MESSAGE, extern. 3.4 teo TEO ERROR MESSAGE. 3.4 copy2,,. %./copy2 nofile.teo output.teo Read error! Can t open file nofile.teo. (error code:1) 3.4 () 1 # include <stdio. h> 2 #include <teo.h> /* T E O */ 3 4 extern char TEO_ ERROR_ MESSAGE[]; 5 6 int 7 main ( int argc, 8 char **argv) { 9 TEOFILE * src_ teofp, * dst_ teofp; 10 TEOIMAGE * src_img, * dst_ img; 11 int x, y, p; 12 TEO_ UINT8 val; /* */ 15 if (argc!= 3) { 16 fprintf (stderr, "Usage: %s in.teo out.teo\n", argv[0]); 17 exit (1); *1 teo.h. teo.h. TEO ERROR MESSAGE.
32 } 19 /* */ 20 src_ teofp = TeoOpenFile ( argv[ 1]); 21 if (! src_ teofp) { 22 fprintf ( stderr, 23 "%s (error code:%d)\n", TEO_ERROR_MESSAGE, TEO_ERROR_CODE); 24 goto settle; 25 } 26 /* */ 27 if (! TeoISUINT8( src_ teofp)) { 28 fprintf ( stderr, 29 " Pixel type UINT8 is only supported in this program.\ n"); 30 goto settlel 31 } 32 /* */ 33 dst_ teofp = TeoCreateSimilarFile ( argv[2], src_ teofp); 34 if (! dst_ teofp) { 35 fprintf ( stderr, 36 "%s (error code:%d)\n", TEO_ERROR_MESSAGE, TEO_ERROR_CODE); 37 goto settle; 38 } 39 /* */ 40 src_ img = TeoAllocSimilarImage ( src_ teofp); 41 if (!src_img) { 42 fprintf ( stderr, 43 "%s (error code:%d)\n", TEO_ERROR_MESSAGE, TEO_ERROR_CODE); 44 goto settle; 45 } 46 dst_ img = TeoAllocSimilarImage ( dst_ teofp); 47 if (!dst_img) { 48 fprintf ( stderr, 49 "%s (error code:%d)\n", TEO_ERROR_MESSAGE, TEO_ERROR_CODE); 50 goto settle; 51 } 52 /* */ 53 TeoReadFrame ( src_ teofp, src_ img); /* */ 56 for ( y = TeoYstart ( src_ img); y <= TeoYend ( src_ img); y++) { 57 for ( x = TeoYstart ( src_ img); x <= TeoYend ( src_ img); x++) { 58 for ( p = 0; p < TeoPlane ( src_ img); p++) { 59 /* */ 60 val = TeoGetPixel ( src_img, x, y, p, TEO_ UINT8); 61 /* */ 62 TeoPutPixel ( dst_img, x, y, p, TEO_ UINT8, val); 63 } 64 } 65 } 66 /* */ 67 TeoWriteFrame ( dst_ teofp, dst_ img);
33 24 3 TEO settle: 70 /* */ 71 if ( src_ teofp) TeoCloseFile ( src_ teofp); 72 if ( dst_ teofp) TeoCloseFile ( dst_ teofp); /* */ 75 if ( src_ img) TeoFreeImage ( src_ img); 76 if ( dst_ img) TeoFreeImage ( dst_ img); return 0; 79 } 3.6, gcc. make. make Makefile. Makefile, make., Makefile, Makefile, libteo. 3.5 Makefile., 3 libteo TEODIR., 4 CFLAGS libteo (teo.h), 5 LDFLAGS. LIBS, libteo -lteo., copy.c, teo copy, SRCS, PROGRAM,. libteo, make. 3.5 Makefile 1 CC = gcc 2 INSTALL = / usr/ bin/ install 3 TEODIR = / usr/ local 4 CFLAGS = -O2 -I$( TEODIR)/ include -Wall -DTEO_ DEBUG_ ALL 5 LDFLAGS = -L$( TEODIR)/ lib 6 LIBS = -lteo -lm 7 DEST = $( HOME)/ bin 8 SRCS = copy. c 9 OBJS = $(SRCS:.c=.o) 10 PROGRAM = teo_ copy 11 all: $( PROGRAM) 12 $( PROGRAM): $( OBJS) 13 $( CC) $( OBJS) $( LDFLAGS) $( LIBS) -o $( PROGRAM) 14 clean:; rm -f *. o * ~ $( PROGRAM)
34 install: $( PROGRAM) 16 $( INSTALL) -s $( PROGRAM) $( DEST) 17 strip $( DEST)/ $( PROGRAM)
35
36 27 4 TEO -, TEO,.,. 1. RGB. 2. (RGB YCrCb ).,., RGB YCrCb. 3. ( 2 ) 2, 1 TEO. 4. () RGB,. RGB. gray = R G B (4.1) R, G, B RGB. (4.1) RGB 0 255
37 28 4 TEO -.. RGB, TEO UINT8 3., TEO UINT8 1.,.,. teo rgb2gray. teo rgb2gray : RGB TEO ( :TEO UINT8, : ) : TEO ( :TEO UINT8, :1) : RGB, 1 TEO. 4.1.,...,. ( ).,.,. 50. RGB,. 3 TEO UINT8 func rgb2gray, TEOIMAGE, TEOIM- AGE..,.. (13 19 ).,,, 1. (21 29 ).. RGB (23 25 ) 1, 2, 3 ( 1 0
38 ), TeoGetPixel, TEOIMAGE (x, y). (26 ) (4.1) RGB, gray.,, TEO UINT8. (27 ) gray TeoPutPixel, (x, y) RGB. 4.1 RGB 1 # include <stdio. h> 2 #include <teo.h> /* T E O */ 3 4 static TEOIMAGE* func_ rgb2gray ( TEOIMAGE * src); 5 6 static TEOIMAGE* 7 func_ rgb2gray ( TEOIMAGE * src) { 8 TEOIMAGE * dst; 9 int row, col; 10 TEO_ UINT8 r, g, b, gray; /* */ 13 dst = TeoAllocImage ( TeoWidth ( src), 14 TeoHeight ( src), 15 TeoXoffset ( src), 16 TeoYoffset ( src), 17 TeoType (src), 18 TeoBit (src), 19 1); 20 /* */ 21 for ( row = TeoYstart ( src); row <= TeoYend ( src); row++) { 22 for ( col = TeoXstart ( src); col <= TeoXend ( src); col++) { 23 r = TeoGetPixel ( src, col, row, 0, TEO_ UINT8); 24 g = TeoGetPixel ( src, col, row, 1, TEO_ UINT8); 25 b = TeoGetPixel ( src, col, row, 2, TEO_ UINT8); 26 gray = ( TEO_ UINT8) ( * r * g * b); 27 TeoPutPixel ( dst, col,row, 0, TEO_ UINT8, gray); 28 } 29 } 30 return dst; 31 } int 34 main ( int argc, 35 char **argv) { 36 TEOFILE * src_ teofp = NULL, * dst_ teofp = NULL; 37 TEOIMAGE * src_ img = NULL, * dst_ img = NULL; 38
39 30 4 TEO - 39 /* */ 40 if (argc!= 2) { 41 fprintf (stderr, "Usage: %s in.teo\n", argv[0]); 42 exit (1); 43 } 44 /* */ 45 src_teofp = TeoOpenFile (argv[1]); /* T E O */ 46 src_img = TeoAllocSimilarImage (src_teofp);/* */ 47 TeoReadFrame (src_teofp, src_img); /* */ /* */ 50 if ( TeoPlane ( src_ img) < 3! TeoIsUINT8 ( src_ img)) { 51 fprintf ( stderr, " Wrong image type!\ n"); 52 goto settle; 53 } 54 /* */ 55 dst_ teofp = TeoCreateFile (" -", 56 TeoWidth ( src_ img), 57 TeoHeight ( src_ img), 58 TeoXoffset ( src_ img), 59 TeoYoffset ( src_ img), 60 TeoType ( src_ img), 61 TeoBit ( src_ img), 62 1, 63 1); 64 /* */ 65 dst_ img = func_ rgb2gray ( src_ img); /* */ 68 TeoWriteFrame ( dst_ teofp, dst_ img); 69 settle: 70 /* */ 71 if ( src_ teofp) TeoCloseFile ( src_ teofp); 72 if ( dst_ teofp) TeoCloseFile ( dst_ teofp); /* */ 75 if ( src_ img) TeoFreeImage ( src_ img); 76 if ( dst_ img) TeoFreeImage ( dst_ img); return 0; 79 }
40 4.2 - RGB YCrCb - 31 (a) (b) 4.1 RGB RGB YCrCb -. RGB YCrCb. YCrCb, Y() Cr, Cb( ). Y, Cr, Cb. NTSC YCrCb. RGB YCrCb. Y = R G B Cr = R G B Cb = R G B (4.2) (4.2), YCrCb TEO UINT8., YCrCb TEO FLOAT64.. teo rgb2yc. 4.2 RGB YCrCb. teo rgb2yc : RGB TEO ( :TEO UINT8, :3) : YCrCbTEO ( :TEO FLOAT64, :3) : RGB YCrCb, YCrCb TEO FLOAT64 3 TEO ,., 62. TEO UINT8 TEO FLOAT64, 1 3.
41 32 4 TEO -. (11 ) Y, Cr, Cb TEO FLOAT64. (14 20 ).,, TEO FLOAT64, 3. (22 23 ).. RGB (24 26 ) 1, 2, 3 ( 1 0 ), TeoGetPixel, TEOIMAGE (x, y). YCrCb (28 30 ) (4.2) RGB YCrCb,. (32 34 ) YCrCb TeoPutPixel (x, y)., TEO FLOAT64, TeoPutPixel TEO FLOAT RGB YCrCb 1 # include <stdio. h> 2 #include <teo.h> /* T E O */ 3 4 static TEOIMAGE* func_ rgb2yc ( TEOIMAGE * src); 5 6 static TEOIMAGE* 7 func_ rgb2yc ( TEOIMAGE * src) { 8 TEOIMAGE * dst; 9 int row, col; 10 TEO_ UINT8 r, g, b; 11 TEO_ FLOAT64 Y, Cr, Cb; /* Y C r C b */ 14 dst = TeoAllocImage ( TeoWidth ( src), 15 TeoHeight ( src), 16 TeoXoffset ( src), 17 TeoYoffset ( src), 18 TEO_ FLOAT, 19 64, 20 3); 21 /* Y C r C b */ 22 for ( row = TeoYstart ( src); row <= TeoYend ( src); row++) { 23 for ( col = TeoXstart ( src); col <= TeoXend ( src); col++) { 24 r = TeoGetPixel ( src, col, row, 0, TEO_ UINT8); 25 g = TeoGetPixel ( src, col, row, 1, TEO_ UINT8); 26 b = TeoGetPixel ( src, col, row, 2, TEO_ UINT8); 27
42 4.2 - RGB YCrCb Y = * r * g * b; 29 Cr = * r * g * b; 30 Cb = * r * g * b; TeoPutPixel ( dst, col, row, 0, TEO_ FLOAT64, Y); 33 TeoPutPixel ( dst, col, row, 1, TEO_ FLOAT64, Cr); 34 TeoPutPixel ( dst, col, row, 2, TEO_ FLOAT64, Cb); 35 } 36 } 37 return dst; 38 } int 41 main ( int argc, 42 char **argv) { 43 TEOFILE * src_ teofp, * dst_ teofp; 44 TEOIMAGE * src_img, * dst_ img; /* */ 47 if (argc!= 2) { 48 fprintf (stderr, "Usage: %s in.teo\n", argv[0]); 49 exit (1); 50 } 51 /* */ 52 src_teofp = TeoOpenFile (argv[1]); /* T E O */ 53 src_img = TeoAllocSimilarImage (src_teofp);/* */ 54 TeoReadFrame (src_teofp, src_img); /* */ /* */ 57 if ( TeoPlane ( src_ img) < 3! TeoIsUINT8 ( src_ img)) { 58 fprintf ( stderr, " Wrong image type!\ n"); 59 goto settle; 60 } 61 /* */ 62 dst_ teofp = TeoCreateFile (" -", 63 TeoWidth ( src_ img), 64 TeoHeight ( src_ img), 65 TeoXoffset ( src_ img), 66 TeoYoffset ( src_ img), 67 TEO_ FLOAT, 68 64, 69 3, 70 1); 71 /* */ 72 dst_ img = func_ rgb2yc ( src_ img); /* */ 75 TeoWriteFrame ( dst_ teofp, dst_ img); 76 settle: 77 /* */
43 34 4 TEO - 78 if ( src_ teofp) TeoCloseFile ( src_ teofp); 79 if ( dst_ teofp) TeoCloseFile ( dst_ teofp); /* */ 82 if ( src_ img) TeoFreeImage ( src_ img); 83 if ( dst_ img) TeoFreeImage ( dst_ img); return 0; 86 } (a) (b) YCrCb (c) Y (d) Cr (e) Cb 4.2 RGB YCrCb
44 , 1 1, , 1 2,. 2. 0, 1. 2., RGB, teo binary. 4.3 teo binary,. teo binary 1 2 : RGB TEO, TEO : : ( :TEO UINT8, :1) :,.,.,. B n = 0 A YES!#"$%&? NO *+, " -. n < '0/? YES NO n '(!#"$ ) n 12 n 3 n + 1 B A 4.3 2
45 36 4 TEO (70 ) for. n (71 ) n. (72 74 ), 1 (RGB ),. (75 ) dst img 2. dst img. n (78 ) 2. TeoReadFrame TeoWriteFrame,.,,. func rgb2gray RGB. TEOIMAGE,,.. func binary 2., 255, , () :, :2
46 ( ) :, : # include <stdio. h> 2 #include <teo.h> /* T E O */ 3 4 static void func_ rgb2gray ( TEOIMAGE * src, 5 TEOIMAGE *dst); 6 static void func_ binary ( TEOIMAGE * src, 7 TEO_ UINT8 threshold); 8 9 static void 10 func_ rgb2gray ( TEOIMAGE * src, 11 TEOIMAGE * dst) { 12 int row, col; 13 TEO_ UINT8 r, g, b, gray; for ( row = TeoYstart ( src); row <= TeoYend ( src); row++) { 16 for ( col = TeoXstart ( src); col <= TeoXend ( src); col++) { 17 r = TeoGetPixel ( src, col, row, 0, TEO_ UINT8); 18 g = TeoGetPixel ( src, col, row, 1, TEO_ UINT8); 19 b = TeoGetPixel ( src, col, row, 2, TEO_ UINT8); 20 gray = ( TEO_ UINT8) ( * r * g * b); 21 TeoPutPixel ( dst, col,row, 0, TEO_ UINT8, gray); 22 } 23 } 24 } static void 27 func_ binary ( TEOIMAGE * src, 28 TEO_ UINT8 threshold) { 29 int row, col; 30 TEO_ UINT8 val; for ( row = TeoYstart ( src); row <= TeoYend ( src); row++) { 33 for ( col = TeoXstart ( src); col <= TeoXend ( src); col++) { 34 val = TeoGetPixel ( src, col, row, 0, TEO_ UINT8);
47 38 4 TEO - 35 val = ( val > threshold)? 255 : 0; 36 TeoPutPixel ( src, col, row, 0, TEO_ UINT8, val); 37 } 38 } 39 } int 42 main ( int argc, 43 char **argv) { 44 TEOFILE * src_ teofp, * dst_ teofp; 45 TEOIMAGE * src_img, * dst_ img; 46 TEO_ UINT8 threshold; 47 int n; /* */ 50 if (argc!= 3) { 51 fprintf (stderr, "Usage: %s in.teo #threshold\n", argv[0]); 52 exit (1); 53 } 54 /* */ 55 src_teofp = TeoOpenFile (argv[1]); /* T E O */ 56 src_img = TeoAllocSimilarImage (src_teofp);/* */ /* 2 */ 59 threshold = ( TEO_ UINT8) atoi ( argv[ 2]); /* */ 62 dst_ teofp = TeoCreateFile (" -", 63 TeoWidth ( src_ img), TeoHeight ( src_ img), 64 TeoXoffset ( src_ img), TeoYoffset ( src_ img), 65 TEO_UNSIGNED, 8, 1, TeoFrame (src_teofp)); 66 /* */ 67 dst_ img = TeoAllocSimilarImage ( dst_ teofp); /* - */ 70 for ( n = 0; n < TeoFrame ( src_ teofp); n++) { 71 TeoReadFrame ( src_ teofp, src_ img); 72 if (TeoPlane (src_img) == 1) { /* R G B */ 73 func_ rgb2gray ( src_img, dst_ img); 74 } 75 func_binary (dst_img, threshold); /* 2 */ /* */ 78 TeoWriteFrame ( dst_ teofp, dst_ img); 79 } 80 /* */ 81 if ( src_ teofp) TeoCloseFile ( src_ teofp); 82 if ( dst_ teofp) TeoCloseFile ( dst_ teofp); /* */
48 if ( src_ img) TeoFreeImage ( src_ img); 86 if ( dst_ img) TeoFreeImage ( dst_ img); return 0; 89 } ,... ( 4.6)., ( ) ( 4.6)., 1.,, ( 4.6)..,., [ ][].teo., image00.teo, image01.teo,, image09.teo, image%02d.teo, n = 0,,
49 40 4 TEO - int n; char name[ 1024]; for ( n = 0; n < 10; n++) { sprintf (name, "image%02d.teo", n); printf ("%s\n", name); } teo detect motion : : : : :. 1,., (67 70 ),, 3. (72 ). (75 82 ).., (84 90 ),., -1 (92 94 ) func sub image,. ( ).,. ( ). func sub image. threshold 1, 0. threshold = 8. func detect motion, 1,. ( 255)
50 :, : # include <stdio. h> 2 #include <teo.h> /* T E O */ 3 4 static void func_ and_ image ( TEOIMAGE * src1, 5 TEOIMAGE * src2, 6 TEOIMAGE * color, 7 TEOIMAGE *dst); 8 static void func_ sub_ image ( TEOIMAGE * src1, 9 TEOIMAGE * src2, 10 TEOIMAGE * dst); static void 13 func_ and_ image ( TEOIMAGE * src1, 14 TEOIMAGE * src2, 15 TEOIMAGE * color, 16 TEOIMAGE * dst) { 17 TEO_ UINT8 val1, val2; 18 int row, col, p; for ( row = TeoYstart ( src1); row <= TeoYend ( src1); row++) { 21 for ( col = TeoXstart ( src1); col <= TeoXend ( src1); col++) { 22 val1 = TeoGetPixel ( src1, col, row, 0, TEO_ UINT8); 23 val2 = TeoGetPixel ( src2, col, row, 0, TEO_ UINT8); 24 if (val1 && val2) { 25 for ( p = 0; p < TeoPlane ( color); p++) { 26 TeoPutPixel ( dst, col,row, p, TEO_ UINT8, 27 TeoGetPixel ( color, col, row, p, TEO_ UINT8)); 28 } 29 } else {
51 42 4 TEO - 30 for ( p = 0; p < TeoPlane ( color); p++) { 31 TeoPutPixel ( dst, col,row, p, TEO_ UINT8, 255); 32 } 33 } 34 } 35 } 36 } static void 39 func_ sub_ image ( TEOIMAGE * src1, 40 TEOIMAGE * src2, 41 TEOIMAGE * dst) { 42 TEO_ UINT8 val1, val2, threshold = 8; 43 int row, col; for ( row = TeoYstart ( src1); row <= TeoYend ( src1); row++) { 46 for ( col = TeoXstart ( src1); col <= TeoXend ( src1); col++) { 47 val1 = TeoGetPixel ( src1, col, row, 0, TEO_ UINT8); 48 val2 = TeoGetPixel ( src2, col, row, 0, TEO_ UINT8); 49 if ( abs ( val1 - val2) > threshold) { 50 TeoPutPixel ( dst, col,row, 0, TEO_ UINT8, 1); 51 } else { 52 TeoPutPixel ( dst, col,row, 0, TEO_ UINT8, 0); 53 } 54 } 55 } 56 } int 59 main ( int argc, 60 char **argv) { 61 TEOFILE * src_ teofp, * dst_ teofp; 62 TEOIMAGE **src_img, **sub_img, *dst_img; 63 int n, frame; 64 char name[ 1024]; /* */ 67 if (argc!= 4) { 68 fprintf ( stderr, " Usage: % s in_ header # frame out_ header\ n", argv[ 0]); 69 exit (1); 70 } 71 /* */ 72 frame = atoi ( argv[ 2]); /* */ 75 src_ img = ( TEOIMAGE **) malloc ( sizeof ( TEOIMAGE *) * frame); 76 for ( n = 0; n < frame; n++) { 77 sprintf ( name, argv[1], n); 78 src_ teofp = TeoOpenFile ( name); 79 src_ img[ n] = TeoAllocSimilarImage ( src_ teofp);
52 TeoReadFrame ( src_ teofp, src_ img[ n]); 81 TeoCloseFile ( src_ teofp); 82 } 83 /* */ 84 dst_ img = TeoAllocSimilarImage ( src_ img[ 0]); /* */ 87 sub_img = (TEOIMAGE **) malloc (sizeof (TEOIMAGE *) * (frame - 1)); 88 for ( n = 0; n < frame - 1; n++) { 89 sub_ img[ n] = TeoAllocSimilarImage ( src_ img[ n]); 90 } 91 /* */ 92 for ( n = 0; n < frame - 1; n++) { 93 func_sub_image (src_img[n+1], src_img[n], sub_img[n]); 94 } 95 /* A N D */ 96 for ( n = 1; n < frame - 1; n++) { 97 func_and_image (sub_img[n-1], sub_img[n], src_img[n], dst_img); 98 sprintf ( name, argv[3], n); 99 dst_ teofp = TeoCreateFile ( name, 100 TeoWidth ( dst_ img), TeoHeight ( dst_ img), 101 TeoXoffset ( dst_ img), TeoYoffset ( dst_ img), 102 TeoType ( dst_ img), TeoBit ( dst_ img), 103 TeoPlane ( dst_ img), 1); 104 TeoWriteFrame ( dst_ teofp, dst_ img); 105 TeoCloseFile ( dst_ teofp); 106 } 107 /* */ 108 for ( n = 0; n < frame; n++) TeoFreeImage ( src_ img[ n]); 109 for ( n = 0; n < frame - 1; n++) TeoFreeImage ( sub_ img[ n]); 110 free ( src_ img); 111 free ( sub_ img); 112 TeoFreeImage ( dst_ img); return 0; 115 }
53
54 45 5 TEO - TEO.,,.,.,,., B A, C f x (B A), f x (C B) I(x, y) (x, y) f x (B A) = I(x, y) I(x 1, y) (5.1) f x (C B) = I(x + 1, y) I(x, y) (5.2)
55 46 5 TEO - A B C f ( B - A ) x f ( C - B ) x f ( C - B ) - f ( B - A ) x x B 2 1 ( (5.3)) f xx (x, y) = f x (B A) f x (C B) = I(x 1, y) + I(x + 1, y) 2I(x, y) (5.3) B 2 2 f(x, y) = I(x 1, y) + I(x + 1, y) + I(x, y 1) + I(x, y + 1) 4I(x, y) (5.4) 5.2(a) 5.2(b) (b) (a) (a) 4 (b) 8 (b)
56 # include <stdio. h> 2 #include <teo.h> /* T E O */ 3 4 static TEOIMAGE* func_ laplacian ( TEOIMAGE * src); 5 6 static TEOIMAGE* func_ laplacian ( TEOIMAGE * src) { 7 TEOIMAGE * dst; 8 TEO_ FLOAT64 sum; 9 int row, col; dst = TeoAllocImage ( TeoWidth ( src), TeoHeight ( src), 12 TeoXoffset ( src), TeoYoffset ( src), 13 TEO_FLOAT, 64, 1); for ( row = TeoYstart ( src) + 1; row <= TeoYend ( src) - 1; row++) { 16 for ( col = TeoXstart ( src) + 1; col <= TeoXend ( src) - 1; col++) { 17 sum = ( TEO_ FLOAT64) TeoGetPixel ( src, col -1, row -1, 0, TEO_ UINT8); 18 sum += ( TEO_ FLOAT64) TeoGetPixel ( src, col, row -1, 0, TEO_ UINT8); 19 sum += ( TEO_ FLOAT64) TeoGetPixel ( src, col+1, row -1, 0, TEO_ UINT8); 20 sum += ( TEO_ FLOAT64) TeoGetPixel ( src, col -1, row, 0, TEO_ UINT8); 21 sum += ( TEO_ FLOAT64) TeoGetPixel ( src, col+1, row, 0, TEO_ UINT8); 22 sum += ( TEO_ FLOAT64) TeoGetPixel ( src, col -1, row+1, 0, TEO_ UINT8); 23 sum += ( TEO_ FLOAT64) TeoGetPixel ( src, col, row+1, 0, TEO_ UINT8); 24 sum += ( TEO_ FLOAT64) TeoGetPixel ( src, col+1, row+1, 0, TEO_ UINT8); 25 sum -= ( TEO_ FLOAT64) TeoGetPixel ( src, col, row, 0, TEO_ UINT8)* 8; 26 TeoPutPixel ( dst, col,row, 0, TEO_ FLOAT64, sum); 27 } 28 } 29 return dst; 30 } int main ( int argc, char ** argv) { 33 TEOFILE * src_ teofp, * dst_ teofp; 34 TEOIMAGE * srcimg, * dstimg; /* */ 37 if (argc!= 2) { 38 fprintf (stderr, "Usage: %s in.teo\n", argv[0]); 39 exit (1); 40 } 41 /* */ 42 src_teofp = TeoOpenFile (argv[1]); /* T E O */ 43 srcimg = TeoAllocSimilarImage (src_teofp);/* */ 44 TeoReadFrame (src_teofp, srcimg); /* */ /* */ 47 if ( TeoPlane ( src_ teofp) < 3! TeoIsUINT8 ( src_ teofp)) { 48 fprintf ( stderr, " This image trowpe is not supported.\ n"); 49 TeoCloseFile ( src_ teofp);
57 48 5 TEO - 50 TeoFreeImage ( srcimg); 51 exit (1); 52 } 53 /* */ 54 dst_ teofp = TeoCreateFile (" -", 55 TeoWidth ( src_ teofp), 56 TeoHeight ( src_ teofp), 57 TeoXoffset( src_ teofp), 58 TeoYoffset( src_ teofp), 59 TEO_FLOAT, 64, 1, 1); /* */ 62 dstimg = func_ laplacian ( srcimg); /* */ 65 TeoWriteFrame ( dst_ teofp, dstimg); /* */ 68 TeoCloseFile ( src_ teofp); 69 TeoCloseFile ( dst_ teofp); /* */ 72 TeoFreeImage ( srcimg); 73 TeoFreeImage ( dstimg); return 0; 76 } w(x, y) = e (x2 +y 2 )/2σ 2 σ (5.5) I (x, y) = 1 σ σ w(k, l) I(x + k, y + l) (5.5) C k= σ l= σ C
58 (a) (b) w(x, y) = e (x2 +y 2 )/2σ 2 (a) σ = 1 (b) σ = 2 σ σ C = w(k, l) (5.6) k= σ l= σ 5.2 exp math.h math.h -lm # include <stdio. h> 2 # include <stdlib. h> 3 # include <math. h> 4 # include <teo. h> 5 6 static TEOIMAGE* func_ gaussian ( TEOIMAGE * src, int sigma); 7 (a) (b) (c) 5.4 (a) (b) (c)
59 50 5 TEO - 8 static TEOIMAGE* func_ gaussian ( TEOIMAGE * src, int sigma) { 9 TEOIMAGE * dst; 10 double ** gauss; 11 double sum = 0. 0; 12 int kernel_ size, x, y, row, col, p; /* */ 15 dst = TeoAllocImage ( TeoWidth ( src), TeoHeight ( src), 16 TeoXoffset ( src), TeoYoffset ( src), 17 TEO_ UNSIGNED, 8, TeoPlane ( src)); /* */ 20 kernel_ size = sigma * 2 + 1; 21 gauss = ( double **) malloc ( sizeof ( double *) * kernel_ size) + sigma; 22 for ( y = -sigma; y <= sigma; y++) { 23 gauss[ y] = ( double *) malloc ( sizeof ( double) * kernel_ size) + sigma; 24 for ( x = -sigma; x <= sigma; x++) { 25 gauss[ y][ x] = exp ( -(x * x + y * y) / ( 2. 0 * sigma * sigma)); 26 sum += gauss[y][x]; 27 } 28 } 29 /* 1 */ 30 for ( y = -sigma; y <= sigma; y++) { 31 for ( x = -sigma; x <= sigma; x++) { 32 gauss[y][x] /= sum; 33 } 34 } 35 /* */ 36 for ( row = TeoYstart( src) +sigma; row <= TeoYend( src) -sigma; row++) { 37 for ( col = TeoXstart( src) +sigma; col <= TeoXend( src) -sigma; col++) { 38 for ( p = 0; p < TeoPlane ( src); p++) { 39 sum = 0. 0; 40 for ( y = -sigma; y <= sigma; y++) { 41 for ( x = -sigma; x <= sigma; x++) { 42 sum += gauss[ y][ x] * TeoGetPixel ( src, 43 col+x, row+y, p, TEO_ UINT8); 44 } 45 } 46 TeoPutPixel ( dst, col, row, p, TEO_ UINT8, ( TEO_ UINT8) sum); 47 } 48 } 49 } 50 /* */ 51 for ( y = -sigma; y <= sigma; y++) { 52 gauss[ y] -= sigma; 53 free (gauss[y]); 54 } 55 gauss -= sigma; 56 free (gauss); 57
60 return dst; 59 } int main ( int argc, char * argv) { 62 TEOFILE * src_ teofp, * dst_ teofp; 63 TEOIMAGE * srcimg, * dstimg; 64 int sigma; /* */ 67 if (argc!= 3) { 68 fprintf (stderr, "Usage: %s in.teo #sigma\n", argv[0]); 69 exit (1); 70 } 71 /* */ 72 src_teofp = TeoOpenFile (argv[1]); /* T E O */ 73 srcimg = TeoAllocSimilarImage (src_teofp);/* */ 74 TeoReadFrame (src_teofp, srcimg); /* */ /* */ 77 if ( TeoPlane ( src_ teofp) < 3! TeoIsUINT8 ( src_ teofp)) { 78 fprintf ( stderr, " This image trowpe is not supported.\ n"); 79 TeoCloseFile ( src_ teofp); 80 TeoFreeImage ( srcimg); 81 exit (1); 82 } 83 /* */ 84 dst_ teofp = TeoCreateFile (" -", 85 TeoWidth( src_ teofp), TeoHeight( src_ teofp), 86 TeoXoffset( src_ teofp), TeoYoffset( src_ teofp), 87 TEO_UNSIGNED, 8, 3, 1); /* */ 90 sigma = atoi ( argv[ 2]); /* */ 93 dstimg = func_ gaussian ( srcimg, sigma); /* */ 96 TeoWriteFrame ( dst_ teofp, dstimg); /* */ 99 TeoCloseFile ( src_ teofp); 100 TeoCloseFile ( dst_ teofp); /* */ 103 TeoFreeImage ( srcimg); 104 TeoFreeImage ( dstimg); return 0; 107 }
61 52 5 TEO (x, y) (x, y ) x = 2x (5.7) y = 2y (5.8) 5.5 (i, 0), i = 0,, N (2i, 0) (2i + 1, 0) x = x /2 (5.9) y = y /2 (5.10) 5.3 int 5.5
62 # include <stdio. h> 2 # include <stdlib. h> 3 # include <teo. h> 4 5 static TEOIMAGE* 6 TeoScaleImage ( TEOIMAGE * src, 7 TEOIMAGE * dst, 8 double xscale, 9 double yscale) { 10 int row, col, in_row, in_col, p; for ( row = TeoYstart ( dst); row <= TeoYend ( dst); row++) { 13 for ( col = TeoXstart ( dst); col <= TeoXend ( dst); col++) { 14 in_ row = ( int) ( row / yscale); 15 in_ col = ( int) ( col / xscale); 16 for ( p = 0; p < TeoPlane ( dst); p++) { 17 TeoPutPixel ( dst, col, row, p, TEO_ UINT8, 18 TeoGetPixel ( src, in_col, in_row, p, TEO_ UINT8)); 19 } 20 } 21 } 22 } int 25 main ( int argc, 26 char **argv) { 27 TEOFILE *src_teofp; /* T E O */ 28 TEOFILE *dst_teofp; /* T E O */ 29 TEOIMAGE *srcimg; /* T E O */ 30 TEOIMAGE *dstimg; /* T E O */ 31 double xscale, yscale; /* */ /* */ 34 if (argc!= 4) { 35 fprintf (stderr, "Usage: %s in.teo #xscale #yscale\n", argv[0]); 36 exit (1); 37 } /* */ 40 src_teofp = TeoOpenFile (argv[1]); /* T E O */ 41 srcimg = TeoAllocSimilarImage (src_teofp);/* */ 42 TeoReadFrame (src_teofp, srcimg); /* */ /* */ 45 xscale = (double) atof (argv[2]); /* */ 46 yscale = (double) atof (argv[3]); /* */ /* */ 49 dst_ teofp
63 54 5 TEO - 50 = TeoCreateFile (" -", /* */ 51 (int) (TeoWidth (srcimg) * xscale),/* */ 52 (int) (TeoHeight(srcimg) * yscale),/* */ 53 0, 0, /* */ 54 TEO_UNSIGNED, /* */ 55 8, /* B i t */ 56 3, /* */ 57 1); /* */ 58 dstimg = TeoAllocSimilarImage ( dst_ teofp); /* */ 61 TeoScaleImage ( srcimg, dstimg, xscale, yscale); /* */ 64 TeoWriteFrame ( dst_ teofp, dstimg); /* */ 67 TeoCloseFile ( src_ teofp); 68 TeoCloseFile ( dst_ teofp); /* */ 71 TeoFreeImage ( srcimg); 72 TeoFreeImage ( dstimg); return 0; 75 } 5.4? 2 (1, 0) (0.5, 0) (0, 0) (1, 0) (x, y), (x + 1, y) α : 1 α (x, y), (x, y + 1) β : 1 β (5.11) I(x + α, y + β) = (1 β) + β ( ) (1 α)i(x, y) + αi(x + 1, y) ( ) (5.11) (1 α)i(x, y + 1) + αi(x + 1, y + 1) (ˆx, ŷ) (5.11) x, y, α, β floor ˆx ( double)
64 ( x, y ) α 1 α ( x+1, y ) β 1 β ( x, y+1 ) ( x+1, y ( 1 ) math.h floor int x = floor(ˆx) (5.12) y = floor(ŷ) (5.13) α = ˆx x (5.14) β = ŷ y (5.15) 5.4 TEO UINT static TEO_ UINT8 2 TeoGetLinearPixel ( TEOIMAGE * img, 3 double x, 4 double y, 5 int plane) { 6 TEO_ UINT8 pix[ 4]; 7 int ix, iy; 8 double a, b; 9 10 ix = ( int) x; 11 iy = ( int) y;
65 56 5 TEO - 12 a = x - ix; 13 b = y - iy; pix[ 0] = TeoGetPixel ( img, ix, iy, plane, TEO_ UINT8); 16 pix[ 1] = TeoGetPixel ( img, 17 (ix >= TeoXend (img))? ix : ix + 1, 18 iy, 19 plane, TEO_ UINT8); 20 pix[ 2] = TeoGetPixel ( img, 21 ix, 22 (iy >= TeoYend (img))? iy : iy + 1, 23 plane, TEO_ UINT8); 24 pix[ 3] = TeoGetPixel ( img, 25 (ix >= TeoXend (img))? ix : ix + 1, 26 (iy >= TeoYend (img))? iy : iy + 1, 27 plane, TEO_ UINT8); return ( TEO_ UINT8) (( b) * ( a) * pix[ 0] + 30 ( b) * a * pix[ 1] + 31 b * (1.0 - a) * pix[2] + 32 b * a * pix[3]); 33 } static void 36 TeoScaleImage2 ( TEOIMAGE * src, 37 TEOIMAGE * dst, 38 double xscale, 39 double yscale) { 40 int row, col, p; 41 double in_row, in_ col; for ( row = TeoYstart ( dst); row <= TeoYend ( dst); row++) { 44 for ( col = TeoXstart ( dst); col <= TeoXend ( dst); col++) { 45 in_ row = ( double) row / yscale; 46 in_ col = ( double) col / xscale; 47 for ( p = 0; p < TeoPlane ( dst); p++) { 48 TeoPutPixel ( dst, col, row, p, TEO_ UINT8, 49 TeoGetLinearPixel ( src, in_col, in_row, p)); 50 } 51 } 52 } 53 }
66 # define TeoGetLinearPixel( image, index_x, index_y, index_p, ETYPE)\ 2 (((index_x) -((int) (index_x))) * \ 3 (((index_y) -((int) (index_y))) * \ 4 ( double) TeoGetPixel( image, \ 5 (((int) (index_x)) == (teo_xend(image)))? \ 6 ((int) (index_x)) : (((int) (index_x))+1), \ 7 (((int) (index_y)) == (teo_yend(image)))? \ 8 ((int) (index_y)) : (((int) (index_y))+1), \ 9 ( index_ p),etype) + \ 10 (1.0 -((index_y) -((int) (index_y)))) * \ 11 ( double) TeoGetPixel( image, \ 12 (((int) (index_x)) == (teo_xend(image)))? \ 13 ((int) (index_x)) : (((int) (index_x))+1), \ 14 ((int) (index_y)), \ 15 ( index_ p),etype)) + \ 16 (1.0 -((index_x) -((int) (index_x)))) * \ 17 (((index_y) -((int) (index_y))) * \ 18 ( double) TeoGetPixel( image, \ 19 ((int) (index_x)), \ 20 (((int) (index_y)) == (teo_yend(image)))? \ 21 ((int) (index_y)) : (((int) (index_y))+1), \ 22 ( index_ p),etype) + \ 23 (1.0 -((index_y) -((int) (index_y)))) * \ 24 ( double) TeoGetPixel( image, \ 25 ((int) (index_x)),((int) (index_y)), \ 26 (index_p),etype))) (a) (b) 5.7 (a) (b)
67 58 5 TEO () 2 2 (5.16) (5.17) 3 3 Z[ ] 3 1 ( 3 ) x = a 11x + a 12 y + a 13 a 31 x + a 32 y + a 33 y = a 21x + a 22 y + a 23 a 31 x + a 32 y + a 33 (5.16) x y 1 = Z[ a 11 a 12 a 13 a 21 a 22 a 23 a 31 a 32 a 33 x y 1 ] (5.17) 1 2 H 1. H ( 5.8)
68 5.5 例題9 パノラマ画像の生成 59 この際 出力画像の左上の座標が (0, 0) でない場合も生じますが TEO 画像フォーマットではオフセッ ト機能により そのような場合も問題なく扱うことができるので便利です 2. 第 1 画像データを出力画像にコピーします 第 1 画像と出力画像の座標系は一致していますので 第 1 画像上の画素値を出力画像の同一座標に書き 込みます 3. 第 2 画像データを出力画像にコピーします a 出力画像の各点について 射影変換行列 H により第 2 画像での座標を計算します b このとき 計算された座標が第 2 画像の範囲外であれば何もしません c 計算された座標が第 2 画像の範囲内であれば 双 1 次補間によって出力画像の画素値を計算し 書 き込みます モザイク画像生成の例を図 5.9に示します (a) (b) (c) 図 5.9 モザイク画像の生成結果 (a) 入力画像 1 (b) 入力画像 2 (c) モザイク画像
69
70 ,, θ. (x, y), (x, y ), (). { x = x cos θ + y sin θ y = x sin θ + y cos θ (6.1), (x, y ) (x, y)..
71 62 6 { x = x cos θ y sin θ y = x sin θ + y cos θ (6.2), x = cos θ sin θ 0 sin θ cos θ x (6.3) x, x (x, y), (x, y ). x = x y 1, x = x y 1 (6.4) (t x, t y ) x = 1 0 t x 0 1 t y x, x = 1 0 t x 0 1 t y x (6.5) θ x = cos θ sin θ 0 sin θ cos θ x, x = cos θ sin θ 0 sin θ cos θ x (6.6) s x = s s x, x = 1/s /s x (6.7)
72 θ, (t x, t y ) x = cos θ sin θ t x sin θ cos θ t y x, x = cos θ sin θ t x cos θ + t y sin θ sin θ cos θ t x sin θ t y cos θ x (6.8) s, θ, (t x, t y ) x = s cos θ s sin θ t x s sin θ s cos θ t y x, x = 1 s cos θ sin θ t x cos θ + t y sin θ sin θ cos θ t x sin θ t y cos θ 0 0 s x (6.9) x = a 11 a 12 a 13 a 21 a 22 a x, x = a 11 a 12 a 13 a 21 a 22 a x (6.10), {a ij } a 11 a 22 a 21 a (a) (b) (c) (d) (e) (f) 6.1 (a) (b) (c) (d) (e) (f)
73 , ( ) , W (k, l). W (k, l) = W 1 (k)w 2 (l) (6.11) ()., I, Î. Î(x, y) = W 1 (k)i(x + k, y) (6.12) s k s 2. Î, I. I (x, y) = s l s W 2 (l)î(x, y + l) (6.13) W (k, l) = e (k2 +l 2 )/2σ 2. W (k, l) = e (k2 +l 2 )/2σ 2 = W 1 (k)w 2 (l) (6.14) W 1 (k) = e k2 /2σ 2, W 2 (l) = e l2 /2σ 2 (6.15). 1. W (k) = e k2 /2σ 2, s k s. 2. I, Î..
74 Î(x, y) = W (k)i(x + k, y) (6.16) s k s 3. Î, I. I (x, y) = s l s W (l)î(x, y + l) (6.17) 6.3,., I(x, y) (). I = ( Ix I y ) (6.18), I x, I y x, y. I, I. I = I 2 x + I 2 y (6.19)., I ,.,,. 1. I(x, y) w(x, y) x,. I x(x, y) w x (t x, s y)i(t, s)dtds
75 66 6 = w x (t, s )I(x + t, y + s )dt ds (6.20), t = t x, s = s y.. I x(x, y) = 1 w x (k, l)i(x + k, y + l) (6.21) C (k,l) N C,. C = w x (k, l)k (6.22) (k,l) N x, y. w x (x, y) = x σ 2 e (x2 +y 2 )/2σ 2, w y (x, y) = y σ 2 e (x2 +y 2 )/2σ 2 (6.23) x. I x(x, y) = D x (k, l)i(x + k, y + l) (6.24) (k,l) N +l 2 )/2σ 2 D x (k, l) = ke (k2, C = C (k,l) N k 2 e (k2 +l 2 )/2σ 2 (6.25) y. I y(x, y) = D y (k, l)i(x + k, y + l) (6.26) (k,l) N +l 2 )/2σ 2 D y (k, l) = le (k2, C = C (k,l) N l 2 e (k2 +l 2 )/2σ 2 (6.27)
76 I = I xx + I yy (6.28),. I I(x, y), I(x, y), I(x + 1, y), I(x, y + 1), I(x + 1, y + 1) 1, ,,. I(x, y) w(x, y),. I (x, y) = w(t x, s y)i(t, s)dtds w(t, s )I(x + t, y + s )dt ds (6.29), t = t x, s = s y.. I (x, y) = 1 w(k, l)i(x + k, y + l) (6.30) C (k,l) N C,. C = 1 4 w(k, l)i(k 2 + l 2 ) (6.31) (k,l) N 2,. w(x, y) = 2 ( σ 2 1 x2 + y 2 ) 2σ 2 e (x2 +y 2 )/2σ 2 (6.32). G(k, l) = 1 C (1 x2 + y 2 2σ 2 I (x, y) = (k,l) N ) e (x2 +y 2 )/2σ 2, C = 1 4 G(k, l)i(x + k, y + l) (6.33) (k,l) N (k 2 + l 2 ) (1 k2 + l 2 ) 2σ 2 e (k2 +l 2 )/2σ 2 (6.34)
77 CG,., A : (x A, y A ), B : (x B, y B ), C : (x C, y C ), (x, y). 6.2 α, β, γ. ( x y ) ( xa = α y A ) ( xb + β y B ) ( xc + γ y C ), α + β + γ = 1 (6.35) (6.35). x A x B x C y A y B y C α β γ = x y 1 (6.36), (x, y) (α, β, γ). D = α = 1 D β = 1 D γ = 1 D x x B x C y y B y C x A x x C y A y y C x A x B x y B y B y x A x B x C y B y B y C = (y B y C )x (x B x C )y + (x B y C y B x C ) D = (y C y A )x (x C x A )y + (x C y A y C x A ) D = (y A y B )x (x A x B )y + (x A y B y A x B ) D (6.37) (6.38) (6.39) = (x By C y B x C ) + (x C y A y C x A ) + (x A y B y A x B ) (6.40) ABC A B C. 1. A B C.
78 β = 0 α > 0 β < 0 γ < 0 γ = 0 α > 0 A β > 0 γ < 0 α > 0 β < 0 α > 0 γ > 0 β > 0 α = 0 B γ > 0 α < 0 C β > 0 γ < 0 α < 0 α < 0 β > 0 β < 0 γ > 0 γ > x min x x max, y min y y max (6.41) 2.. a 11 = y B y C, a 12 = x B x C, a 13 = x B y C y B x C a 21 = y C y A, a 22 = x C x A, a 23 = x C y A y C x A (6.42) D = a 11 + a 23 + x A y B y A x B (6.43) 3. (x min, y min ) (x max, y max ) (x, y),. a (x, y) (α, β, γ). α = a 11x a 12 y + a 13 D, β = a 21x a 22 y + a 23, γ = 1 α β (6.44) D b α 0, β 0, γ 0 ABC (x, y ) (6.35). c (x, y ) (x, y).
79 ( ) ( ) ( ) σw 2 σ2 B σw 2 /σ2 B M N L 1. L w(l), l = 0,..., L l w(l) w(l) l = 0 w(l) w(l) > 0 l l min 4. l = L 1 w(l) w(l) > 0 l l max l = l min 1 (6.45) n 1 = 0, n 2 = MN (6.46) s 1 = 0.0, s 2 = t 1 = 0.0, t 2 = l max i=l min i w(i) (6.47) l max i=l min i i w(i) (6.48) λ = 0.0 (6.49) 1. l = l max l 2. w(l) = 0 l l l l + 1 (6.50) z = w(l), z = w(l) l, z = w(l) l l (6.51) n 1 n 1 + z, s 1 s 1 + z, t 1 t 1 + z (6.52)
80 n 2 n 2 z, s 2 s 2 z, t 2 t 2 z (6.53) 4. 2 µ 1, µ 2 σ 1, σ 2 µ 1 = s 1 n 1, σ 2 1 = t 1 n 1 µ 2 1, µ 2 = s 2 n 2, σ 2 2 = t 2 n 2 µ 2 2 (6.54) 5. σ 2 B σ2 W σ 2 B = n 1 n 2 (µ 1 µ 2 ) 2, σ 2 W = n 1 σ n 2 σ 2 2 (6.55) 6. λ = σ2 B σ 2 W (6.56) 7. λ < λ l λ λ (a) (b)
81
82 73 A libteo A.1 TEOFILE* TeoOpenFile (char *filename); filename : TEO TEO - PNM TEO TEOFILE NULL int TeoCloseFile (TEOFILE *teofp); teofp : TEOFILE TEOFILE TEOFILE 1 0
83 74 A libteo TEOFILE* TeoCreateFile (char *filename, int width, int height, int xoffset, int yoffset, int type, int bit, int plane, int frame); filename : width : height : xoffset : X yoffset : Y type : bit : plane : frame : TEO - TEOFILE TEOFILE NULL TeoCreateFileWithUserExtension TEOFILE* TeoCreateSimilarFile (char *filename, TEOFILE *teofp); filename : teofp : TEOFILE TEOFILE teofp TEO - TEOFILE TEOFILE NULL
84 A.1 75 TEOFILE* TeoCreateFileWithUserExtension (char *filename, int width, int height, int xoffset, int yoffset, int type, int bit, int plane, int frame, int extc, char **extv); filename : width : height : xoffset : X yoffset : Y type : bit : plane : frame : extc : extv : TEO - extc extv extc TEOFILE TEOFILE NULL TeoCreateFile TeoGetUserExtension
85 76 A libteo A.2 TEOIMAGE* TeoAllocImage (int int int int int int int width, height, xoffset, yoffset, type, bit, plane); width : height : xoffset : X yoffset : Y type : bit : plane : NULL TEOIMAGE* TeoAllocSimilarImage (TEOFILE *teofp); teofp : TEOFILE TEOFILE teofp NULL
86 A.2 77 TEOIMAGE* TeoAllocSimilarImage (TEOIMAGE *teoimg); teoimg : TEOIMAGE TEOIMAGE teoimg NULL int TeoFreeImage (TEOIMAGE *teoimg); teoimg : TEOIMAGE TEOIMAGE 1 0 int TeoReadFrame (TEOFILE *teofp, TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE 1 TEOIMAGE 1 0
87 78 A libteo int TeoWriteFrame (TEOFILE *teofp, TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE int TeoSetAbsFrame (TEOFILE *teofp, int frame); teofp : TEOFILE frame : TeoSetRelFrame int TeoSetRelFrame (TEOFILE *teofp, int frame); teofp : TEOFILE frame : TeoSetAbsFrame
88 A.3 79 int TeoCheckFrame (TEOFILE *teofp); teofp : TEOFILE ( 0 ) (0) A.3 ETYPE TeoGetPixel (TEOIMAGE *teoimg, int x, int y, int plane, ETYPE); teoimg : TEOIMAGE x : x y : y plane : ETYPE : (x, y) plane ETYPE teoimg 0 (x, y) plane
89 80 A libteo void TeoPutPixel (TEOIMAGE *teoimg, int x, int y, int plane, ETYPE, ETYPE val); teoimg : TEOIMAGE x : x y : y plane : ETYPE : val : (x, y) plane val ETYPE teoimg 0 (void) TEO_BIT TeoGetBit (TEOIMAGE *teoimg, int x, int y, int plane); teoimg : TEOIMAGE x : x y : y plane : 2 (TEO BIT ) (x, y) plane 0 (x, y) plane (0 or 1)
90 A.4 81 void TeoPutBit (TEOIMAGE *teoimg, int x, int y, int plane, TEO BIT val); teoimg : TEOIMAGE x : x y : y plane : val : 2 (TEO BIT ) (x, y) plane val 0 (void) A.4 int TeoWidth (TEOFILE *teofp); int TeoWidth (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE int TeoHeight (TEOFILE *teofp); int TeoHeight (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE
91 82 A libteo int TeoType (TEOFILE *teofp); int TeoType (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE (TEO SIGNED, TEO UNSIGNED, TEO FLOAT) int TeoBit (TEOFILE *teofp); int TeoBit (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE int TeoPlane (TEOFILE *teofp); int TeoPlane (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE int TeoFsize (TEOFILE *teofp); int TeoFsize (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE ( )
92 A.4 83 int TeoXoffset (TEOFILE *teofp); int TeoXoffset (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE X int TeoYoffset (TEOFILE *teofp); int TeoYoffset (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE Y int TeoXstart (TEOFILE *teofp); int TeoXstart (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE X int TeoYstart (TEOFILE *teofp); int TeoYstart (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE Y
93 84 A libteo int TeoXend (TEOFILE *teofp); int TeoXend (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE X int TeoYend (TEOFILE *teofp); int TeoYend (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE Y int TeoIsBIT (TEOFILE *teofp); int TeoIsBIT (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO BIT ( 0 ) (0) int TeoIsUINT8 (TEOFILE *teofp); int TeoIsUINT8 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO UINT8 ( 0 ) (0)
94 A.4 85 int TeoIsSINT8 (TEOFILE *teofp); int TeoIsSINT8 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO SINT8 ( 0 ) (0) int TeoIsUINT16 (TEOFILE *teofp); int TeoIsUINT16 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO UINT16 ( 0 ) (0) int TeoIsSINT16 (TEOFILE *teofp); int TeoIsSINT16 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO SINT16 ( 0 ) (0) int TeoIsUINT32 (TEOFILE *teofp); int TeoIsUINT32 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO UINT32 ( 0 ) (0)
95 86 A libteo int TeoIsSINT32 (TEOFILE *teofp); int TeoIsSINT32 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO SINT32 ( 0 ) (0) int TeoIsFLOAT32 (TEOFILE *teofp); int TeoIsFLOAT32 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO FLOAT32 ( 0 ) (0) int TeoIsFLOAT64 (TEOFILE *teofp); int TeoIsFLOAT64 (TEOIMAGE *teoimg); teofp : TEOFILE teoimg : TEOIMAGE TEO FLOAT64 ( 0 ) (0) int TeoFrame (TEOFILE *teofp); teofp : TEOFILE
96 A.4 87 int TeoHsize (TEOFILE *teofp); teofp : TEOFILE FILE* TeoFp (TEOFILE *teofp); teofp : TEOFILE TEO int TeoExtc (TEOFILE *teofp); teofp : TEOFILE char** TeoExtv (TEOFILE *teofp); teofp : TEOFILE char* TeoGetUserExtension (TEOFILE *teofp, char *key); teofp : TEOFILE key :
97 88 A libteo int TeoCurrent (TEOFILE *teofp); teofp : TEOFILE void* TeoData (TEOIMAGE *teoimg); teoimg : TEOIMAGE
98 89 B TEO B.1 pnm2teo pnm2teo [input.pnm]... input.pnm : PNM ( ) PNM TEO TEO % cat input.ppm pnm2teo > output.teo % pnm2teo input1.ppm input2.ppm > output.teo
99 90 B TEO B.2 teo2pnm teo2pnm #frame number [input.teo] frame number : input.teo : TEO ( ) TEO PNM % cat input.teo teo2pnm 0 > output.ppm % teo2pnm 0 input.teo > output.ppm B.3 teo2avi teo2avi [-c code][-q quality][-s start end step][-r frame rate] input.teo output.avi input.teo : TEO output.avi : AVI -c codec : -q quality : (0 100) -s start end step : -r frame rate : ( 30[fps]) TEO AVI -s ( ) % teo2avi input.teo output.avi % teo2avi input%02d.teo output.avi -s
100 B.4 teogzip 91 B.4 teogzip teogzip [-d] input.teo input.teo : TEO -d : TEO -d TEO % teogzip uncompressed.teo % teogzip -d compressed.teo B.5 teo get extension teo get extension input.teo [keyword] input.teo : TEO keyword : ( ) TEO % teo get extension has extension.teo HasAlpha YES % teo get extension has extension.teo HasAlpha YES
101 92 B TEO B.6 teocast teocast pixel-type bits [input.teo] pixel-type : (U, S, F ) bits : (1, 8, 16, 32, 64 ) input.teo : ( ) % teocast U 8 FLOAT64.teo > UINT8.teo % cat FLOAT64.teo teocast U 8 > UINT8.teo B.7 teodiff teodiff [-s -l1 -l2 -c] [-abs] input1.teo input2.teo input1.teo : TEO 1 input2.teo : TEO 2 -s : -l1 : L1 -l2 : L2 -c : -abs : 2 TEO FLOAT64 % teodiff input.teo background.teo > diff.teo
102 B.8 teorange 93 B.8 teorange teorange srcmin srcmax destmin destmax [input.teo] srcmin : srcmax : destmin : destmax : input.teo : TEO ( ) [srcmin:srcmax] [destmin:destmax] TEO FLOAT64 % teorange input.teo > output.teo % cat input.teo teorange > output.teo
103
104 95 C TEO TeoEyes TeoEyes TEO TEO TEO TEO TeoEyes C.1 TeoEyes C.2 ( C.3) C.1 TeoEyes
105 96 C TEO TeoEyes C.2 C.3
106 97 D TEO TEO libteo D.1 libteopp libteopp libteo TEOFILE TEOIMAGE C++ TEO D.2 ruby-teo ruby-teo libteo ruby Ruby D.3 libteo2ipl libteo2ipl TEO OpenCV OpenCV OpenCV D.4 libteo+ libteo+ libteo libteo+ 1
107 98 D TEO XY XY X Y XY TeoOpenXYFile, TeoCreateXYFile libteo XY TEO D.5 libteo draw libteo draw TEO libteo draw... TeoDrawPoint... TeoDrawLine... TeoDrawLines... TeoDrawSegments... TeoDrawRectangle... TeoDrawConvex... TeoDrawArc... TeoDrawEllipse 2... TeoDrawConic libteo draw D.1 D.6 libteo2gdk-pixbuf libteo2gdk-pixbuf TEO GdkPixbuf GdkPixbuf GTK+ GTK+ GUI
108 D.6 libteo2gdk-pixbuf 99 (a) 線分 矩形の描画 (b) 円の描画 図 D.1 (c) 楕円の描画 libteo draw を用いた図形の描画 にたちます TEO 画像データから GdkPixbuf 形式に変換するだけではなく 反対に GdkPixbuf 形式から TEOIMAGE 形式への変換も行うことができます これにより gdk-pixbuf 関数により読み込んだ JPEG, PNG 等の画像 データを TEO 画像データに変換することが可能になります 図 D.2 libteo2gdk-pixbuf を利用した GUI ツール (ggetpixel)
109
110 101 E MMX MMX MMX *1 MMX MMX MMX MMX 1/8 MMX E.1 E.1(a) ( E.1(b)) MMX E.1 E.1 MMX MMX paddw mm1, mm0 mm0 F000h a2 a1 a mm1 3000h b2 b1 b0 paddusw mm1, mm0 mm0 F000h a2 a1 a mm1 3000h b2 b1 b0 mm0 2000h a2+b2 a1+b1 a0+b0 mm0 FFFFh a2+b2 a1+b1 a0+b0 E.1 (a) (b) MMX (a) (b) *1 MMX MMX
111 102 E MMX C C C MMX E.1 MMX E.2 MMX (12 ) MMX 8 (14 16 ) (18 31 ) 1 8 n (?) 8 1 (19 ) src ptr1 MMX mm0 *2 asm ( operand source, destination ); or asm ( operand source ); src ptr1 64 mm0 asm ( operand (%0), destination :: *3 ()); MMX mm0 mm7 8 1 (20 ) src ptr2 MMX mm1 (21 ) 1(22 ) mm0 mm2 mm0 mm1 mm0 psubusb 0 (23 ) mm1 mm2 mm1 (24 ) mm0, mm1 or mm0 1 2 (25 ) 0FFh 0 mm0 (26 ) mm2( 2 ) AND 2 0 *2 *3
112 103 (27 ) MMX asm ( operand source, (%0) :: ()); (28 30 ) 8 (32 ) MMX E.1 MMX 1 # include <stdio. h> 2 # include <stdlib. h> 3 # include <teo. h> 4 5 static void 6 func_ subtract_ mmx ( unsigned char * src1, 7 unsigned char * src2, 8 unsigned char * dst, 9 int size) { 10 int n; 11 unsigned char * src_ ptr1, * src_ ptr2, * dst_ ptr; 12 unsigned char threshold[ 8] = {16, 16, 16, 16, 16, 16, 16, 16}; src_ ptr1 = src1; 15 src_ ptr2 = src2; 16 dst_ ptr = dst; for ( n = size; n > 0; n -= 8) { 19 asm ("movq (%0), %%mm0"::"r"(src_ptr1)); 20 asm ("movq (%0), %%mm1"::"r"(src_ptr2)); 21 asm ("movq %mm0, %mm2"); 22 asm ("psubusb %mm1, %mm0"); 23 asm ("psubusb %mm2, %mm1"); 24 asm ("por %mm1, %mm0"); 25 asm ("pcmpgtb (%0), %%mm0"::"r"(threshold)); 26 asm ("pand %mm2, %mm0"); 27 asm ("movq %%mm0, (%0)"::"r"(dst_ptr)); 28 src_ ptr1 += 8; 29 src_ ptr2 += 8; 30 dst_ ptr += 8; 31 } 32 asm ("emms"); 33 } int 36 main ( int argc, 37 char **argv) { 38 TEOFILE * src_ teofp[2], * dst_ teofp; 39 TEOIMAGE * src_ img[2], * dst_ img; 40 int n; /* */
113 104 E MMX 43 for ( n = 0; n < 2; n++) { 44 src_ teofp[ n] = TeoOpenFile ( argv[ n+1]); 45 src_ img[ n] = TeoAllocSimilarImage ( src_ teofp[ n]); 46 TeoReadFrame (src_teofp[n], src_img[n]); 47 } 48 /* */ 49 dst_ teofp = TeoCreateSimilarFile (" -", src_ teofp[ 0]); 50 dst_ img = TeoAllocSimilarImage ( dst_ teofp); /* */ 53 func_ subtract_ mmx (( unsigned char *) TeoData ( src_ img[ 1]), 54 ( unsigned char *) TeoData ( src_ img[ 0]), 55 ( unsigned char *) TeoData ( dst_ img), 56 TeoFsize (src_teofp[0])); TeoWriteFrame ( dst_ teofp, dst_ img); 59 TeoCloseFile ( src_ teofp[ 0]); 60 TeoCloseFile ( src_ teofp[ 1]); 61 TeoCloseFile ( dst_ teofp); 62 TeoFreeImage ( src_ img[ 0]); 63 TeoFreeImage ( src_ img[ 1]); 64 TeoFreeImage ( dst_ img); return 0; 67 }
114 105 movq (src_ptr1)... (3) movq (src_ptr1)... (4) mm (5) mm psubusb... (6) psubusb... (7) mm mm mm mm por... (8) mm pcmpgtb... (9) threshold mm pand... (10) mm mm movq (dst_ptr)... (11) E.2 MMX E.3 (a) (b) (c) MMX (a) (b) (c)
double float
2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................
More informationC
C 1 2 1.1........................... 2 1.2........................ 2 1.3 make................................................ 3 1.4....................................... 5 1.4.1 strip................................................
More information1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou
1 1.1 C 2 1 double a[ ][ ]; 1 3x3 0 1 3x3 ( ) 0.240 0.143 0.339 0.191 0.341 0.477 0.412 0.003 0.921 1.2 malloc() 2 double *a[ ]; double 1 malloc() double 1 malloc() free() 3 #include #include
More information1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include
1 1.1 C 2 1 double a[ ][ ]; 1 3x3 0 1 3x3 ( ) 0.240 0.143 0.339 0.191 0.341 0.477 0.412 0.003 0.921 1.2 malloc() malloc 2 #include #include #include enum LENGTH = 10 ; int
More informationA/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B
A/B (2018/10/19) Ver. 1.0 kurino@math.cst.nihon-u.ac.jp http://edu-gw2.math.cst.nihon-u.ac.jp/ kurino/2018/soft/soft.html 2018 10 19 A/B 1 2018 10 19 2 1 1 1.1 OHP.................................... 1
More informationmstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )
2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test
More informationmemo
数理情報工学演習第一 C プログラミング演習 ( 第 5 回 ) 2015/05/11 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : プロトタイプ宣言 ヘッダーファイル, プログラムの分割 課題 : 疎行列 2 プロトタイプ宣言 3 C 言語では, 関数や変数は使用する前 ( ソースの上のほう ) に定義されている必要がある. double sub(int
More information‚æ4›ñ
( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9
More informationCM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)
CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) ( 第 1 版 ) Copyright (C)2016 株式会社コンピューテックス 目次 1. はじめに... 1 2. MS5607 について... 1 3. 接続図... 1 4. アプリケーション ソース... 2 5. アプリケーションのコンパイル方法... 7 6. アプリケーションの実行... 8 1. はじめに
More informationuntitled
II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}
More informationC 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in
C 1 / 21 C 2005 A * 1 2 1.1......................................... 2 1.2 *.......................................... 3 2 4 2.1.............................................. 4 2.2..............................................
More informationOriginal : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n
2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test
More informationAppendix
Appendix Appendix-A PHP 392 Appendix-B -> cd ext/pgsql -> phpize ->./configure --with-pgsql -> make -> make EXTENSION_DIR=/usr/local/lib/php/extensions install extension_dir = "/usr/local/lib/php/extensions/"
More informationARM gcc Kunihiko IMAI 2009 1 11 ARM gcc 1 2 2 2 3 3 4 3 4.1................................. 3 4.2............................................ 4 4.3........................................
More information( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1
() 2006 2 27 1 10 23 () 30 () 27 [1] p.97252 7 2 2.1 2.1.1 1 LIFO(last in first out, ) (push) (pup) 1 1: 2.1.2 1 List 4-1(p.100) stack[] stack top 1 2 (push) (pop) 1 2 void stack push(double val) val stack
More information[user@linux tmp]$ tar xzvf utvpn-src-unix-v100-7092-beta-2010.06.25.tar.gz [user@linux tmp]$ cd utvpn-unix-v100-7092-beta [user@linux utvpn-unix-v100-7092-beta]$ ls License-ja.txt configure makefiles src
More informationMicrosoft Word - C.....u.K...doc
C uwêííôöðöõ Ð C ÔÖÐÖÕ ÐÊÉÌÊ C ÔÖÐÖÕÊ C ÔÖÐÖÕÊ Ç Ê Æ ~ if eíè ~ for ÒÑÒ ÌÆÊÉÉÊ ~ switch ÉeÍÈ ~ while ÒÑÒ ÊÍÍÔÖÐÖÕÊ ~ 1 C ÔÖÐÖÕ ÐÊÉÌÊ uê~ ÏÒÏÑ Ð ÓÏÖ CUI Ô ÑÊ ÏÒÏÑ ÔÖÐÖÕÎ d ÈÍÉÇÊ ÆÒ Ö ÒÐÑÒ ÊÔÎÏÖÎ d ÉÇÍÊ
More informationII 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y
II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C 1 6 9 1 main main 1 NULL NULL 1 15 23 25 48 26 30 32 36 38 43 45 47 50 52 for 2 (a) 2 2 1 Yacc 2 (b) 2 3 yytext tmp2 ("") tmp2->next->word tmp2 yytext tmp2->next->word
More information2004 2005 2 2 1G01P038-0 1 2 1.1.............................. 2 1.2......................... 2 1.3......................... 3 2 4 2.1............................ 4 2.2....................... 4 2.3.......................
More informationlexex.dvi
(2018, c ) http://istksckwanseiacjp/ ishiura/cpl/ 4 41 1 mini-c lexc,, 2 testlexc, lexc mini-c 1 ( ) mini-c ( ) (int, char, if, else, while, return 6 ) ( ) (+, -, *, /, %, &, =, ==,!=, >, >=,
More informationCプログラミング1(再) 第2回
C プログラミング 1( 再 ) 第 2 回 講義では Cプログラミングの基本を学び演習では やや実践的なプログラミングを通して学ぶ 1 前回のレポートから 前回の宿題 数あてゲーム の説明において 次のように書いていたものがいた : これはコンピュータがランダムに設定した数字を人間が当てるゲームである この説明でどこかおかしなところはないだろうか? 2 コンピュータの用語と日常的な用語の違い 物理において
More informationCondition DAQ condition condition 2 3 XML key value
Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................
More information1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l
C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................
More informationI 2 tutimura/ I 2 p.1/??
I 2 tutimura@mist.i.u-tokyo.ac.jp http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/ 2002 4 25 I 2 p.1/?? / / Makefile I 2 p.2/?? Makefile make GNU make I 2 p.3/?? Makefile L A T E X I 2 p.4/?? core (1) gcc,
More informationXMPによる並列化実装2
2 3 C Fortran Exercise 1 Exercise 2 Serial init.c init.f90 XMP xmp_init.c xmp_init.f90 Serial laplace.c laplace.f90 XMP xmp_laplace.c xmp_laplace.f90 #include int a[10]; program init integer
More informationC による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.
C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/009383 このサンプルページの内容は, 新装版 1 刷発行時のものです. i 2 22 2 13 ( ) 2 (1) ANSI (2) 2 (3) Web http://www.morikita.co.jp/books/mid/009383
More information3.2 Linux root vi(vim) vi emacs emacs 4 Linux Kernel Linux Git 4.1 Git Git Linux Linux Linus Fedora root yum install global(debian Ubuntu apt-get inst
1 OS Linux OS OS Linux Kernel 900 1000 IPA( :http://www.ipa.go.jp/) 8 12 ( ) 16 ( ) 4 5 22 60 2 3 6 Linux Linux 2 LKML 3 3.1 Linux Fedora 13 Ubuntu Fedora CentOS 3.2 Linux root vi(vim) vi emacs emacs 4
More information02: 変数と標準入出力
C プログラミング入門 基幹 7 ( 水 5) 10: ファイル入出力 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/ teachers/w483692/cpr1/ 2016-06-15 1 標準ライブラリ関数によりファイルの出力を行う 画像ファイルの生成を例題として 配列の作成を復習する 今日の内容 関数を作ってプログラムを構造化する
More informationInformatics 2014
C 計算機の歴史 手回し計算機 新旧のソロバン バベッジの階差機関 スパコン ENIAC (1946) パソコン 大型汎用計算機 電卓 現在のコンピュータ Input Output Device Central Processing Unit I/O CPU Memory OS (Operating System) OS Windows 78, Vista, XP Windows Mac OS X
More information新版明解C言語 実践編
2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,
More information9 8 7 (x-1.0)*(x-1.0) *(x-1.0) (a) f(a) (b) f(a) Figure 1: f(a) a =1.0 (1) a 1.0 f(1.0)
E-mail: takio-kurita@aist.go.jp 1 ( ) CPU ( ) 2 1. a f(a) =(a 1.0) 2 (1) a ( ) 1(a) f(a) a (1) a f(a) a =2(a 1.0) (2) 2 0 a f(a) a =2(a 1.0) = 0 (3) 1 9 8 7 (x-1.0)*(x-1.0) 6 4 2.0*(x-1.0) 6 2 5 4 0 3-2
More informationコンピュータ概論
4.1 For Check Point 1. For 2. 4.1.1 For (For) For = To Step (Next) 4.1.1 Next 4.1.1 4.1.2 1 i 10 For Next Cells(i,1) Cells(1, 1) Cells(2, 1) Cells(10, 1) 4.1.2 50 1. 2 1 10 3. 0 360 10 sin() 4.1.2 For
More informationI J
I 065763J 8 7 7 31 jikken/ +----- accumulation_demupa.c +----- accumulation_rain.c +----- frequency_demupa.c +----- frequency_rain.c +----- go.sh +----- graph_maker.sh +----- mesure-ryudai/ 2007/4/1 2007/6/30
More information[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:
005 9 7 1 1.1 1 Hello World!! 5 p r i n t f ( H e l l o World!! \ n ) ; 7 return 0 ; 8 } 1: 1 [ ] Hello World!! from Akita National College of Technology. 1 : 5 p r i n t f ( H e l l o World!! \ n ) ;
More informationpptx
iphone 2010 8 18 C xkozima@myu.ac.jp C Hello, World! Hello World hello.c! printf( Hello, World!\n );! os> ls! hello.c! os> cc hello.c o hello! os> ls! hello!!hello.c! os>./hello! Hello, World!! os>! os>
More informationMinimum C Minimum C Minimum C BNF T okenseq W hite Any D
6 2019 5 14 6.1 Minimum C....................... 6 1 6.2....................................... 6 7 6.1 Minimum C Minimum C BNF T okenseq W hite Any Digit ::= 0 1 2... 9. Number ::= Digit Digit. Alphabet
More information1.3 2 gnuplot> set samples gnuplot> plot sin(x) sin gnuplot> plot [0:6.28] [-1.5:1.5] sin(x) gnuplot> plot [-6.28:6.28] [-1.5:1.5] sin(x),co
gnuplot 8 gnuplot 1 1.1 gnuplot gnuplot 2D 3D gnuplot ( ) gnuplot UNIX Windows Machintosh Excel gnuplot C 1.2 web gnuplot $ gnuplot gnuplot gnuplot> exit 1 1.3 2 gnuplot> set samples 1024 1024 gnuplot>
More informationmain.dvi
A PostScript y 1997 1 Silicon Graphics i-station ( vhsgi) 1 i-station LaserMaster DisplayMaker-J DisplayMaker-J A dpi( ) PostScript 2 PostScript DisplayMaker-J i-station i-station ( AVS) PostScript i-station
More information橡Pro PDF
1 void main( ) char c; /* int c; */ int sum=0; while ((c = getchar())!= EOF) if(isdigit(c) ) sum += (c-'0'); printf("%d\n", sum); main()int i,sum=0; for(i=0;i
More informationslide5.pptx
ソフトウェア工学入門 第 5 回コマンド作成 1 head コマンド作成 1 早速ですが 次のプログラムを head.c という名前で作成してください #include #include static void do_head(file *f, long nlines); int main(int argc, char *argv[]) { if (argc!=
More informationprogrammingII2019-v01
II 2019 2Q A 6/11 6/18 6/25 7/2 7/9 7/16 7/23 B 6/12 6/19 6/24 7/3 7/10 7/17 7/24 x = 0 dv(t) dt = g Z t2 t 1 dv(t) dt dt = Z t2 t 1 gdt g v(t 2 ) = v(t 1 ) + g(t 2 t 1 ) v v(t) x g(t 2 t 1 ) t 1 t 2
More information知能科学:ニューラルネットワーク
2 3 4 (Neural Network) (Deep Learning) (Deep Learning) ( x x = ax + b x x x ? x x x w σ b = σ(wx + b) x w b w b .2.8.6 σ(x) = + e x.4.2 -.2 - -5 5 x w x2 w2 σ x3 w3 b = σ(w x + w 2 x 2 + w 3 x 3 + b) x,
More information知能科学:ニューラルネットワーク
2 3 4 (Neural Network) (Deep Learning) (Deep Learning) ( x x = ax + b x x x ? x x x w σ b = σ(wx + b) x w b w b .2.8.6 σ(x) = + e x.4.2 -.2 - -5 5 x w x2 w2 σ x3 w3 b = σ(w x + w 2 x 2 + w 3 x 3 + b) x,
More information(2 Linux Mozilla [ ] [ ] [ ] [ ] URL 2 qkc, nkc ~/.cshrc (emacs 2 set path=($path /usr/meiji/pub/linux/bin tcsh b
II 5 (1 2005 5 26 http://www.math.meiji.ac.jp/~mk/syori2-2005/ UNIX (Linux Linux 1 : 2005 http://www.math.meiji.ac.jp/~mk/syori2-2005/jouhousyori2-2005-00/node2. html ( (Linux 1 2 ( ( http://www.meiji.ac.jp/mind/tool/internet-license/
More informationOpenCV IS Report No Report Medical Information System Labratry
OpenCV 2014 8 25 IS Report No. 2014090201 Report Medical Information System Labratry Abstract OpenCV OpenCV 1............................ 2 1.1 OpenCV.......................... 2 1.2......................
More information2008 DS T050049
DS T050049. PSP DS DS DS RPG DS OS Windows XP DevkiPro OS DS CPU ARM devkitarm MSYS MinGW MSYS MinGW Unix OS C++ C++ make nds nds DS DS micro SD Card nds DS DS DS nds C Java C++ nds nds DS 2008 DS T050049
More information新・明解C言語 ポインタ完全攻略
2 1-1 1-1 /* 1-1 */ 1 int n = 100; int *p = &n; printf(" n %d\n", n); /* n int */ printf("*&n %d\n", *&n); /* *&n int */ printf(" p %p\n", p); /* p int * */ printf("&*p %p\n", &*p); /* &*p int * */ printf("sizeof(n)
More information計算機プログラミング
プログラミング言語 C 第 8 講 システム標準関数 ( 入出力関数 ) システム標準関数 システムに備え付けの関数 例 ) printf( ); scanf( ); 標準出力関数 標準入力関数 A. 入出力用の関数 高水準入出力関数 高水準言語 (OS に依存しない ) 低水準入出力関数 機械語レベル (OS に依存 ) B. それ以外の関数 引数と関数の型 ( 戻り値 ) に注目しましょう 例
More informationInformatics 2010.key
http://math.sci.hiroshima-u.ac.jp/ ~ryo/lectures/informatics2010/ 1 2 C ATM etc. etc. (Personal Computer) 3 4 Input Output Device Central Processing Unit I/O CPU Memory 5 6 (CPU),,... etc. C, Java, Fortran...
More information02: 変数と標準入出力
C プログラミング入門 基幹 7 ( 水 5) 1 10: ファイル入出力 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/teachers/w48369 2/CPR1/ 2016-06-15 今日の内容 2 標準ライブラリ関数によりファイルの出力を行う画像ファイルの生成を例題として 配列の作成を復習する 文字列の扱いを復習する
More informationMicrosoft PowerPoint - Lec04 [互換モード]
画像情報処理論及び演習 I 第 4 回講義水曜日 1 限教室 6218 情報処理実習室 情報デザイン専攻 - デジタル画像の表現と応用 - 画像処理プログラミングの基礎 吉澤信 shin@riken.jp, 非常勤講師 大妻女子大学社会情報学部 今日の授業内容 1 レポートについて. 2 www.riken.jp/brict/yoshizawa/lectures/index.html www.riken.jp/brict/yoshizawa/lectures/lec04.pdf
More information第5回お試しアカウント付き並列プログラミング講習会
qstat -l ID (qstat -f) qscript ID BATCH REQUEST: 253443.batch1 Name: test.sh Owner: uid=32637, gid=30123 Priority: 63 State: 1(RUNNING) Created at: Tue Jun 30 05:36:24 2009 Started at: Tue Jun 30 05:36:27
More information1.... 1 2.... 1 2.1. RATS... 1 2.1.1. expat... 1 2.1.2. expat... 1 2.1.3. expat... 2 2.2. RATS... 2 2.2.1. RATS... 2 2.2.2.... 3 3. RATS... 4 3.1.... 4 3.2.... 4 3.3.... 6 3.3.1.... 6 3.3.2.... 6 3.3.3....
More informationLinuxデバイスドライバ.PDF
Linux hidaka@devdrv.com 2002/10/9 Linux Kernel Conference 2002 1 Linux 2 Linux 3 Software Hardware Device Algolith m Protocol Applicati on 4 CPU 128MB NIC ATI Radeon GeForce2 MX400 Matrox G400 DISK 5 OS
More information/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }
C 2: A Pedestrian Approach to the C Programming Language 2 2-1 2.1........................... 2-1 2.1.1.............................. 2-1 2.1.2......... 2-4 2.1.3..................................... 2-6
More information卒 業 研 究 報 告.PDF
C 13 2 9 1 1-1. 1-2. 2 2-1. 2-2. 2-3. 2-4. 3 3-1. 3-2. 3-3. 3-4. 3-5. 3-5-1. 3-5-2. 3-6. 3-6-1. 3-6-2. 4 5 6 7-1 - 1 1 1-1. 1-2. ++ Lisp Pascal Java Purl HTML Windows - 2-2 2 2-1. 1972 D.M. (Dennis M Ritchie)
More informationDOPRI5.dvi
ODE DOPRI5 ( ) 16 3 31 Runge Kutta Dormand Prince 5(4) [1, pp. 178 179] DOPRI5 http://www.unige.ch/math/folks/hairer/software.html Fortran C C++ [3, pp.51 56] DOPRI5 C cprog.tar % tar xvf cprog.tar cprog/
More information/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v
1 http://www7.bpe.es.osaka-u.ac.jp/~kota/classes/jse.html kota@fbs.osaka-u.ac.jp /* do-while */ #include #include int main(void) double val1, val2, arith_mean, geo_mean; printf( \n );
More informationr08.dvi
19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev
More informationprogram.dvi
2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation
More informationt 2 2 t 2 t F ( ) p- 2 2 F 2 G F ( ) 2 2 F 2 G F ( ) 2 2 2
1 2 2 0 1 2 2 2 2 2 2 2 2.1 2 2 F={f ij }, G {g ij } t f ij t g ij = 1 f ij < t g ij = 0 t p- p S 0 S p = S 0 /S t p 2 t 1 t 2 2 t 2 t 2 2 3 3 1 2 F ( ) p- 2 2 F 2 G 3 2 2 F ( ) 2 2 F 2 G 3 3 2 F ( ) 2
More informationdebug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology
I117 28 School of Information Science, Japan Advanced Institute of Science and Technology debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology 2008 1-2 1 a) b)
More informationv v = v 1 v 2 v 3 (1) R = (R ij ) (2) R (R 1 ) ij = R ji (3) 3 R ij R ik = δ jk (4) i=1 δ ij Kronecker δ ij = { 1 (i = j) 0 (i
1. 1 1.1 1.1.1 1.1.1.1 v v = v 1 v 2 v 3 (1) R = (R ij ) (2) R (R 1 ) ij = R ji (3) R ij R ik = δ jk (4) δ ij Kronecker δ ij = { 1 (i = j) 0 (i j) (5) 1 1.1. v1.1 2011/04/10 1. 1 2 v i = R ij v j (6) [
More informationMicrosoft PowerPoint - CproNt02.ppt [互換モード]
第 2 章 C プログラムの書き方 CPro:02-01 概要 C プログラムの構成要素は関数 ( プログラム = 関数の集まり ) 関数は, ヘッダと本体からなる 使用する関数は, プログラムの先頭 ( 厳密には, 使用場所より前 ) で型宣言 ( プロトタイプ宣言 ) する 関数は仮引数を用いることができる ( なくてもよい ) 関数には戻り値がある ( なくてもよい void 型 ) コメント
More informationcomment.dvi
( ) (sample1.c) (sample1.c) 2 2 Nearest Neighbor 1 (2D-class1.dat) 2 (2D-class2.dat) (2D-test.dat) 3 Nearest Neighbor Nearest Neighbor ( 1) 2 1: NN 1 (sample1.c) /* -----------------------------------------------------------------
More information1 28 6 12 7 1 7.1...................................... 2 7.1.1............................... 2 7.1.2........................... 2 7.2...................................... 3 7.3...................................
More informationthesis.dvi
H8 e041220 2009 2 Copyright c 2009 by Kentarou Nagashima c 2009 Kentarou Nagashima All rights reserved , H8.,,,..,.,., AKI-H8/3052LAN. OS. OS H8 Write Turbo. H8 C, Cygwin.,., windows. UDP., (TA7279P).,.
More information第3章 OpenGL の基礎
3 OpenGL April 20, 2012 1 / 23 31 ( ) OpenGL OpenGL 2 / 23 32 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh CAD
More information( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>
2007 12 5 1 2 2.1 ( ) 1 1: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 #define H WIN 400 // 8 #define W WIN 300 // 9
More information2009 T060050
T060050 C++ Microsoft Visual C++ 2008 Express Edition DX C DX VC++ Debug exe 1 2 2009 T060050 1 1 2 1 2.1...................... 1 2.2....................... 2 3 3 3.1................... 3 3.2.....................
More information2000年度『数学展望 I』講義録
2000 I I IV I II 2000 I I IV I-IV. i ii 3.10 (http://www.math.nagoya-u.ac.jp/ kanai/) 2000 A....1 B....4 C....10 D....13 E....17 Brouwer A....21 B....26 C....33 D....39 E. Sperner...45 F....48 A....53
More information£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡
(2018) 2018 5 17 0 0 if switch if if ( ) if ( 0) if ( ) if ( 0) if ( ) (0) if ( 0) if ( ) (0) ( ) ; if else if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 (0) 2 if else
More informationyacc.dvi
2017 c 8 Yacc Mini-C C/C++, yacc, Mini-C, run,, Mini-C 81 Yacc Yacc, 1, 2 ( ), while ::= "while" "(" ")" while yacc 1: st while : lex KW WHILE lex LPAREN expression lex RPAREN statement 2: 3: $$ = new
More informationBessel ( 06/11/21) Bessel 1 ( ) 1.1 0, 1,..., n n J 0 (x), J 1 (x),..., J n (x) I 0 (x), I 1 (x),..., I n (x) Miller (Miller algorithm) Bess
Bessel 5 3 11 ( 6/11/1) Bessel 1 ( ) 1.1, 1,..., n n J (x), J 1 (x),..., J n (x) I (x), I 1 (x),..., I n (x) Miller (Miller algorithm) Bessel (6 ) ( ) [1] n n d j J n (x), d j I n (x) Deuflhard j= j=.1
More information1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>
1 C++ 1.1 C C++ C++ C C C++ 1.1.1 C printf() scanf() C++ C hello world printf() 1-1 #include printf( "hello world\n" ); C++ 1-2 std::cout
More information画像ファイルを扱う これまでに学んだ条件分岐, 繰り返し, 配列, ファイル入出力を使って, 画像を扱うプログラムにチャレンジしてみよう
第 14 回 応用 情報処理演習 ( テキスト : 第 10 章 ) 画像ファイルを扱う これまでに学んだ条件分岐, 繰り返し, 配列, ファイル入出力を使って, 画像を扱うプログラムにチャレンジしてみよう 特定色の画素の検出 ( テキスト 134 ページ ) 画像データが保存されているファイルを読み込んで, 特定色の画素の位置を検出するプログラムを作成しなさい 元画像生成画像 ( 結果の画像 )
More informationII ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D
II 8 2003 11 12 1 6 ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 Daisuke 8 =>. 73 Daisuke 35 Hiroshi 64 Ichiro 87 Junko
More informationMicrosoft PowerPoint - kougi8.ppt
C プログラミング演習 第 8 回構造体とレコードデータファイル 1 例題 1. バイナリファイル形式のファイル からのデータ読み込み 次のような名簿ファイル ( バイナリファイル形式 ) を読み込んで, 画面に表示するプログラムを作る name Ken Bill Mike age 20 32 35 address NewYork HongKong Paris 名簿ファイル 2 #include "stdafx.h"
More informationohp08.dvi
19 8 ( ) 2019.4.20 1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: 2 (2) NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( 2) 3 (3) head cur tail head cur prev data
More informationC¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç
C (3) if else switch AND && OR (NOT)! 1 BMI BMI BMI = 10 4 [kg]) ( [cm]) 2 bmi1.c Input your height[cm]: 173.2 Enter Input your weight[kg]: 60.3 Enter Your BMI is 20.1. 10 4 = 10000.0 1 BMI BMI BMI = 10
More information: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology
I117 8 1 School of Information Science, Japan Advanced Institute of Science and Technology : CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and
More informationInt Int 29 print Int fmt tostring 2 2 [19] ML ML [19] ML Emacs Standard ML M M ::= x c λx.m M M let x = M in M end (M) x c λx.
1, 2 1 m110057@shibaura-it.ac.jp 2 sasano@sic.shibaura-it.ac.jp Eclipse Visual Studio ML Standard ML Emacs 1 ( IDE ) IDE C C++ Java IDE IDE IDE IDE Eclipse Java IDE Java Standard ML 1 print (Int. 1 Int
More informationex01.dvi
,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double
More information数値計算
プログラム作成から実行まで 数値計算 垣谷公徳 17 号館 3 階電子メール : kimi@ee.ous.ac.jp Source program hello.c printf("hello\n"); コンパイラ Library libc.a 0011_printf000101001 1101_getc00011100011 1011_scanf1110010100 コンパイル Object module
More informationCompiled MODELSでのDFT位相検出装置のモデル化と評価
listsize TPBIG.EXE /Mingw32 ATP (Alternative Transients Program)- EMTP ATP ATP ATP ATP(TPBIG.EXE) EMTP (ATP)FORTAN77 DIMENSION C malloc listsize TACS DIMENSIONEMTP ATP(TPBIG.EXE) listsize (CPU ) RL 4040
More information第3章 OpenGL の基礎
3 OpenGL April 11, 2017 1 / 28 3.1 ( ) OpenGL OpenGL 2 / 28 3.2 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc. 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh
More information実際の株価データを用いたオプション料の計算
2002 2 20 1 1 3 2 3 2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 2.1.1 : : : : : : : : : : : : : : : : : : : : 5 2.1.2 : : : : : : : : : : : : : : : : : : : : 6 2.2 : : : : : : : : : :
More informationMicrosoft PowerPoint - kougi9.ppt
C プログラミング演習 第 9 回ポインタとリンクドリストデータ構造 1 今まで説明してきた変数 #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { double x; double y; char buf[256]; int i; double start_x; double step_x; FILE*
More informationex12.dvi
1 0. C, char., char, 0,. C, ("),., char str[]="abc" ; str abc.,, str 4. str 3. char str[10]="abc" ;, str 10, str 3., char s[]="abc", t[10] ;, t = s. ASCII, 0x00 0x7F, char., "abc" 3, 1. 1 8 256, 2., 2
More informationex14.dvi
1,, 0, b (b b 2 b ) n k n = n j b j, (0 n j b 1), n =(n k n k 1...n 1 n 0 ) b, n j j j +1, 0,...,b 1 (digit). b b, n b 1 ñ, ñ = k (b 1 n j )b j b N, n b n, n = b N n, n =ñ+1 b N, n m n + m (mod b N ),
More informationunix.dvi
1 UNIX 1999 4 27 1 UNIX? 2 1.1 Windows/Macintosh? : : : : : : : : : : : : : : : : : : : : : : : : 2 1.2 UNIX OS : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 2 1.3 : : : : : : : : : : : :
More information(300, 150) 120 getchar() HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgO
Handy Graphic for Handy Graphic Version 0.5 2008-06-09 1 Handy Graphic Handy Graphic C Handy Graphic Handy Graphic Mac OS X Handy Graphic HgDisplayer Handy Graphic HgDisplayer 2 Handy Graphic 1 Handy Graphic
More informationO(N) ( ) log 2 N
2005 11 21 1 1.1 2 O(N) () log 2 N 1.2 2 1 List 3-1 List 3-3 List 3-4? 3 3.1 3.1.1 List 2-1(p.70) 1 1 10 1 3.1.2 List 3-1(p.70-71) 1 1 2 1 2 2 1: 1 3 3.1.3 1 List 3-1(p.70-71) 2 #include stdlib.h
More information211 kotaro@math.titech.ac.jp 1 R *1 n n R n *2 R n = {(x 1,..., x n ) x 1,..., x n R}. R R 2 R 3 R n R n R n D D R n *3 ) (x 1,..., x n ) f(x 1,..., x n ) f D *4 n 2 n = 1 ( ) 1 f D R n f : D R 1.1. (x,
More informationMicrosoft PowerPoint - adi05.ppt [互換モード]
画像情報処理論 画像処理プログラミングの基礎 1 画像クラス PNM 画像フォーマット 2 レポートについて 3 演習 : 入出力 2 値化 多値化 Hue 疑似カラー ヒストグラム作成 大学院情報システム科学専攻張暁華 1 2 C++ クラスの基礎 多重ポインターから多次元配列を作る方法 class クラス名 { /* 設計図の様なものでクラス = 新しい型 */ public: /* パブリックの場合は
More informationr07.dvi
19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1
More information1 [ 1] (1) MKS? (2) MKS? [ 2] (1) (42.195k) k 2 (2) (3) k/hr [ 3] t = 0 10 ( 1 velocity [/s] 8 4 O
: 2014 4 10 1 2 2 3 2.1...................................... 3 2.2....................................... 4 2.3....................................... 4 2.4................................ 5 2.5 Free-Body
More informationPC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU
1. 1.1. 1.2. 1 PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 2. 2.1. 2 1 2 C a b N: PC BC c 3C ac b 3 4 a F7 b Y c 6 5 a ctrl+f5) 4 2.2. main 2.3. main 2.4. 3 4 5 6 7 printf printf
More informationohp07.dvi
19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5
More informationUSB 0.6 https://duet.doshisha.ac.jp/info/index.jsp 2 ID TA DUET 24:00 DUET XXX -YY.c ( ) XXX -YY.txt() XXX ID 3 YY ID 5 () #define StudentID 231
0 0.1 ANSI-C 0.2 web http://www1.doshisha.ac.jp/ kibuki/programming/resume p.html 0.3 2012 1 9/28 0 [ 01] 2 10/5 1 C 2 3 10/12 10 1 2 [ 02] 4 10/19 3 5 10/26 3 [ 03] 6 11/2 3 [ 04] 7 11/9 8 11/16 4 9 11/30
More information