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 ...
随机推荐
- django orm介绍以及字段和参数
Object Relational Mapping (ORM) orm介绍 orm概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数 ...
- [PAT] A1019 General Palindromic Number
[题目] https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984 题目大意:给定一个N和b,求N在b ...
- NC反弹shell的几种方法
假如ubuntu.CentOS为目标服务器系统 kali为攻击者的系统,ip为:192.168.0.4,开放7777端口且没被占用 最终是将ubuntu.CentOS的shell反弹到kali上 正向 ...
- Agri-Net POJ - 1258 prim
#include<iostream> #include<cstdio> #include<cstring> using namespace std; ; #defi ...
- 小白的java学习之路 “ 字符串”
定一个字符串可以使用string类和stringbuffer类. string类提供了大量的操作字符串的方法,常用的如下: 获得字符串的长度: length(). 比较字符串:equals(). 链接 ...
- C++中public、protected、private的区别(转载)
转载:https://blog.csdn.net/vanturman/article/details/79393317 首先记住一点:派生类能且只能访问基类的public和protected成员! ...
- .NetCore学习笔记:一、UnitOfWork工作单元
Maintains a list of objects affected by a business transaction and coordinates the writing out of ch ...
- Dubbo-服务注册中心之AbstractRegistryFactory等源码
在上文中介绍了基础类AbstractRegistry类的解释,在本篇中将继续介绍该包下的其他类. FailbackRegistry 该类继承了AbstractRegistry,AbstractRegi ...
- 直观获取redis cluster 主从关系
需求:还是redis-trib.rb脚本获取的信息不足或者太繁杂,这里给出更加直观的一种方法, 说明:已在4.x版本测试通过,3.x不可用. 原生的输出 (1adfa7f3...) keys slot ...
- Wannafly Camp 2020 Day 1I K小数查询 - 分块
给你一个长度为\(n\)序列\(A\),有\(m\)个操作,操作分为两种: 输入\(x,y,c\),表示对\(i\in[x,y]\),令\(A_{i}=min(A_{i},c)\) 输入\(x,y,k ...