PICCANTE  0.4
The hottest HDR imaging library!
region_border.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_ALGORITHMS_REGION_BORDER_HPP
19 #define PIC_ALGORITHMS_REGION_BORDER_HPP
20 
21 #include <set>
22 
23 #include "../base.hpp"
24 #include "../image.hpp"
25 
26 namespace pic {
27 
34 PIC_INLINE std::set<int> *setBorder(Image *img, std::set<int> *coordsBorder)
35 {
36  //second border
37  int ind, c, x, y;
38  std::set<int> *ret = new std::set<int>;
39  std::set<int>::iterator it;
40 
41  for(it = coordsBorder->begin(); it != coordsBorder->end(); it++) {
42  ind = *it;
43  img->reverseAddress(ind, x, y);
44 
45  c = img->getAddress(x + 1, y);
46 
47  if(img->data[c] > 1.0f &&
48  coordsBorder->find(c) == coordsBorder->end()) {
49  ret->insert(c);
50  }
51 
52  c = img->getAddress(x - 1, y);
53 
54  if(img->data[c] > 1.0f &&
55  coordsBorder->find(c) == coordsBorder->end()) {
56  ret->insert(c);
57  }
58 
59  c = img->getAddress(x, y + 1);
60 
61  if(img->data[c] > 1.0f &&
62  coordsBorder->find(c) == coordsBorder->end()) {
63  ret->insert(c);
64  }
65 
66  c = img->getAddress(x, y - 1);
67 
68  if(img->data[c] > 1.0f &&
69  coordsBorder->find(c) == coordsBorder->end()) {
70  ret->insert(c);
71  }
72  }
73 
74  return ret;
75 }
76 
84 PIC_INLINE std::set<int> *setBorderNth(Image *img, std::set<int> *coordsBorder,
85  int widthBorder)
86 {
87  std::set<int> *ret = new std::set<int>;
88 
89  //insert initial border
90  ret->insert(coordsBorder->begin(), coordsBorder->end());
91 
92  for(int i = 0; i < widthBorder; i++) {
93  std::set<int> *tmpBorder = setBorder(img, ret);
94  ret->insert(tmpBorder->begin(), tmpBorder->end());
95  }
96 
97  return ret;
98 }
99 
100 } // end namespace pic
101 
102 #endif /* PIC_ALGORITHMS_REGION_BORDER_HPP */
103 
void reverseAddress(int ind, int &x, int &y)
reverseAddress computes (x, y) given a memory address
Definition: image.hpp:680
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
PIC_INLINE std::set< int > * setBorderNth(Image *img, std::set< int > *coordsBorder, int widthBorder)
setBorderNth
Definition: region_border.hpp:84
PIC_INLINE std::set< int > * setBorder(Image *img, std::set< int > *coordsBorder)
setBorder
Definition: region_border.hpp:34
int getAddress(int x, int y)
getAddress calculates a memory address from (x, y)
Definition: image.hpp:650
#define PIC_INLINE
Definition: base.hpp:33
The Image class stores an image as buffer of float.
Definition: image.hpp:60
Definition: bilateral_separation.hpp:25