自适应阈值

 #include "StdAfx.h"   
#include      
#include      
#include      
int main()    
{    
    IplImage* Igray = cvLoadImage( "lena.jpg", CV_LOAD_IMAGE_GRAYSCALE);    
    IplImage* It = cvCreateImage(cvSize(Igray->width, Igray->height),IPL_DEPTH_8U, 1);  
    IplImage* Iat = cvCreateImage(cvSize(Igray->width, Igray->height),IPL_DEPTH_8U, 1);
    cvThreshold(Igray, It, 65, 255,CV_THRESH_BINARY_INV);    
    cvAdaptiveThreshold(Igray, Iat, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY_INV, 3, 5);  
    cvNamedWindow("orignal", 1);    
    cvNamedWindow("threshold", 1);    
    cvNamedWindow("adaptiveThresh", 1);    
    cvShowImage("orignal", Igray);    
    cvShowImage("threshold", It);    
    cvShowImage("adaptiveThresh", Iat);    
    cvWaitKey(0);    
    cvReleaseImage(&Igray);    
    cvReleaseImage(&It);    
    cvReleaseImage(&Iat);    
    cvDestroyWindow("orignal");    
    cvDestroyWindow("threshold");    
    cvDestroyWindow("adaptiveThresh");   
    return 0;
    

你可能感兴趣的:(OpenCV)