实际上,前面已经全部完成了,由于4倍图非常费内存,对于象我这样的只有2G内存的笔记本只能运行很小的图,特别是最后图像放大部分。
所以这里分成两种方法处理:
1。图像分成4块分别处理,然后合并
//把jpg分成4份分别重建 再合并
IMAGE pDstImg=jpg;
char name1[]="_1";
char name2[]="_2";
char name3[]="_3";
char name4[]="_4";
char *name[4];
name[0]=name1;
name[1]=name2;
name[2]=name3;
name[3]=name4;
for(int i=0;i<4;i++)
{
cout<<"4分之"<<i+1<<"开始... "<<endl;
jpg4分(pDstImg,i);
// SRResNet 高分辨率重建
SRResNet(name[i],sr);
}
//合并4分图
合并4分图(pDstImg,name);
输入图1234分图合并图
2。第二种,只在最后一步卷积处分成3步(实际上是分成3X64=192步,所以会慢一点,这个可参SRCCN部分)
//vl_nnconv(&中间4倍,&hR1,层 ,1,1,4,4,4,4);
//这里需要很大内存,这里分步 64-->3
*
{
卷积层 in(中间4倍.width,中间4倍.height),out(hR1.width,hR1.height),tt_out(hR1.width,hR1.height);
tt_out.data=new float[wid * hei * 16];
//float *in,*out,*f;
int wh_out=hR1.width*hR1.height;
int wh_in =中间4倍.width*中间4倍.height;
层数据 tc;
tc.核宽=9;
tc.输入维度=1;
tc.输出维度=1;
tc.偏移长度=0;
tc.权重长度=9*9;
tc.偏移_数据=NULL;
char txt[256];
for(int i=0;i<3;i++)
{
cout<<"3分之"<<i+1<<"..."<<endl;
out.data=hR1.data+wh_out*i;
for(int j=0;j<64;j++)
{
in.data=中间4倍.data+wh_in*j;
//sprintf(txt, "in%d", j);
//save_卷积层2jpg(&in,txt);
tc.权重_数据=层->权重_数据+81*j+64*81*i;//+81*i+81*3*j;//
vl_nnconv(&in,&tt_out,&tc ,1,1,4,4,4,4);
//sprintf(txt, "tt_out%d_%d", i,j);
//save_卷积层2jpg(&tt_out,txt);
卷积层相加(&tt_out,&out);
//sprintf(txt, "out%d_%d", i,j);
// save_卷积层2jpg(&out,txt);
}
}
//加上偏移
tf_BatchNorm(&hR1,层->偏移_数据);
}//*/
效果图:
原图4倍图
原图4倍图
注意:输入图应该是清晰的
清晰(小)-->清晰(大)
模糊(小)-->模糊(大)
下载(里面包括了上面的3个程序):
win32位编译的 超分辨率重建(SRGAN_generator)
win32位编译的 超分辨率重建(SRGAN_generator)的应用程序,使用了OpenBLAS加速,详细情况参看博客
https://download.csdn.net/download/juebai123/10797136
结束。