有一个提取图像直线的程序,好不容易编译过了,发现只可以处理宽度为64的倍数的bmp图片,因此写了一个将某个目录下的所有tif文件的宽度修改为64的倍数(最接近原始宽度)的数值,然后另存为bmp的程序。
1、修改图像大小只需要用函数cvResize(srcColorImage,dstColorImage,CV_INTER_CUBIC);
2、另存为图像只要用函数cvSaveImage(outputfileName.c_str(),dstColorImage);至于存储的类型,只要把后缀名定义好就直接存储为后缀名指定的类型了
该功能的源代码如下:
#include
"stdafx.h"
#include <stdio.h >
#include <afx.h >
#include <Windows.h >
#include "opencv\highgui.h"
#include "opencv\cxcore.h"
#include "opencv\cv.h"
#include <iostream >
#include <fstream >
#include <iomanip >
#include <vector >
#include <math.h >
using namespace std ;
using namespace cv ;
#define LEN 1024
int main ( int argc , char * argv [])
{
char * Path = "E:\\Documents\\KT\\居民地提取\\line\\ExtractStraightLine\\HoughOpenCV\\onepic" ;
#include <stdio.h >
#include <afx.h >
#include <Windows.h >
#include "opencv\highgui.h"
#include "opencv\cxcore.h"
#include "opencv\cv.h"
#include <iostream >
#include <fstream >
#include <iomanip >
#include <vector >
#include <math.h >
using namespace std ;
using namespace cv ;
#define LEN 1024
int main ( int argc , char * argv [])
{
char * Path = "E:\\Documents\\KT\\居民地提取\\line\\ExtractStraightLine\\HoughOpenCV\\onepic" ;