2 cv GetD cv GetD cv PtrD Cv

  • Slides: 22
Download presentation

행렬 데이터에 접근하기 (2) 엄격한 방법 • 단순히 데이터를 읽기 위해서라면 cv. Get*D 형태의

행렬 데이터에 접근하기 (2) 엄격한 방법 • 단순히 데이터를 읽기 위해서라면 cv. Get*D 형태의 함수를 사용하 면 편리하다. • cv. Get*D 형태의 함수는 cv. Ptr*D 함수와 사용법이 유사하지만 행렬 의 실제 원소값을 반환한다. Cv. Mat와 Ipl. Image 원소값을 받아오는 함수 Example double cv. Get. Real 1 D( const Cv. Arr* arr, int idx 0 ); double cv. Get. Real 2 D( const Cv. Arr* arr, int idx 0, int idx 1 ); double cv. Get. Real 3 D( const Cv. Arr* arr, int idx 0, idx 1, idx 2 ); double cv. Get. Real. ND( const Cv. Arr* arr, int* idx ); Cv. Scalar cv. Get 1 D( const Cv. Arr* arr, int idx 0 ); Cv. Scalar cv. Get 2 D( const Cv. Arr* arr, int idx 0, idx 1 ); Cv. Scalar cv. Get 3 D( const Cv. Arr* arr, int idx 0, idx 1, idx 2 ); Cv. Scalar cv. Get. ND( const Cv. Arr* arr, int* idx ); void cv. Set. Real 1 D( Cv. Arr* arr, int idx 0, double value ); void cv. Set. Real 1 D( Cv. Arr* arr, int idx 0, Cv. Scalar value ); : void cv. Set. Real. ND( Cv. Arr* arr, int* idx, double value ); void cv. Set. Real. ND( Cv. Arr* arr, int* idx, Cv. Scalar value );

행렬 데이터에 접근하기 (3) 적절한 방법 Example Float sum( const Cv. Mat* mat )

행렬 데이터에 접근하기 (3) 적절한 방법 Example Float sum( const Cv. Mat* mat ) { float s = 0. 0 f; for( int row = 0 ; row < mat->rows ; row++ ) { const float* ptr = )const float*)(mat->data. ptr + row * mat->step); } } for( col = 0 ; col < mat->cols ; col++ ) s += *ptr++; // ptr이 가리키는 값을 s에 더한 후, ptr 주소를 하나 증가 return( s );

Ipl. Image IPL : Image Processing Library 구조체 Structure typedef struct_Ipl. Image { int

Ipl. Image IPL : Image Processing Library 구조체 Structure typedef struct_Ipl. Image { int n. Size; int ID; int n. Channels; int alpha. Channel; int depth; char color. Model[4]; char channel. Seq[4]; int data. Order; int origin; int align; int width; int height; struct _Ipl. ROI* roi; struct _Ipl. Image*mask. ROI; void* image. Id; struct _Ipl. Tile. Info* tile. Info; int image. Size; char* image. Data; int width. Step; int Border. Mode[4]; int Border. Const[4]; char* Image. Data. Origin; } Ipl. Image; • 1(gray), 2, 3(RGB), 4(RGBA) Macro Image pixel type IPL_DEPTH_8 U IPL_DEPTH_8 S IPL_DEPTH_16 S IPL_DEPTH_32 F 부호없는 8비트 정수(8 u) 부호있는 8비트 정수(8 s) 부호있는 16비트 정수 (16 s) 부호있는 32비트 정수 (32 s) 32비트 실수형 단일 정밀 도 (32 f) 64비트 실수형 이중 정밀 도 (64 f) IPL_DEPTH_64 F

Ipl. Image IPL : Image Processing Library 구조체 Structure typedef struct_Ipl. Image { int

Ipl. Image IPL : Image Processing Library 구조체 Structure typedef struct_Ipl. Image { int n. Size; int ID; int n. Channels; int alpha. Channel; int depth; char color. Model[4]; char channel. Seq[4]; int data. Order; int origin; int align; int width; int height; struct _Ipl. ROI* roi; struct _Ipl. Image*mask. ROI; void* image. Id; struct _Ipl. Tile. Info* tile. Info; int image. Size; char* image. Data; int width. Step; int Border. Mode[4]; int Border. Const[4]; char* Image. Data. Origin; } Ipl. Image; • IPL_DATA_ORDER_PIXEL or IPL_DATA_ORDER_PLANE • IPL_ORIGIN_TL or IPL_ORIGIN_BL

Ipl. Image IPL : Image Processing Library 구조체 Structure typedef struct_Ipl. Image { int

Ipl. Image IPL : Image Processing Library 구조체 Structure typedef struct_Ipl. Image { int n. Size; int ID; int n. Channels; int alpha. Channel; int depth; char color. Model[4]; char channel. Seq[4]; int data. Order; int origin; int align; int width; int height; struct _Ipl. ROI* roi; struct _Ipl. Image*mask. ROI; void* image. Id; struct _Ipl. Tile. Info* tile. Info; int image. Size; char* image. Data; int width. Step; int Border. Mode[4]; int Border. Const[4]; char* Image. Data. Origin; } Ipl. Image; • IPL/IPP에서 유래된 Ipl. ROI라는 이름의 구조체타입변수 xoffset, yoffset, height, width, coi(관심 채널(channel of interst)등의 멤버를 가지고 있음 • 동일 column과 연속된 rows간의 점들 사 이에 바이트 개수

직선과 사각형 • 가장 간단한 그리기 연산은 브레제남 알고리즘(Bresenham algorithm)에 의한 직선 그리기이다. Function

직선과 사각형 • 가장 간단한 그리기 연산은 브레제남 알고리즘(Bresenham algorithm)에 의한 직선 그리기이다. Function void cv. Line( Cv. Arr* array, Cv. Point pt 1, Cv. Point pt 2, Cv. Scalarcolor, int thickness = 1, int connectivity = 8 ); void cv. Rectangle( Cv. Arr* array, Cv. Point pt 1, Cv. Point pt 2, Cv. Scalarcolor, int thickness = 1, );

원과 타원 • cv. Circle(), cv. Ellipse. Box() 사용 Function void cv. Circle (

원과 타원 • cv. Circle(), cv. Ellipse. Box() 사용 Function void cv. Circle ( Cv. Arr* array, Cv. Point center, int radius, Cv. Scalarcolor, int thickness = 1, int connectivity = 8 ); void cv. Ellipse( Cv. Arr* array, Cv. Point center, Cv. Size axes, double angle, double end_angle, Cv. Scalarcolor, int thickness = 1, int line_type = 8 ); void cv. Ellipse. Box( Cv. Arr* array, Cv. Box 2 D box, Cv. Scalar color, int thickness = 1, int line_type = 8, int shift = 0 ); typedef struct{ Cv. Point 2 D 32 f center; Cv. Size 2 D 32 f size; float angle; } Cv. Box 2 D;