Apollo
11.0
自动驾驶开放平台
convolve.h
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2019 The Apollo Authors. All Rights Reserved.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*****************************************************************************/
16
17
/*
18
Copyright (C) 2006 Pedro Felzenszwalb
19
This program is free software; you can redistribute it and/or modify
20
it under the terms of the GNU General Public License as published by
21
the Free Software Foundation; either version 2 of the License, or
22
(at your option) any later version.
23
This program is distributed in the hope that it will be useful,
24
but WITHOUT ANY WARRANTY; without even the implied warranty of
25
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
GNU General Public License for more details.
27
You should have received a copy of the GNU General Public License
28
along with this program; if not, write to the Free Software
29
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
*/
31
#pragma once
32
#include <algorithm>
33
#include <cmath>
34
#include <vector>
35
36
#include "
modules/perception/lidar_segmentation/segmentor/ncut_segmentation/common/graph_felzenszwalb/image.h
"
37
38
namespace
apollo
{
39
namespace
perception {
40
namespace
lidar {
41
49
void
convolve_even
(
Image<float>
*src,
Image<float>
*dst,
const
std::vector<float> &mask) {
50
int
width = src->
width
();
51
int
height = src->
height
();
52
int
len = mask.size();
53
for
(
int
y = 0; y < height; y++) {
54
for
(
int
x = 0; x < width; x++) {
55
float
sum = mask[0] *
imRef
(src, x, y);
56
for
(
int
i = 1; i < len; i++) {
57
sum += mask[i] * (
imRef
(src, std::max(x - i, 0), y) +
imRef
(src, std::min(x + i, width - 1), y));
58
}
59
imRef
(dst, y, x) = sum;
60
}
61
}
62
}
63
71
void
convolve_odd
(
Image<float>
*src,
Image<float>
*dst,
const
std::vector<float> &mask) {
72
int
width = src->
width
();
73
int
height = src->
height
();
74
int
len = mask.size();
75
for
(
int
y = 0; y < height; y++) {
76
for
(
int
x = 0; x < width; x++) {
77
float
sum = mask[0] *
imRef
(src, x, y);
78
for
(
int
i = 1; i < len; i++) {
79
sum += mask[i] * (
imRef
(src, std::max(x - i, 0), y) -
imRef
(src, std::min(x + i, width - 1), y));
80
}
81
imRef
(dst, y, x) = sum;
82
}
83
}
84
}
85
86
}
// namespace lidar
87
}
// namespace perception
88
}
// namespace apollo
apollo::perception::lidar::Image
Definition
image.h:40
apollo::perception::lidar::Image::height
int height() const
Get the height of an image
Definition
image.h:73
apollo::perception::lidar::Image::width
int width() const
Get the width of an image
Definition
image.h:64
image.h
imRef
#define imRef(im, x, y)
Definition
image.h:88
apollo::perception::lidar::convolve_even
void convolve_even(Image< float > *src, Image< float > *dst, const std::vector< float > &mask)
convolve src with mask.
Definition
convolve.h:49
apollo::perception::lidar::convolve_odd
void convolve_odd(Image< float > *src, Image< float > *dst, const std::vector< float > &mask)
convolve src with mask.
Definition
convolve.h:71
apollo
class register implement
Definition
arena_queue.h:37
modules
perception
lidar_segmentation
segmentor
ncut_segmentation
common
graph_felzenszwalb
convolve.h