Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Morphology.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #include "Morphology.hh"
27 
28 #include <Base/Common/BIASpragma.hh>
29 
30 using namespace BIAS;
31 using namespace std;
32 
33 template <class InputStorageType, class OutputStorageType>
36 {
37  kernelSize_=3;
38 }
39 
40 template <class InputStorageType, class OutputStorageType>
43  : kernelSize_(other.kernelSize_)
44 {
45 }
46 
47 template <class InputStorageType, class OutputStorageType>
49 {}
50 
51 template <class InputStorageType, class OutputStorageType>
54  unsigned short int XBorderSize,
55  unsigned short int YBorderSize,
56  OutputStorageType Value) {
57  register OutputStorageType *UpperAddr, *LowerAddr, *last;
58  unsigned int ChannelCount= Image.GetChannelCount();
59 
60  last=
61  &(Image.GetImageData()[(Image.GetPixelCount()-1)*ChannelCount]);
62 
63  // fill upper and lower border
64  if (XBorderSize>0){
65  UpperAddr=Image.GetImageData();
66  LowerAddr=Image.GetImageDataArray()[Image.GetHeight()-1];;
67  while (LowerAddr<=last) {
68  *UpperAddr=Value;
69  *LowerAddr=Value;
70  UpperAddr++; LowerAddr++;
71  }
72  }
73 
74  // fill left and right border
75  if (YBorderSize > 0){
76  register int WidthStep = Image.GetWidth()*ChannelCount;
77  UpperAddr=Image.GetImageData();
78  LowerAddr=UpperAddr+WidthStep-1;
79  while (LowerAddr<=last) {
80  *UpperAddr=Value;
81  *LowerAddr=Value;
82  UpperAddr+=WidthStep; LowerAddr+=WidthStep;
83  }
84  }
85 
86  return 0;
87 }
88 
89 //////////////////////////////////////////////////////////////////////////
90 // instantiation
91 //////////////////////////////////////////////////////////////////////////
92 
93 namespace BIAS{
94 #define FILTER_INSTANTIATION_CLASS Morphology
95 #include "Filterinst.hh"
96 }
virtual ~Morphology()
Definition: Morphology.cpp:48
unsigned int GetWidth() const
Definition: ImageBase.hh:312
int FillBorderConst(Image< OutputStorageType > &Image, unsigned short int XBorderSize, unsigned short int YBorderSize, OutputStorageType Value)
fills the XBorderSize respectivly YBorderSize nearest Pixels to picture border with Value XBorderSize...
Definition: Morphology.cpp:53
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
Definition: ImageBase.hh:382
unsigned int GetHeight() const
Definition: ImageBase.hh:319
base class for Erosion, Dilation, and single Deletion
Definition: Morphology.hh:41
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
Definition: Image.hh:137
unsigned long int GetPixelCount() const
returns number of pixels in image
Definition: ImageBase.hh:422
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase
Definition: Image.hh:153