标签:specified ima esc cas guarantee ash set ever ems
用高斯消元对高斯模糊的图像还原....
from each pixel (including the pixel itself ). Here‘s an example of how to calculate the blurring of a 3x3 image with a blurring distance
of 1:
Given the blurred version of an image, we are interested in reconstructing the original version assuming that the image was blurred as explained above.
2 2 1 1 1 1 1 3 3 1 19 14 20 12 15 18 13 14 16 4 4 2 14 15 14 15 14 15 14 15 14 15 14 15 14 15 14 15 0 0 0
1.00 1.00 1.00 1.00 2.00 30.00 17.00 25.00 7.00 13.00 14.00 0.00 35.00 1.00 27.00 2.00 28.00 21.00 12.00 17.00 8.00 21.00 12.00 17.00 8.00 1.00 27.00 2.00 28.00HintThe Manhattan Distance (sometimes called the Taxicab distance) between two points is the sum of the (absolute) difference of their coordinates. The grid on the lower right illustrates the Manhattan distances from the grayed cell.
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const double eps=1e-8; const int maxn=130; double data[maxn/10][maxn/10],a[maxn][maxn],x[maxn]; int n,m,d; int equ,val; void Gauss() { int k,col,mar; for(k=0,col=0;k<equ&&col<val;k++,col++) { mar=k; for(int i=k+1;i<equ;i++) { if(fabs(a[i][col])>fabs(a[mar][col])) mar=i; } if(fabs(a[mar][col])<eps) return ; if(k!=mar) { for(int i=col;i<val;i++) swap(a[k][i],a[mar][i]); swap(x[k],x[mar]); } x[k]/=a[k][col]; for(int i=col+1;i<val;i++) a[k][i]/=a[k][col]; a[k][col]=1.; for(int i=0;i<equ;i++) { if(i==k) continue; x[i]-=x[k]*a[i][col]; for(int j=col+1;j<val;j++) a[i][j]-=a[k][j]*a[i][col]; a[i][col]=0; } } } int main() { bool fst=false; while(scanf("%d%d%d",&m,&n,&d)!=EOF) { if(n==0&&m==0) break; if(fst) putchar(10); else fst=true; memset(a,0,sizeof(a)); memset(x,0,sizeof(x)); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { scanf("%lf",&data[i][j]); int cnt=0; int t1=i*m+j,t2=0; for(int ii=0;ii<n;ii++) { for(int jj=0;jj<m;jj++) { if(abs(i-ii)+abs(j-jj)<=d) { t2=ii*m+jj; a[t2][t1]=1.; cnt++; } } } x[t1]=data[i][j]*cnt; } } equ=val=n*m; Gauss(); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { printf("%8.2lf",x[i*m+j]); } putchar(10); } } return 0; }
标签:specified ima esc cas guarantee ash set ever ems
原文地址:http://www.cnblogs.com/zhchoutai/p/6792018.html