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 ...
随机推荐
- 【spring boot】SpringBoot初学(5)– WebService之Jersey
前言 github: https://github.com/vergilyn/SpringBootDemo 代码位置: 一.准备 spring boot对jersey1.x与jersey2.x的注入方 ...
- JavaDay9(下)
Java learning_Day9(下) 本人学习视频用的是马士兵的,也在这里献上 <链接:https://pan.baidu.com/s/1qKNGJNh0GgvlJnitTJGqgA> ...
- c#在类里不能使用Response解决方法
response对应的类是HttpResponse, 在System.Web 命名字间里, 如果你在类中要使用 Response 的话, 需要使用System.Web.HttpConte ...
- Oracle 12c 如何在 PDB 中添加 SCOTT 模式(数据泵方式)
Oracle 12c 建库后,没有 scott 模式,本篇使用数据泵方式,在12c版本之前数据库中 expdp 导出 scott 模式,并连接 12c 的 pdb 进行 impdp 导入. 目录 1. ...
- java学习笔记之IO编程—File文件操作类
1. File类说明 在Java语言里面提供有对于文件操作系统操作的支持,而这个支持就在java.io.File类中进行了定义,也就是说在整个java.io包里面,File类是唯一一个与文件本身操作( ...
- 自定义React-redux
实现mini版react-redux 1. 理解react-redux模块 1). react-redux模块整体是一个对象模块 2). 包含2个重要属性: Provider和connect 3). ...
- JS中axios使用注意点
今天遇到这样一个问题,前端会同时弹出成功和失败的两个提示框,由于不是本人操作,也没有怀疑是前端代码的问题,就索性根据后端的日志作为分析依据,开始个人以为是后端接口上班了两次结果,一个是成功,另外一个是 ...
- Linux的常用命令---这是对Linux最基本的尊重
Linux: 诞生日期:1991年 开发者:林纳斯·托瓦茨 特点:免费,开源 发行版本:centos|red Hat|Ubuntu|红旗等 思想:一切都是文件 重要文件目录 bin:二进制文件(命令) ...
- vjudge 骨牌覆盖
原题链接:https://vjudge.net/contest/331993#problem/B 在2*N的一个长方形方格中,用一个1*2的骨牌排满方格. 问有多少种不同的排列方法. 例如:2 * 3 ...
- vjudge A Funny Game 思维题 (其实今天讲的全是数学。。。)
原文链接https://vjudge.net/contest/331993#problem/H Alice and Bob decide to play a funny game. At the be ...