测试图片:
代码:
#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
IplImage * pImg=cvLoadImage("c://test.jpg",0);
cvNamedWindow("ShowImage",1);
cvNamedWindow("result",1);
cvNamedWindow("result_h",1);
CvScalar s,t;
cvSmooth( pImg, pImg, CV_BLUR, 3, 3, 0, 0 );
cvThreshold( pImg, pImg ,50, 255, CV_THRESH_BINARY_INV ); //取阀值为
50 把图像转为二值图像
int* v=new int[pImg->width];
int* h=new int[pImg->height];
for(int i=0;i<pImg->width;i++)
v[i]=0;
for(int i=0;i<pImg->height;i++)
h[i]=0;