OpenCV图象大小调整cvEqualizeHist灰度调整

#include <stdio.h>
#include <cv.h>
#include <highgui.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdlib.h>
#include <dos.h> 

#pragma comment(lib, "cv.lib")
#pragma comment(lib, "cxcore.lib")
#pragma comment(lib, "highgui.lib")

int main(int argc, char* argv[])
{
	char bmp[10] = ".bmp";
	int i = 0;
	char num[10];
	IplImage *src = 0;			//源图像指针
	IplImage *dst = 0;			//目标图像指针
	IplImage* dstGray;
	CvSize dst_cvsize;			//目标图像尺寸

	dst_cvsize.width = 24;		//目标图像的宽为24
	dst_cvsize.height = 24;		//目标图像的高24

	int len = 100;
	int read;

	while (1) 
	{
		///////////////////////////////////////////读取文件

		char srcPath[100] = ".\\";
		char dstpath[100] = ".\\";

		itoa(i,num,10);
		strcpy(srcPath + strlen(srcPath), num);
		strcpy(srcPath + strlen(srcPath), bmp);
		srcPath[strlen(srcPath)] = '\0';
		printf("%s",srcPath);

		src = cvLoadImage(srcPath,CV_LOAD_IMAGE_GRAYSCALE); 

		if(src == NULL)
		{
			printf("%s,没有找到图片",srcPath);
			break;
		}
		cvEqualizeHist(src,src);//使灰度图象直方图均衡化。归一化图像亮度和增强对比度

		strcpy(dstpath + strlen(dstpath), num);
		strcpy(dstpath + strlen(dstpath), bmp);
		dst = cvCreateImage( dst_cvsize, src->depth, 1);	//构造目标图象
		cvResize(src, dst, CV_INTER_LINEAR);	//缩放源图像到目标图像
		cvSaveImage(dstpath,dst);
		i++;
	}
	cvReleaseImage(&src);	//释放源图像占用的内存
	cvReleaseImage(&dst);	//释放目标图像占用的内存

	printf("图片转化完成!!!");
	getchar();
	return 0;
}

你可能感兴趣的:(OpenCV图象大小调整cvEqualizeHist灰度调整)