Example: dental hygienist

画像処理の基礎 (2) OpenCV による基本的な例―

(2) OpenCV swk(at) ( ): { Fx,y}{ Gx,y}Gx,y{ Fi,j}, (i, j) Neighbor(x,y) 3x3 5x5 , .. Gx,y : (smoothing) (edge detection)3 ( ): : (smoothing) Gx,y{ Fi,j}, (i, j) Neighbor(x,y) 3x3 {Fi,j} Gx,y 1 2 1/161/81/161/81/41/81/161/81/161/91/91/9 1/91/91/91/91/91/9 1 2 4 ( ): { Fx,y}{ Gx,y}Gx,y{ Fi,j}, (i, j) Neighbor(x,y)weight matrixpixel-wise multiplicationand summation 5 ( ): 1111

知能制御システム学 画像処理の基礎(2) ―OpenCV による基本的な例― 東北大学大学院情報科学研究科 鏡慎吾 swk(at)ic.is.tohoku.ac.jp

Tags:

  Opencv

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of 画像処理の基礎 (2) OpenCV による基本的な例―

1 (2) OpenCV swk(at) ( ): { Fx,y}{ Gx,y}Gx,y{ Fi,j}, (i, j) Neighbor(x,y) 3x3 5x5 , .. Gx,y : (smoothing) (edge detection)3 ( ): : (smoothing) Gx,y{ Fi,j}, (i, j) Neighbor(x,y) 3x3 {Fi,j} Gx,y 1 2 1/161/81/161/81/41/81/161/81/161/91/91/9 1/91/91/91/91/91/9 1 2 4 ( ): { Fx,y}{ Gx,y}Gx,y{ Fi,j}, (i, j) Neighbor(x,y)weight matrixpixel-wise multiplicationand summation 5 ( ): 1111211110101410101111111116 ( ): double w[3 * 3] = { , , , , , , , , }; double scaling = / ;for (j = 0; j < img->height; j++) {for (i = 0; i < img->width; i++) {double sum = ;for (n = 0; n < 3; n++) {for (m = 0.)}}}

2 M < 3; m++) {sum += pval(img, i - 1 + m, j - 1 + n)* w[m + 3 * n];}}PIXVAL(result, i, j) = clipvalue(scaling * sum);}}7 ( ): OpenCV cvFilter2D() cvSmooth() cvSobel(), cvLaplace pval() clipvalue() sample program: ( ): 2 9 ( ): ?

3 (1)Marr and Hildreth (1980) 10 ( ): ? (2) : I(x, y) t I(x, y; t) 3 ) Florack et al. (1992) : t1 t2 t1+ t2 11 ( ): [Lindeberg 1996]12 ( ): (edge detection) -101-101-101-1-1-1000111 1 1 (Sobel )-101-202-101-1-2-100012113 ( ).

4 2 2/ x2+ 2/ y2 1 2 fi+1 2 fi+ fi 1 3x3 0101 4 101014 ( ): DoG Laplacian of Gaussian (LoG) LoG 2 Difference of Gaussian (DoG) DoG( , t) = G( , t + t) G( , t) DoG 15 ( ): [Lindeberg 1994]16 ( ): (sharpening) 0-10-112-10-100000800000101 4 1010 = 17 ( ): 2 (binary image) 18 ( ): (neighbor): 4-neighbor8-neighbor n- 2 n- (n-adjacent) 2 a, b p0(= a), p1, p2.

5 , pn-1, pn(= b) pi pi pi-1 n- a b n- (n-neighbor connected) 19 ( ): dilation: 1 1 erosion: 0 0 opening: erosion + dilationclosing: dilation + erosionGi,j= Fi,j| Fi-1,j| Fi+1,j| Fi,j-1 | Fi,j+1Gi,j= Fi,j& Fi-1,j& Fi+1,j& Fi,j-1& Fi,j+1(4- )(4- ) OpenCV cvErode(), cvDilate() sample program: ( ): 2 sample program: : 0 21 ( ): 4422 ( ): 0.

6 2 x 1 y 1 0 1 (gx, gy) = (m1,0/m0,0, m0,1/m0,0) OpenCV cvMoments() sample program: ( ): = 34 ms 33 ms 33 ms 32 ms 1 ms 24 ( ): #include < >LARGE_INTEGER freq;LARGE_INTEGER cn1, cn2;double elapsed_time_in_microseconds;if (QueryPerformanceFrequency(&freq) == 0) {fprintf(stderr, "cannot use performance counter n");return 1;}QueryPerformanceCounter( // do somethingQueryPerformanceCounter( elapsed_time_in_microseconds = ( * ( )) / ).)

7 25 ( ): : m n 1 O(mn) X Y 1 1 O(max(m,n)) (separable) 26 ( ): ( PerformanceCounter )MSIZEMSIZE//#define OPT_NOSEP#define OPT_SEP MSIZE = 2 * MARGIN + 1#define MARGIN 7 27 ( ): PC CPU : 28 ( ): for (j = 0; j < height; j++) {for (i = 0; i < width; i++) {PIXVAL(img, i, j) =.}}

8 }}for (i = 0; i < width; i++) {for (j = 0; j < height; j++) {PIXVAL(img, i, j) = ..}} #define OPT_INTERCHANGE sample program ( )29 ( ): #define OPT_INDEX PIXVAL sample program ( )30 ( ): *ptr;int gap = img->widthStep width;for (j = 0, ptr = img->imageData; j < height; j++, ptr += gap) {for (i = 0; i < width; i++, ptr++) {*ptr =.

9 }}#define PIXVAL(img, i, j)(*(uchar *)((img)->imageData + (y) * (img)->widthStep + (x)))for (j = 0; j < height; j++) {for (i = 0; i < width; i++) {PIXVAL(img, i, j) = ..}}31 ( ): [1] : , , 2002. [2] T. Lindeberg: Scale-space: A framework for handling image structures at multiple scales, Proc. CERN School of Computing, 1996.[3] T. Lindeberg: Scale-space theory: A basic tool for analysingstructures at different scales, J. Applied Statistics, , , , 1994. [4] D. Marr: , , 1987.

10 [5] D. Marr and E. Hildreth: Theory of Edge Detection, Proc. Roy. Soc. London, Series B, Biological Sciences, , , , 1980. [6] L. M. J. Florack, B. M. T. Romeny, J. J. Koenderink and M. A. Viergever: Scale and the Differential Structure of Images, Image and Vision Computing, , , , 1992.


Related search queries