例5-4 Compare thresholding with adaptive thresholding

来源:互联网 发布:航空业行业数据 编辑:程序博客网 时间:2024/06/14 21:23

#include "cv.h"#include "highgui.h"#include "math.h"IplImage* Igray =NULL;IplImage* It = NULL;IplImage* Iat;int main(){ double threshold = 100; int threshold_type = 1 ? CV_THRESH_BINARY :CV_THRESH_BINARY_INV; int adaptive_method = 1 ?CV_ADAPTIVE_THRESH_MEAN_C : CV_ADAPTIVE_THRESH_GAUSSIAN_C; int block_size = 3; double offset = 5; if((Igray =cvLoadImage("lena.bmp", CV_LOAD_IMAGE_GRAYSCALE)) == 0){  return -1; } It =cvCreateImage(cvSize(Igray->width,Igray->height), IPL_DEPTH_8U, 1); Iat =cvCreateImage(cvSize(Igray->width,Igray->height), IPL_DEPTH_8U, 1); cvThreshold(Igray, It,threshold, 255, threshold_type); cvAdaptiveThreshold(Igray, Iat, 255,adaptive_method, threshold_type, block_size, offset); cvNamedWindow("Raw",1); cvNamedWindow("Threshold", 1); cvNamedWindow("Adaptive Threshold",1); cvShowImage("Raw",Igray); cvShowImage("Threshold", It); cvShowImage("Adaptive Threshold",Iat); cvWaitKey(0); cvReleaseImage(&Igray); cvReleaseImage(&It); cvReleaseImage(&Iat); cvDestroyWindow("Raw"); cvDestroyWindow("Threshold"); cvDestroyWindow("Adaptive Threshold"); return0;}


例5-4 <wbr>Compare <wbr>thresholding <wbr>with <wbr>adaptive <wbr>thresholding

例5-4 <wbr>Compare <wbr>thresholding <wbr>with <wbr>adaptive <wbr>thresholding

例5-4 <wbr>Compare <wbr>thresholding <wbr>with <wbr>adaptive <wbr>thresholding

原创粉丝点击