#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
# include <stdlib.h>
#include <ctype.h>
#include <stdlib.h>
#include <dos.h>
int _tmain(int argc, _TCHAR* 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] = "F:\\分类器\\图图\\negtive\\";
char dstpath[100] = "F:\\分类器\\图图\\negtive\\Resize\\";
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;
}
Resize your images
最新推荐文章于 2024-11-03 19:03:28 发布