




已阅读5页,还剩53页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
opencv 二值化函数 cvThreshold OpenCV 2009-03-26 16:00:07 阅读 4570 评论 5 字号:大中小 订阅 对图像二值化函数 cvThreshold 的理解 Threshold 对数组元素进行固定阈值操作 void cvThreshold( const CvArr* src, CvArr* dst, double threshold, double max_value, int threshold_type ); src 原始数组 (单通道 , 8-bit of 32-bit 浮点数). dst 输出数组,必须与 src 的类型一致,或者为 8-bit. threshold 阈值 max_value 使用 CV_THRESH_BINARY 和 CV_THRESH_BINARY_INV 的最大值. threshold_type 阈值类型 (见讨论) 函数 cvThreshold 对单通道数组应用固定阈值操作。该函数的典型应用是 对灰度图像进行阈值操作得到二值图像。(cvCmpS 也可以达到此目的) 或者是 去掉噪声,例如过滤很小或很大象素值的图像点。本函数支持的对图像取阈值 的方法由 threshold_type 确定: threshold_type=CV_THRESH_BINARY: dst(x,y) = max_value, if src(x,y)threshold 0, otherwise. threshold_type=CV_THRESH_BINARY_INV: dst(x,y) = 0, if src(x,y)threshold; dst(x,y) = max_value, otherwise. threshold_type=CV_THRESH_TRUNC: dst(x,y) = threshold, if src(x,y)threshold; dst(x,y) = src(x,y), otherwise. threshold_type=CV_THRESH_TOZERO: dst(x,y) = src(x,y), if (x,y)threshold ; dst(x,y) = 0, otherwise. threshold_type=CV_THRESH_TOZERO_INV: dst(x,y) = 0, if src(x,y)threshold ; dst(x,y) = src(x,y), otherwise. 左面是图形化的阈值描述: OpenCV 中矩阵数据的访问(一)(Learning OpenCV 第三章 2) 由 keystonexu 2008-11-26 20:28 在 OpenCV 中有三种方式访问矩阵中的数据元素:容易的方式,困难的方式,以 及正确的方式。以下先讲容易的方式和困难的方式。 容易的方式 最容易的方式是使用宏 CV_MAT_ELEM( matrix, elemtype, row, col ),输入参 数是矩阵的指针,矩阵元素类型,行,列,返回值是相应行,列的矩阵元素, 例如: CvMat* mat = cvCreateMat(5,5,CV_32FC1); float element = CV_MAT_ELEM(*mat,float,3,2); 以下是一个例子: #pragma comment( lib, “cxcore.lib“ ) #include “cv.h“ #include void main() CvMat* mat = cvCreateMat(3,3,CV_32FC1); cvZero(mat);/将矩阵置 0 /为矩阵元素赋值 CV_MAT_ELEM( *mat, float, 0, 0 ) = 1.f; CV_MAT_ELEM( *mat, float, 0, 1 ) = 2.f; CV_MAT_ELEM( *mat, float, 0, 2 ) = 3.f; CV_MAT_ELEM( *mat, float, 1, 0 ) = 4.f; CV_MAT_ELEM( *mat, float, 1, 1 ) = 5.f; CV_MAT_ELEM( *mat, float, 1, 2 ) = 6.f; CV_MAT_ELEM( *mat, float, 2, 0 ) = 7.f; CV_MAT_ELEM( *mat, float, 2, 1 ) = 8.f; CV_MAT_ELEM( *mat, float, 2, 2 ) = 9.f; /获得矩阵元素的值 float element = CV_MAT_ELEM(*mat,float,2,2); printf(“%fn“,element); CV_MAT_ELEM 宏实际上会调用 CV_MAT_ELEM_PTR(matrix,row,col)宏来完成任务。 CV_MAT_ELEM_PTR()宏的参数是矩阵的指针,行,列。 CV_MAT_ELEM()宏和 CV_MAT_ELEM_PTR()宏的区别是,在调用 CV_MAT_ELEM 时, 指向矩阵元素的指针的数据类型已经依据输入参数中的元素类型而 做了强制转换。,以下是使用 CV_MAT_ELEM_PTR()来设置元素的值: #pragma comment( lib, “cxcore.lib“ ) #include “cv.h“ #include void main() CvMat* mat = cvCreateMat(3,3,CV_32FC1); cvZero(mat);/将矩阵置 0 float element_0_2 = 7.7f; *(float*)CV_MAT_ELEM_PTR( *mat, 0, 2 ) ) = element_0_2; /获得矩阵元素的值 float element = CV_MAT_ELEM(*mat,float,0,2); printf(“%fn“,element); 以上使用矩阵中元素的方式很方便,但不幸的是,该宏在每次调用时,都会重 新计算指针的位置。这意味着,先查找矩阵数据区中第 0 个元素的位置,然后, 根据参数中的行和列,计算所需要的元素的地址偏移量,然后将地址偏移量与 第 0 个元素的地址相加,获得所需要的元素的地址。 所以,以上的方式虽然很容易使用,但是却不是获得矩阵元素的最好方式。特 别是当你要顺序遍历整个矩阵中所有元素时,这种每次对地址的重复计算就更 加显得不合理。 困难的方式 以上两个宏只适合获得一维或二维的矩阵(数组)元素,OpenCV 提供了处理多 维矩阵(数组)的方式。实际上你可以不受限制地使用 N 维。 当访问这样一种 N 维矩阵中元素时,你需要使用一个系列的函数,叫做 cvPtr*D,*代表 1,2,3,4,例如,cvPtr1D(),cvPtr2D(),cvPtr3D(),以及 cvPtrND().以下为此系列函数的定义: cvPtr*D 函数用于返回指向某数组元素的指针 uchar* cvPtr1D( const CvArr* arr, int idx0, int* type=NULL ); uchar* cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type=NULL ); uchar* cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, int* type=NULL ); uchar* cvPtrND( const CvArr* arr, int* idx, int* type=NULL, int create_node=1, unsigned* precalc_hashval=NULL ); arr 输入数组(矩阵). idx0 元素下标的第一个以 0 为基准的成员 idx1 元素下标的第二个以 0 为基准的成员 idx2 元素下标的第三个以 0 为基准的成员 idx 数组元素下标 type 可选的,表示输出参数的数据类型 create_node 可选的,为稀疏矩阵输入的参数。如果这个参数非零就意味着被需要的元素如 果不存在就会被创建。 precalc_hashval 可选的,为稀疏矩阵设置的输入参数。如果这个指针非 NULL,函数不会重新计 算节点的 HASH 值,而是从指定位置获取。这种方法有利于提高智能组合数据的 操作 函数 cvPtr*D 返回指向特殊数组元素的指针。数组维数应该与传递给函数的下 标数相匹配,它可以被用于顺序存取的 1D,2D 或 nD 密集数组 函数也可以用于稀疏数组,并且如果被需要的节点不存在函数可以创建这个节 点并设置为 0 就像其它获取数组元素的函数 (cvGetReal*D, cvSetReal*D)如果元素的下 标超出了范围就会产生错误 很明显,如果是一维数组(矩阵),那就可以使用 cvPtr1D,用参数 idx0 来指向 要获得的第 idx0 个元素,返回值为指向该元素的指针,如果是二维数组(矩阵), 就可以使用 cvPtr2D,用 idx0,idx1 来指向相应的元素。 如果是 N 维数组,则 int* idx 参数指向对 N 维数组中某元素定位用的下标序列。 #pragma comment( lib, “cxcore.lib“ ) #include “cv.h“ #include void main() CvMat* mat = cvCreateMat(3,3,CV_32FC1); cvZero(mat);/将矩阵置 0 /为矩阵元素赋值 CV_MAT_ELEM( *mat, float, 0, 0 ) = 1.f; CV_MAT_ELEM( *mat, float, 0, 1 ) = 2.f; CV_MAT_ELEM( *mat, float, 0, 2 ) = 3.f; CV_MAT_ELEM( *mat, float, 1, 0 ) = 4.f; CV_MAT_ELEM( *mat, float, 1, 1 ) = 5.f; CV_MAT_ELEM( *mat, float, 1, 2 ) = 6.f; CV_MAT_ELEM( *mat, float, 2, 0 ) = 7.f; CV_MAT_ELEM( *mat, float, 2, 1 ) = 8.f; CV_MAT_ELEM( *mat, float, 2, 2 ) = 9.f; /获得矩阵元素(0,2)的值 float *p = (float*)cvPtr2D(mat, 0, 2); printf(“%fn“,*p); 我们使用 cvPtr*D()函数的一个理由是,通过此函数,我们可以用指针指向矩 阵中的某元素,并使用指针运算符,来设置该元素的值,或者,用指针运算来 移动指针,指向从起始位置开始的矩阵中的其他元素。例如,我们可以用以下 方式遍历矩阵中的元素: #pragma comment( lib, “cxcore.lib“ ) #include “cv.h“ #include void main() CvMat* mat = cvCreateMat(3,3,CV_32FC1); cvZero(mat);/将矩阵置 0 /获得矩阵元素(0,0)的指针 float *p = (float*)cvPtr2D(mat, 0, 0); /为矩阵赋值 for(int i = 0; i void main() /矩阵元素为三通道浮点数 CvMat* mat = cvCreateMat(3,3,CV_32FC3); cvZero(mat);/将矩阵置 0 /为矩阵元素赋值 /获得矩阵元素(0,0)的指针 float *p = (float*)cvPtr2D(mat, 0, 0); /为矩阵赋值 for(int i = 0; i void main() /矩阵元素为 1 通道浮点型数据 CvMat*mat=cvCreateMat(3,3,CV_32FC1 ); cvZero(mat);/将矩阵置 0 /为矩阵元素赋值 /获得矩阵元素(0,0)的指针 float *p=(float*)cvPtr2D(mat,0,0); /为矩阵赋值 for(int i=0;i void main() /矩阵元素为三通道 8 位浮点数 CvMat *mat=cvCreateMat(3,3,CV_32FC3 ); cvZero(mat);/将矩阵置 0 /为矩阵元素赋值 for(int i = 0; i height*image-widthStep),單位位元組*/ char *imageData; /* 指向排列的圖像數據 */ int widthStep; /* 排列的圖像行大小,以位元組為單位 */ int BorderMode4; /* 邊際結束模式, 被 OpenCV 忽略 */ int BorderConst4; /* 同上 */ char *imageDataOrigin; /* 指針指向一個不同的圖像數據結構(不 是必須排列的),是為了糾正圖像記憶體分配準備的 */ IplImage; IplImage 結構來自於 Intel Image Processing Library(是其本身所具有的) 。OpenCV 只支持其中的一個子集: alphaChannel 在 OpenCV 中被忽略。 colorModel 和 channelSeq 被 OpenCV 忽略。OpenCV 顏色轉換的唯一函數 cvCvtColor 把原圖像的顏色空間的目標圖像的顏色空間作為一個參數。 dataOrder 必須是 IPL_DATA_ORDER_PIXEL (顏色通道是交叉存取),然而平面圖 像的被選擇通道可以被處理,就像 COI(感興趣的通道)被設置過一樣。 align 是被 OpenCV 忽略的,而用 widthStep 去訪問後繼的圖像行。 不支持 maskROI 。處理 MASK 的函數把他當作一個分離的參數。MASK 在 OpenCV 里是 8-bit,然而在 IPL 他是 1-bit。 tileInfo 不支持。 BorderMode 和 BorderConst 是不支持的。每個 OpenCV 函數處理像素的鄰近的像 素,通常使用單一的固定代碼邊際模式。 除了上述限制,OpenCV 處理 ROI 有不同的要求。要求原圖像和目標圖像的尺寸 或 ROI 的尺寸必須(根據不同的操作,例如 cvPyrDown 目標圖像的寬(高)必 須等於原圖像的寬(高)除以 2 1)精確匹配,而 IPL 處理交叉區域,如圖像 的大小或 ROI 大小可能是完全獨立的。 編輯 CvArr 不確定數組 typedef void CvArr; CvArr* 僅僅是被用於作函數的參數,用於指示函數接收的數組類型可以不止一 個,如 IplImage*, CvMat* 甚至 CvSeq*. 最終的數組類型是在運行時通過分 析數組頭的前 4 個位元組判斷。 怎么访问图像像素 (坐标是从 0 开始的,并且是相对图像原点的位置。图像原点或者是左上角 (img-origin=IPL_ORIGIN_TL) 或者是左下角 (img-origin=IPL_ORIGIN_BL) ) 假设有 8-bit 1通道的图像 I (IplImage* img): I(x,y) (uchar*)(img-imageData + img-widthStep*y)x 假设有 8-bit 3-通道的图像 I (IplImage* img): I(x,y)blue (uchar*)(img-imageData + img-widthStep*y)x*3 I(x,y)green (uchar*)(img-imageData + img-widthStep*y)x*3+1 I(x,y)red (uchar*)(img-imageData + img-widthStep*y)x*3+2 例如,给点 (100,100) 的亮度增加 30 ,那么可以这样做: CvPoint pt = 100,100; (uchar*)(img-imageData + img-widthStep*pt.y)pt.x*3 += 30; (uchar*)(img-imageData + img-widthStep*pt.y)pt.x*3+1 += 30; (uchar*)(img-imageData + img-widthStep*pt.y)pt.x*3+2 += 30; 或者更高效地: CvPoint pt = 100,100; uchar* temp_ptr = temp_ptr0 += 30; temp_ptr1 += 30; temp_ptr2 += 30; 假设有 32-bit 浮点数, 1-通道 图像 I (IplImage* img): I(x,y) (float*)(img-imageData + img-widthStep*y)x 现在,一般的情况下,假设有 N-通道,类型为 T 的图像: I(x,y)c (T*)(img-imageData + img-widthStep*y)x*N + c 你可以使用宏 CV_IMAGE_ELEM( image_header, elemtype, y, x_Nc ) I(x,y)c CV_IMAGE_ELEM( img, T, y, x*N + c ) 也有针对各种图像(包括 4 通道图像)和矩阵的函数(cvGet2D, cvSet2D), 但是它们非常慢。 编辑 如何访问矩阵元素? 方法是类似的(下面的例子都是针对 0 起点的列和行) 设有 32-bit 浮点数的实数矩阵 M (CvMat* mat): M(i,j) (float*)(mat-data.ptr + mat-step*i)j 设有 64-bit 浮点数的复数矩阵 M (CvMat* mat): Re M(i,j) (double*)(mat-data.ptr + mat-step*i)j*2 Im M(i,j) (double*)(mat-data.ptr + mat-step*i)j*2+1 对单通道矩阵,有宏 CV_MAT_ELEM( matrix, elemtype, row, col ), 例如对 32-bit 浮点数的实数矩阵: M(i,j) CV_MAT_ELEM( mat, float, i, j ), 例如,这儿是一个 3x3 单位矩阵的初始化: CV_MAT_ELEM( mat, float, 0, 0 ) = 1.f; CV_MAT_ELEM( mat, float, 0, 1 ) = 0.f; CV_MAT_ELEM( mat, float, 0, 2 ) = 0.f; CV_MAT_ELEM( mat, float, 1, 0 ) = 0.f; CV_MAT_ELEM( mat, float, 1, 1 ) = 1.f; CV_MAT_ELEM( mat, float, 1, 2 ) = 0.f; CV_MAT_ELEM( mat, float, 2, 0 ) = 0.f; CV_MAT_ELEM( mat, float, 2, 1 ) = 0.f; CV_MAT_ELEM( mat, float, 2, 2 ) = 1.f; 编辑 如何在 OpenCV 中处理我自己的数据 设你有 300x200 32-bit 浮点数 image/array, 也就是对一个有 60000 个元素 的数组。 int cols = 300, rows = 200; float* myarr = new floatrows*cols; / 第一步,初始化 CvMat 头 CvMat mat = cvMat( rows, cols, CV_32FC1, / 32 位浮点单通道类型 myarr / 用户数据指针(数据没有被复制) ); / 第二步,使用 cv 函数, 例如计算 l2 (Frobenius) 模 double norm = cvNorm( . delete myarr; 其它情况在参考手册中有描述。 见 cvCreateMatHeader,cvInitMatHeader,cvCreateImageHeader, cvSetData 等 编辑 如何读入和显示图像 /* usage: prog */ #include “cv.h“ #include “highgui.h“ int main( int argc, char* argv ) IplImage* img; if( argc = 2 cvShowImage( “Image view“, img ); cvWaitKey(0); / 非常重要,内部包含事件处理循环 cvDestroyWindow( “Image view“ ); cvReleaseImage( return 0; return -1; 编辑 如何检测和处理轮廓线 参考 squares demo /* 在程序里找寻矩形 */ #ifdef _CH_ #pragma package #endif #ifndef _EiC #include “cv.h“ #include “highgui.h“ #include #include #include #endif int thresh = 50; IplImage* img = 0; IplImage* img0 = 0; CvMemStorage* storage = 0; CvPoint pt4; const char* wndname = “Square Detection Demo“; / helper function: / finds a cosine of angle between vectors / from pt0-pt1 and from pt0-pt2 double angle( CvPoint* pt1, CvPoint* pt2, CvPoint* pt0 ) double dx1 = pt1-x - pt0-x; double dy1 = pt1-y - pt0-y; double dx2 = pt2-x - pt0-x; double dy2 = pt2-y - pt0-y; return (dx1*dx2 + dy1*dy2)/sqrt(dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2) + 1e-10); / returns sequence of squares detected on the image. / the sequence is stored in the specified memory storage CvSeq* findSquares4( IplImage* img, CvMemStorage* storage ) CvSeq* contours; int i, c, l, N = 11; CvSize sz = cvSize( img-width IplImage* timg = cvCloneImage( img ); / make a copy of input image IplImage* gray = cvCreateImage( sz, 8, 1 ); IplImage* pyr = cvCreateImage( cvSize(sz.width/2, sz.height/2), 8, 3 ); IplImage* tgray; CvSeq* result; double s, t; / create empty sequence that will contain points - / 4 points per square (the squares vertices) CvSeq* squares = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvPoint), storage ); / select the maximum ROI in the image / with the width and height divisible by 2 cvSetImageROI( timg, cvRect( 0, 0, sz.width, sz.height ); / down-scale and upscale the image to filter out the noise cvPyrDown( timg, pyr, 7 ); cvPyrUp( pyr, timg, 7 ); tgray = cvCreateImage( sz, 8, 1 ); / find squares in every color plane of the image for( c = 0; c total = 4 for( i = 0; i = 2 ) t = fabs(angle( (CvPoint*)cvGetSeqElem( result, i ), (CvPoint*)cvGetSeqElem( result, i-2 ), (CvPoint*)cvGetSeqElem( result, i-1 ); s = s t ? s : t; / if cosines of all angles are small / (all angles are 90 degree) then write quandrange / vertices to resultant sequence if( s h_next; / release all the temporary images cvReleaseImage( cvReleaseImage( cvReleaseImage( cvReleaseImage( return squares; / the function draws all the squares in the image void drawSquares( IplImage* img, CvSeq* squares ) CvSeqReader reader; IplImage* cpy = cvCloneImage( img ); int i; / initialize reader of the sequence cvStartReadSeq( squares, / read 4 sequence elements at a time (all vertices of a square) for( i = 0; i total; i += 4 ) CvPoint* rect = pt; int count = 4; / read 4 vertices memcpy( pt, reader.ptr, squares-elem_size ); CV_NEXT_SEQ_ELEM( squares-elem_size, reader ); memcpy( pt + 1, reader.ptr, squares-elem_size ); CV_NEXT_SEQ_ELEM( squares-elem_size, reader ); memcpy( pt + 2, reader.ptr, squares-elem_size ); CV_NEXT_SEQ_ELEM( squares-elem_size, reader ); memcpy( pt + 3, reader.ptr, squares-elem_size ); CV_NEXT_SEQ_ELEM( squares-elem_size, reader ); / draw the square as a closed polyline cvPolyLine( cpy, / show the resultant image cvShowImage( wndname, cpy ); cvReleaseImage( void on_trackbar( int a ) if( img ) drawSquares( img, findSquares4( img, storage ) ); char* names = “pic1.png“, “pic2.png“, “pic3.png“, “pic4.png“, “pic5.png“, “pic6.png“, 0 ; int main(int argc, char* argv) int i, c; / create memory storage that will contain all the dynamic data storage = cvCreateMemStorage(0); for( i = 0; namesi != 0; i+ ) / load i-th image img0 = cvLoadImage( namesi, 1 ); if( !img0 ) printf(“Couldnt load %sn“, namesi ); continue; img = cvCloneImage( img0 ); / create window and a trackbar (slider) with parent “image“ and set callback / (the slider regulates upper threshold, passed to Canny edge detector) cvNamedWindow( wndname, 1 ); cvCreateTrackbar( “canny thresh“, wndname, / force the image processing on_trackbar(0); / wait for key. / Also the function cvWaitKey takes care of event processing c = cvWaitKey(0); / release both images cvReleaseImage( cvReleaseImage( / clear memory storage - reset free space position cvClearMemStorage( storage ); if( c = 27 ) break; cvDestroyWindow( wndname ); return 0; #ifdef _EiC main(1,“squares.c“); #endif 关于 OpenCV 中图像像素的操作 由 mirnux 2007-04-10 10:34 有个问题没弄明白,请教一下 我们在 CreateImage 时,数据类型有如下几种: IPL_DEPTH_8U - 无符号 8 位整型 IPL_DEPTH_8S - 有符号 8 位整型 IPL_DEPTH_16U - 无符号 16 位整型 IPL_DEPTH_16S - 有符号 16 位整型 IPL_DEPTH_32S - 有符号 32 位整型 IPL_DEPTH_32F - 单精度浮点数 IPL_DEPTH_64F - 双精度浮点数 如果是 IPL_DEPTH_8U,我们可以用(uchar*)(img-imageData + img- widthStep*y)x来遍历数据 如果是 IPL_DEPTH_32F ,我们可以用(float*)(img-imageData + img- widthStep*y)x来遍历 如果是 IPL_DEPTH_64F ,我们可以用(double*)(img-imageData + img- widthStep*y)x来遍历 以上都假设是单通道,那么如果是其余的数据类型呢?前面这个强制转换的类 型是什么? 比如我在用 cvIntegral 函数时 CvSize size = cvGetSize(pImg); size.width += 1; size.height += 1; matrix1 = cvCreateImage( size, IPL_DEPTH_64F, 1 ); cvIntegral( pImg , matrix1 ); 然后用循环打印 printf(“%f “,(double *)(matrix1-imageData + matrix1- widthStep*j)i);的数据为什么全部是 0 呢? Last Change Annotate Revision Log root/trunk/opencv/src/cv/cvgeometry.cpp 2518 View revision: 2518 Visit: Go! Revision 2219, 19.3 KB (checked in by xavier98, 18 months ago) fix incorrect matrix size bug in cv:decomposeProjectionMatrix Line 1 /*M/ 2 / 3 / IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 / 5 / By downloading, copying, installing or using the software you agree to this license. 6 / If you do not agree to this license, do not download, install, 7 / copy or use the software. 8 / 9 / 10 / Intel License Agreement 11 / For Open Source Computer Vision Library 12 / 13 / Copyright (C) 2000, Intel Corporation, all rights reserved. 14 / Third party copyrights are property of their respective owners. 15 / 16 / Redistribution and use in source and binary forms, with or without modification, 17 / are permitted provided that the following conditions are met: 18 / Line 19 / * Redistributions of source code must retain the above copyright notice, 20 / this list of conditions and the following disclaimer. 21 / 22 / * Redistributions in binary form must reproduce the above copyright notice, 23 / this list of conditions and the following disclaimer in the documentation 24 / and/or other materials provided with the distribution. 25 / 26 / * The name of Intel Corporation may not be used to endorse or promote products 27 / derived from this software without specific prior written permission. 28 / 29 / This software is provided by the copyright holders and contributors “as is“ and 30 / any express or implied warranties, including, but not limited to, the implied 31 / warranties of merchantability and fitness for a particular purpose are disclaimed. 32 / In no event shall the Intel Corporation or contributors be liable for any direct, 33 / indirect, incidental, special, exemplary, or consequential damages 34 / (including, but not limited to, procurement of substitute goods or services; 35 / loss of use, data, or profits; or business interruption) however caused 36 / and on any theory of liability, whether in contract, strict liability, 37 / or tort (including negligence or otherwise) arising in any way out of 38 / the use of this software, even if advised of the possibility of such damage. 39 / 40 /M*/ 41 #include “_cv.h“ 42 43 44 CV_IMPL CvRect 45 cvMaxRect( const CvRect* rect1, const CvRect* rect2 ) 46 47 if( rect1 50 int a, b; 51 52 max_rect.x = a = rect1-x; 53 b = rect2-x; 54 if( max_rect.x b ) 55 max_rect.x = b; 56 57 max_rect.width = a += rect1-width; Line 58 b += rect2-width; 59 60 if( max_rect.width y; 65 b = rect2-y; 66 if( max_rect.y b ) 67 max_rect.y = b; 68 69 max_rect.height = a += rect1-height; 70 b += rect2-height; 71 72 if( max_rect.height pt; 133 CvPoint2D32f dst = cvSubdiv2DEdgeDst( edge )-pt; 134 135 double a = dst.x - org.x; Line 136 double b = dst.y - org.y; 137 double c = -(a * (dst.x + org.x) + b * (dst.y + org.y); 138 139 *_a = a + a; 140 *_b = b + b; 141 *_c = c; 142 143 144 145 void 146 icvIntersectLines3( double *a0, double *b0, double *c0, 147 double *a1, double *b1, double *c1, CvPoint2D32f * point ) 148 149 double det = a00 * b10 - a10 * b00; 150 151 if( det != 0 ) 152 153 det = 1. / det; 154 point-x = (float) (b00 * c10 - b10 * c00) * det); 155 point-y = (float) (a10 * c00 - a00 * c10) * det); 156 157 else 158 159 point-x = point-y = FLT_MAX; 160 161 162 163 164 CV_IMPL double 165 cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist ) 166 167 double result = 0; 168 CV_FUNCNAME( “cvCheckPointPolygo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 天车大修施工方案
- 2025-2030年中国福辛普利片行业市场深度分析及市场需求与投资价值研究报告
- 2025-2030年中国磁力加热搅拌器行业市场现状供需分析及投资评估规划分析研究报告
- 圆形窗户施工方案
- 2025-2030年中国石化安防行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国真空吸水机行业深度分析及发展趋势与投资战略研究报告
- 2025-2030年中国电视机行业市场深度发展趋势与前景展望战略研究报告
- 2025-2030年中国电离辐射灭菌设备行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国电子纸行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030年中国电动和混合动力飞机推进系统行业市场现状供需分析及投资评估规划分析研究报告
- 车险理赔重大案管理办法
- 牙科市场细分领域分析-洞察分析
- 第16课《经济危机与资本主义国家的应对》中职高一下学期高教版(2023)世界历史全一册
- 货运车队的管理制度模版(2篇)
- 2024年贵州省贵阳市中考生物试卷(附答案)
- 《威尼斯商人》课本剧剧本:一场人性与金钱的较量(6篇)
- 管道、阀门安装方案
- 旅游业游客满意度调查与管理制度
- 2024年公路水运工程试验检测师《道路工程》考试题库大全(含真题等)-中(多选题)
- 喷绘设备买卖合同三篇
- 四年级语文下册 第19课《小英雄雨来》同步训练题(含答案)(部编版)
评论
0/150
提交评论