Java-POJ1009-Edge Detection(未完成,有C++代码)
RLE编码,还不会,先搬运一下大佬的代码,理解之后再用Java自己实现
#include <map>
#include <vector>
#include <cstdlib>
#include <iostream>
using namespace std;
static int around[][]= {{-,-},{-,},{-,},{,-},{,},{,-},{,},{,}};
map<int,int>::iterator a_It,b_It;
map<int,int> a,b;
vector<int> s;
int getValue(int index) {
int value=;
for(a_It = a.begin(); a_It != a.end(); a_It++) {
if(index<a_It->first) break;
value=a_It->second;
}
return value;
}
int getMax(int index,int width,int count) {
int center=getValue(index);
int h=index/width;
int max=;
for(int i=; i<; i++) {
int sub=index+around[i][]*width+around[i][];
if(h+around[i][]==sub/width && sub>= && sub<count) {
int a=getValue(sub);
max=abs(center-a)>max?abs(center-a):max;
}
}
return max;
}
void process(int width,int count) {
for(int i=; i < s.size(); i++) {
int index=s.at(i);
b.insert(pair<int,int>(index,getMax(index,width,count)));
}
}
int main() {
int width;
while(cin>>width && cout<<width<<endl && width) {
a.clear(),b.clear(),s.clear();
int v,l,count=;
while(cin>>v>>l && l) { //v有可能为0
a.insert(pair<int,int>(count,v));
count+=l;
}
for(a_It = a.begin(); a_It != a.end(); a_It++) {
for(int i=-; i<; i++) {
for(int j=-; j<; j++) {
int index=a_It->first+i*width+j;
if(index>= && index <count)
s.push_back(index);
}
}
}
s.push_back(width);
s.push_back(count-width);
process(width,count); b_It = b.begin();
int s=b_It->first;
int val=b_It->second;
b_It++;
for(; b_It != b.end(); b_It++) {
if(b_It->second != val) {
cout<<val<<" "<<b_It->first-s<<endl;
s=b_It->first;
val=b_It->second;
}
}
cout<<val<<" "<<count-s<<endl;
cout<<"0 0"<<endl;
}
return ;
}
Java-POJ1009-Edge Detection(未完成,有C++代码)的更多相关文章
- POJ1009 Edge Detection
题目来源:http://poj.org/problem?id=1009 题目大意: 某图像公司用run length encoding(RLE)的方式记录和存储了大量的图像.程序的目标是读入压缩后的图 ...
- 计算机视觉中的边缘检测Edge Detection in Computer Vision
计算机视觉中的边缘检测 边缘检测是计算机视觉中最重要的概念之一.这是一个很直观的概念,在一个图像上运行图像检测应该只输出边缘,与素描比较相似.我的目标不仅是清晰地解释边缘检测是怎样工作的,同时也提 ...
- 【数字图像分析】基于Python实现 Canny Edge Detection(Canny 边缘检测算法)
Canny 边缘检测算法 Steps: 高斯滤波平滑 计算梯度大小和方向 非极大值抑制 双阈值检测和连接 代码结构: Canny Edge Detection | Gaussian_Smoothing ...
- Image Processing and Analysis_8_Edge Detection:Edge Detection Revisited ——2004
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...
- Edge Detection
Edge Detection Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22604 Accepted: 5311 ...
- 轮廓检测论文解读 | Richer Convolutional Features for Edge Detection | CVPR | 2017
有什么问题可以加作者微信讨论,cyx645016617 上千人的粉丝群已经成立,氛围超好.为大家提供一个遇到问题有可能得到答案的平台. 0 概述 论文名称:"Richer Convoluti ...
- Edge detection using LoG
intensity梯度值分布跟图片的大小有关, 比如将一张小图片放大后会变得很模糊, 原先清晰的edge, 即大的梯度值变得模糊. 但是原有的边缘通常还是肉眼可分辨的. 但用Sobel 算子可能就检测 ...
- Java中替换HTML标签的方法代码
这篇文章主要介绍了Java中替换HTML标签的方法代码,需要的朋友可以参考下 replaceAll("\\&[a-zA-Z]{0,9};", "").r ...
- java mail实现Email的发送,完整代码
java mail实现Email的发送,完整代码 1.对应用程序配置邮件会话 首先, 导入jar <dependencies> <dependency> <groupId ...
随机推荐
- 七月在线spark教程
链接:https://pan.baidu.com/s/1Ir5GMuDqJQBmSavHC-hDgQ 提取码:qd2e
- 递归查询 start with connect by prior
1.语法:start with 子节点ID='...' connect by prior 子节点ID = 父节点ID 含义:查询结果我所有的后代节点(包括我) 例子: select id,parent ...
- Pair类模板
>Pair的实现是一个结构体而不是一个类< 1.标准头文件 #include<utility> 似乎无需引入该文件,在std命名空间内也有pair类型 2.格式为:templa ...
- iPad成为Windows系统的第二屏幕
一.Windows端软件准备 1.Splashtop Wired XDisplay Agent (官网下载 快速下载) 2.iTunes (点击此处跳转至微软应用商店) 二.iPad端软件准 ...
- SpringBoot之Configuration
在SpringBoot中可以通过@Configuration对某个类注解将该类申明为配置类,以此在代替先前spring版本中配置xml中的功能,并且增加了可读性与维护性.并且在注解类中的类方法中可 ...
- Educational Codeforces Round 65 (Rated for Div. 2)B. Lost Numbers(交互)
This is an interactive problem. Remember to flush your output while communicating with the testing p ...
- Python元组详解
元组的特征 元组类型的名字是tuple 元组的一级元素不可被修改.不能增加或者删除: 元组和列表的书写区别是将中括号改成了小括号: 为方便区分元组和普通方法的参数,一般在元组的最后一个元素后保持加一个 ...
- gazebo仿真踩坑--rviz中设定机器人的目标位置,move_base后台日志报错
启动仿真环境及各种节点(amcl,move_base,map_server)后,在rviz中设定机器人的目标位置,后台日志报错 [ INFO] [1571974242.864525935, 40.51 ...
- Wannafly Camp 2020 Day 1H 最大公约数 - 质因数分解,高精度
把每个质因子扒出来乱搞一下 #include <bits/stdc++.h> using namespace std; int g[505][505]; int isp[505]; str ...
- dataTables插件的使用
用到dataTables这个插件还是因为Metronic这个框架里有用到,不然我不会选择它的,为啥呢?就感觉它的文档有点复杂(当然,也有我智商不够用的原因):既然用了,那就说说我遇到的问题吧,以防下次 ...