首页
IT
登录
6mi
u
盘
搜
搜 索
IT
opencv图像归一化大小
opencv图像归一化大小
xiaoxiao
2021-03-25
107
在进行简单的人脸训练时候,遇到人脸库的图像像素大小不一样,所以用了这个简单的操作,将图片大小归一化。
#include <iostream> #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#define NORM_WIDTH 230 //归一化后的宽和高 #define NORM_HEIGHT 230
using namespace std; using namespace cv;
int main(void) {
Mat src_img; int i; char chari[10];
for(i=10; i<=10; i++) {
string imgSrcPath = "s1/"; //原始图片路径 string imgSavePath = "s2/"; //图片最后保存路径 sprintf(chari, "%d", i); imgSrcPath += chari; imgSrcPath += ".pgm";
src_img = imread(imgSrcPath, 1); Mat dst_img_rsize(NORM_WIDTH, NORM_HEIGHT, src_img.type()); resize(src_img, dst_img_rsize, dst_img_rsize.size(), 0, 0, INTER_LINEAR);
imgSavePath += chari; imgSavePath += ".pgm"; imwrite(imgSavePath, dst_img_rsize);
} return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-14243.html
技术
最新回复
(
0
)