opencv彩色三通道图片反色,转换mnist使用,有疑问请联系
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-06-01 17:08 testImgColorInv
目录 0 2018-05-31 21:58 testImgColorInvcode
目录 0 2018-06-01 17:17 testImgColorInvcode estImgColorInv
目录 0 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug
文件 71680 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug estImgColorInv.exe
文件 384328 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug estImgColorInv.ilk
文件 1822720 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug estImgColorInv.pdb
目录 0 2018-06-01 17:15 testImgColorInvcode estImgColorInv estImgColorInv
目录 0 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug
文件 241775 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebugmain.obj
文件 2498 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.log
目录 0 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlog
文件 28106 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogCL.read.1.tlog
文件 716 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogCL.write.1.tlog
文件 768 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogcl.command.1.tlog
文件 3024 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tloglink.command.1.tlog
文件 7496 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tloglink.read.1.tlog
文件 694 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tloglink.write.1.tlog
文件 191 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlog estImgColorInv.lastbuildstate
文件 1018880 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebugvc120.idb
文件 1421312 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebugvc120.pdb
目录 0 2018-05-31 21:54 testImgColorInvcode estImgColorInv estImgColorInvimage
文件 795 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00001.jpg
文件 791 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00002.jpg
文件 879 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00003.jpg
文件 880 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00004.jpg
文件 801 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00005.jpg
文件 768 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00006.jpg
文件 910 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00007.jpg
文件 818 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00008.jpg
文件 880 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00009.jpg
............此处省略617个文件信息
#include
#include
#include
#include
using namespace std;
using namespace cv;
void main()
{
Directory dir;
string inPathfileDirectory = “E:\vs2013\highschool\testImgColorInv\code\testImgColorInv\testImgColorInv\image\“;//读取指定的文件路径
string outPathfileDirectory = “E:\vs2013\highschool\testImgColorInv\code\testImgColorInv\testImgColorInv\resultImg\“;//存储指定的文件路径
string fileType = “*.jpg“;//原始图片为jpg格式
string completePath;//图片完整路径
Mat srcImg dstImg;
vector filenames = dir.GetListFiles(inPathfileDirectory fileType false);
string outFileNamesFileType;
int size = filenames.size();
for (int i = 0; i < size; i++)
{
completePath = inPathfileDirectory + filenames[i];
srcImg = imread(completePath);
if (!srcImg.data){
cout << “图像载入失败“ << endl;
return;
}
int rows = srcImg.rows;
int cols = srcImg.cols;
dstImg.create(srcImg.size() srcImg.type());
//遍历
for (int row = 0; row for (int col = 0; col int b = srcImg.at(row col)[0];//一共3通道
int g = srcImg.at(row col)[1];
int r = srcImg.at(row col)[2];
dstImg.at(row col)[0] = 255 - b;//取反
dstImg.at(row col)[1] = 255 - g;
dstImg.at(row col)[2] = 255 - r;
}
}
outFileNamesFileType = filenames[i];
outFileNamesFileType[8] = ‘p‘;//jpg转png.字符串第9,10,11位对应jpg因命名规则为0_00001.jpg
outFileNamesFileType[9] = ‘n‘;
outFileNamesFileType[10] = ‘g‘;
imwrite(outPathfileDirectory + outFileNamesFileType dstImg);//写入当前文件
cout << “第“ << i + 1 << “张图片转换成功“ << endl;
waitKey(0);
}
cout << “转换完成“ << endl;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-06-01 17:08 testImgColorInv
目录 0 2018-05-31 21:58 testImgColorInvcode
目录 0 2018-06-01 17:17 testImgColorInvcode estImgColorInv
目录 0 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug
文件 71680 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug estImgColorInv.exe
文件 384328 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug estImgColorInv.ilk
文件 1822720 2018-05-31 22:09 testImgColorInvcode estImgColorInvDebug estImgColorInv.pdb
目录 0 2018-06-01 17:15 testImgColorInvcode estImgColorInv estImgColorInv
目录 0 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug
文件 241775 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebugmain.obj
文件 2498 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.log
目录 0 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlog
文件 28106 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogCL.read.1.tlog
文件 716 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogCL.write.1.tlog
文件 768 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogcl.command.1.tlog
文件 3024 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogli
文件 7496 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogli
文件 694 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlogli
文件 191 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebug estImgColorInv.tlog estImgColorInv.lastbuildstate
文件 1018880 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebugvc120.idb
文件 1421312 2018-05-31 22:09 testImgColorInvcode estImgColorInv estImgColorInvDebugvc120.pdb
目录 0 2018-05-31 21:54 testImgColorInvcode estImgColorInv estImgColorInvimage
文件 795 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00001.jpg
文件 791 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00002.jpg
文件 879 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00003.jpg
文件 880 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00004.jpg
文件 801 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00005.jpg
文件 768 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00006.jpg
文件 910 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00007.jpg
文件 818 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00008.jpg
文件 880 2018-05-21 21:14 testImgColorInvcode estImgColorInv estImgColorInvimage _00009.jpg
............此处省略617个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)