资源简介
基于criminisi算法的图像修复,采用的工具是matlab,修复速度较慢,可直接运行

代码片段和文件信息
/*
* A best exemplar finder. Scans over the entire image (using a
* sliding window) and finds the exemplar which minimizes the sum
* squared error (SSE) over the to-be-filled pixels in the target
* patch.
*
* @author Sooraj Bhat
*/
#include “mex.h“
#include
#include “matrix.h“
void bestexemplarhelper(const int mm const int nn const int m const int n
const double *img const double *Ip
const mxLogical *toFill const mxLogical *sourceRegion
double *best)
{
register int ijiijjii2jj2MNIJndxndx2mn=m*nmmnn=mm*nn;
double patchErr=0.0err=0.0bestErr=1000000000.0;
/* foreach patch */
N=nn-n+1; M=mm-m+1;
for (j=1; j<=N; ++j)
{
J=j+n-1;
for (i=1; i<=M; ++i)
{
I=i+m-1;
/*** Calculate patch error ***/
/* foreach pixel in the current patch */
for (jj=jjj2=1; jj<=J; ++jj++jj2)
{
for (ii=iii2=1; ii<=I; ++ii++ii2)
{
ndx=ii-1+mm*(jj-1);
if (!sourceRegion[ndx])
goto skipPatch;
ndx2=ii2-1+m*(jj2-1);
if (!toFill[ndx2])
{
err=img[ndx ] - Ip[ndx2 ]; patchErr += err*err;
err=img[ndx+=mmnn] - Ip[ndx2+=mn]; patchErr += err*err;
err=img[ndx+=mmnn] - Ip[ndx2+=mn]; patchErr += err*err;
}
}
}
/*** Update ***/
if (patchErr < bestErr)
{
bestErr = patchErr;
best[0] = i; best[1] = I;
best[2] = j; best[3] = J;
}
/*** Reset ***/
skipPatch:
patchErr = 0.0;
}
}
}
/* best = bestexemplarhelper(mmnnmnimgIptoFillsourceRegion); */
void mexFunction(int nlhsmxArray *plhs[]int nrhsconst mxArray *prhs[])
{
int mmnnmn;
double *img*Ip*best;
mxLogical *toFill*sourceRegion;
/* Extract the inputs */
mm = (int)mxGetScalar(prhs[0]);/*The value of the first real (nonimaginary) element of the mxArray.*/
nn = (int)mxGetScalar(prhs[1]);
m = (int)mxGetScalar(prhs[2]);
n = (int)mxGetScalar(prhs[3]);
img = mxGetPr(prhs[4]);/*The address of the first element of the real data*/
Ip = mxGetPr(prhs[5]);
toFill = mxGetLogicals(prhs[6]);/*mxGetLogicals()The address of the first logical element in the mxArray. The result is unspecified if the mxArray is not a logical array.*/
sourceRegion = mxGetLogicals(prhs[7]);
/* Setup the output */
plhs[0] = mxCreateDoubleMatrix(41mxREAL);
best = mxGetPr(plhs[0]);
best[0]=best[1]=best[2]=best[3]=0.0;
/* Do the actual work */
bestexemplarhelper(mmnnmnimgIptoFillsourceRegionbest);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-05-20 22:34 Criminisi\
文件 162139 2015-03-26 10:20 Criminisi\20.png
文件 136031 2015-03-26 10:20 Criminisi\201.png
文件 293 2015-04-30 21:37 Criminisi\Evaluate.m
文件 1063 2004-11-29 23:04 Criminisi\README.txt
文件 37938 2015-03-29 20:15 Criminisi\benggee_7.jpg
文件 2382 2015-04-06 14:14 Criminisi\bestexemplarhelper.asv
文件 2503 2015-04-30 11:56 Criminisi\bestexemplarhelper.c
文件 8536 2013-03-12 13:12 Criminisi\bestexemplarhelper.mexmaci64
文件 6656 2015-03-26 10:46 Criminisi\bestexemplarhelper.mexw32
文件 11264 2019-05-20 22:30 Criminisi\bestexemplarhelper.mexw64
文件 8928 2015-05-03 23:49 Criminisi\inpaint7.m
文件 506 2019-05-20 22:34 Criminisi\plotall.m
相关资源
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
评论
共有 条评论