poj1009 Edge Detection

给一个n * m的矩阵(n * m ≤ 1e9, m ≤ 1e9)A, 求矩阵A‘。

定义A‘(i, j) = max(abs(A(i, j) - A(u, v))), 其中(u, v)在矩阵内同时在以(i, j)为中心的九宫格范围内。

考虑到矩阵大小,当然不是按照传统方式呈现矩阵,而是用一种流程编码(RLE)的编码方式表示。

编码方式题目已经交代的很清楚了。

看似很棘手的一个题目,对于如此大的数据量感觉似乎无从下手。

注意到题目说明pair数不会超过1e3。

也就是说,相连的重复数字是很多的,这是本题能够被解决的先决条件。

我们定义A(i, j)的位置是(i * width + j)(i, j从0开始)。

我们定义当前pair(i)的最小位置为f(i)。

如果能够知道A中所有pair的f值,答案即可得到。

然而准确找到所有pair的位置(不重不漏)是困难的,但是找到它们出现的可能位置(允许冗余)则是可行的。

我们断言:A中所有pair的f值对应的位置(简记为突变位置)一定在以A中某个突变位置为中心的九宫格范围内。

画图易得反证,此略过。

这样我们找到所有伪命中点最后再处理一下(去重)就行了,具体实现见代码。

http://poj.org/problem?id=1009

时间: 2024-08-27 15:06:15

poj1009 Edge Detection的相关文章

POJ 1009 Edge Detection

Edge Detection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22153   Accepted: 5201 Description IONU Satellite Imaging, Inc. records and stores very large images using run length encoding. You are to write a program that reads a compre

【数字图像分析】基于Python实现 Canny Edge Detection(Canny 边缘检测算法)

import numpy as np import cv2 import argparse from Computer_Vision.Canny_Edge_Detection.sobel import sobel_edge_detection from Computer_Vision.Canny_Edge_Detection.gaussian_smoothing import gaussian_blur import matplotlib.pyplot as plt def non_max_su

edge box

先介绍一下matlab与c混合编程 主要步骤: 使用c语言编写函数 利用mexFunction()函数创建C与matlab接口 从Matlab中编译函数 # include <mex.h>: 为了实现matlab与c混合编程的接口 //例如实现一个 add函数在接口 #include "mex.h" double add(double x, double y) { return x+y; } 这个代码是算法真正实现的地方. 然后创建接口.mex函数库中的mexFunctio

[OpenCV] Samples 08: edge

Canny edge detector 效率高,效果可控. TrackBar的使用. 技巧:gray找边缘后作为mask去CopyTo(). #include "opencv2/core/utility.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/imgcodecs.hpp" #include "opencv2/highgui.hpp" #include <

What makes for effective detection proposals? 论文解析

1 介绍(INTRODUCTION) 本文主要对最近的 proposal 检测方法做一个总结和评价.主要是下面这些方法.  2 Detection Proposal 方法(DETECTION PROPOSAL METHODS) 作者将 Detection Proposal 分为两类,grouping method (将图片分为碎片,最后聚合)和 window scoring method (对分成的大量窗口打分). 2.1 分组 proposal 方法(Grouping proposal met

POJ 1009

Edge Detection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18826   Accepted: 4359 Description IONU Satellite Imaging, Inc. records and stores very large images using run length encoding. You are to write a program that reads a compre

caffe框架下目标检测——faster-rcnn实战篇操作

原有模型 1.下载fasrer-rcnn源代码并安装 git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git 1)  经常断的话,可以采取两步: git clone https://github.com/rbgirshick/py-faster-rcnn.git 2)  到py-faster-rcnn中,继续下载caffe-faster-rcnn,采取后台跑: git submodule update --in

Scale Space(zz Wiki)

Scale space From Wikipedia, the free encyclopedia Scale space Scale-space axioms Scale-space implementation Feature detection Edge detection Blob detection Corner detection Ridge detection Interest point detection Scale selection Affine shape adaptat

Canny边缘检测算法原理及C语言实现详解(原创码字)

Canny算子是John Canny在1986年提出的,那年老大爷才28岁,该文章发表在PAMI顶级期刊上的(1986. A computational approach to edge detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 8, 1986, pp. 679-698).老大爷目前在加州伯克利做machine learning,80-90年代视觉都是图像处理,现在做视觉都是机器