扩充方法
在进行卷积神经网络计算时,很多情况下我们无法获得足够的数据,可以通过人工数据合成的方法进行扩充.本人的扩充方法如下:
具体为将原图像分别水平,竖直和水平竖直翻转扩充至原来的4倍;然后对获得图像分别-30°,-15°,15°,30°进行旋转扩充至原来的20倍;然后随机添加高斯噪声扩充至原来的40倍.
运行环境:QT+C+++OPENCV
代码
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
void Resize(int i,cv::Mat image1);
void imageRotate(const cv::Mat &src, double degree, const double scale,int i, float height, float width );
double generateGaussianNoise(double mu, double sigma);
Mat addGaussianNoise(Mat &srcImag,int i);
int main()
{
//用void glob(String pattern, std::vector<String>& result, bool recursive = false);当recursive为false时,仅仅遍历指定文件夹内符合模式的文件,当recursive为true时,会同时遍历指定文件夹的子文件夹
//pattern要绝对路径 其它测试有问题
string pattern ="/home/li/shijuejiance/sample/train/