HDOJ 3359 Kind of a Blur
用高斯消元对高斯模糊的图像还原....
Kind of a Blur
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1321 Accepted Submission(s): 383
topics in image processing. This process is called deblurring, which will be your task for this problem.
In this problem, all images are in grey-scale (no colours). Images are represented as a 2 dimensional matrix of real numbers, where each cell corresponds to the brightness of the corresponding pixel. Although not mathematically accurate, one way to describe
a blurred image is through averaging all the pixels that are within (less than or equal to) a certain Manhattan distance?
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.
<= min(W/2,H/2)). The remaining H lines specify the gray-level of each pixel in the blurred image. Each line specifies W non-negative real numbers given up to the 2nd decimal place. The value of all the given real numbers will be less than 100.
Zero or more lines (made entirely of white spaces) may appear between cases. The last line of the input file consists of three zeros.
test cases by an empty line. Do not print an empty line after the last test case. It is guaranteed that there is exactly one unique solution for every test case.
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;
}
HDOJ 3359 Kind of a Blur的更多相关文章
- hdu 3359 Kind of a Blur (高斯消元 浮点型)
题目链接 题意: H * W (W,H <= 10) 的矩阵A的某个元素A[i][j],从它出发到其他点的曼哈顿距离小于等于D的所有值的和S[i][j]除上可达点的数目,构成了矩阵B.给定矩阵B ...
- HDU 3359 Kind of a Blur(高斯消元)
题意: H * W (W,H <= 10) 的矩阵A的某个元素A[i][j],从它出发到其他点的曼哈顿距离小于等于D的所有值的和S[i][j]除上可达点的数目,构成了矩阵B.给定矩阵B,求矩阵A ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- 解决css3毛玻璃效果(blur)有白边问题
做一个登录页,全屏背景图毛玻璃效果,实现方法如下: HTML: <body> <div class="login-wrap"> <div class= ...
- js(jquery)解决input元素的blur事件和其他非表单元素的click事件冲突的方法
HTML结构:很简单,就一个input,一个div,能说明问题就OK了: <input type="text" value="默认值"><br ...
- blur和click事件的先后顺序问题
这两个同时用会有冲突.懒得翻译了,需要的自己看哈. 以下摘自stackoverflow. I have an input field, where I try to make autocomplete ...
- HDOJ 1004 Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
随机推荐
- json数据格式的简单案例
json数据是一种文本字符串,它是javascript的原生数据格式,在数据需要多次重复使用时,json数据是ajax请求的首先.(注:ajax返回的数据格式支持三种分别为:文本格式,json.和xm ...
- spring in action 学习笔记十四:用纯注解的方式实现spring mvc
在讲用纯注解的方式实现springmvc之前先介绍一个类:AbstractAnnotationDispatcherServletInitializer.这个类的作用是:任何一个类继承AbstractA ...
- Mysql事务隔离级
转自:http://xm-king.iteye.com/blog/770721 SQL标准定义了4类隔离级别,包括了一些具体规则,用来限定事务内外的哪些改变是可见的,哪些是不可见的.低级别的隔离级一般 ...
- 【IDEA】IDEA创建Maven的Web项目并运行以及打包
0.IDEA集成Maven并设置Maven的配置 idea15之后的版本,都自带了maven插件,idea14貌似需要自己安装,方法也很简单:File->Settings->Plugin ...
- Inline Hook
@author: dlive IAT Hook时如果要钩取的API不在IAT中(LoadLibrary后调用),则无法使用该技术.而Inline Hook不存在这个限制. 0x01 Inline Ho ...
- 【Cocos2D研究院之游戏开发】
http://www.xuanyusong.com/archives/category/ios/cocos2d_game 分类目录归档:[Cocos2D研究院之游戏开发] 201211-19 Co ...
- java使用BeanUtils封装file类型表单数据到一个对象中
package com.cc.web.servlet; import java.io.FileOutputStream; import java.io.IOException; import java ...
- ReportView控件的使用
ReportView控件的使用Posted on 2012-01-06 17:02 随遇 阅读(3006) 评论(0) 编辑 收藏 最近使用了ReportView控件绑定数据,总结下: 1.在设计器 ...
- 大牛教你如何循序渐进,有效的学习JavaScript?
首先要说明的是,咱现在不是高手,最多还是一个半桶水,算是入了JS的门.谈不上经验,都是一些教训. 这个时候有人要说,“靠,你丫半桶水,凭啥教我们”.您先别急着骂,先听我说! 你叫一个大学生去教小学数学 ...
- 将C#程序做成服务后服务自动停止的问题
查了好几天,没法调试实在是很难找错误,今天想了半天到事件查看器,提示如下: 说明: 由于未经处理的异常,进程终止. 异常信息: System.NullReferenceException 想了半天,应 ...