MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
NoiseParameter.cs
1using System;
2using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8using MyCaffe.basecode;
9
10namespace MyCaffe.param.ssd
11{
19 [Serializable]
20 [TypeConverter(typeof(ExpandableObjectConverter))]
22 {
23 float m_fProb = 0;
24 bool m_bHistEq = false;
25 bool m_bInverse = false;
26 bool m_bDecolorize = false;
27 bool m_bGaussBlur = false;
28 float m_fJpeg = -1;
29 bool m_bPosterize = false;
30 bool m_bErode = false;
31 bool m_bSaltPepper = false;
32 SaltPepperParameter m_saltPepper = new SaltPepperParameter(true);
33 bool m_bClahe = false;
34 bool m_bConvertToHsv = false;
35 bool m_bConvertToLab = false;
36
41 public NoiseParameter(bool bActive) : base(bActive)
42 {
43 }
44
48 [Description("Get/set probability of using this resize policy.")]
49 public float prob
50 {
51 get { return m_fProb; }
52 set { m_fProb = value; }
53 }
54
58 [Description("Get/set histogram equalized.")]
59 public bool hist_eq
60 {
61 get { return m_bHistEq; }
62 set { m_bHistEq = value; }
63 }
64
68 [Description("Get/set color inversion.")]
69 public bool inverse
70 {
71 get { return m_bInverse; }
72 set { m_bInverse = value; }
73 }
74
78 [Description("Get/set grayscale.")]
79 public bool decolorize
80 {
81 get { return m_bDecolorize; }
82 set { m_bDecolorize = value; }
83 }
84
88 [Description("Get/set gaussian blur.")]
89 public bool gauss_blur
90 {
91 get { return m_bGaussBlur; }
92 set { m_bGaussBlur = value; }
93 }
94
98 [Description("Get/set jpeg quality.")]
99 public float jpeg
100 {
101 get { return m_fJpeg; }
102 set { m_fJpeg = value; }
103 }
104
108 [Description("Get/set posterization.")]
109 public bool posterize
110 {
111 get { return m_bPosterize; }
112 set { m_bPosterize = value; }
113 }
114
118 [Description("Get/set erosion.")]
119 public bool erode
120 {
121 get { return m_bErode; }
122 set { m_bErode = value; }
123 }
124
128 [Description("Get/set salt-n-pepper noise.")]
129 public bool saltpepper
130 {
131 get { return m_bSaltPepper; }
132 set { m_bSaltPepper = value; }
133 }
134
138 [Description("Get/set the salt-n-pepper parameter.")]
140 {
141 get { return m_saltPepper; }
142 set { m_saltPepper = value; }
143 }
144
148 [Description("Get/set the local histogram equalization.")]
149 public bool clahe
150 {
151 get { return m_bClahe; }
152 set { m_bClahe = value; }
153 }
154
158 [Description("Get/set color space conversion to hsv.")]
159 public bool convert_to_hsv
160 {
161 get { return m_bConvertToHsv; }
162 set { m_bConvertToHsv = value; }
163 }
164
168 [Description("Get/set color space convertion to lab.")]
169 public bool convert_to_lab
170 {
171 get { return m_bConvertToLab; }
172 set { m_bConvertToLab = value; }
173 }
174
179 public override void Copy(OptionalParameter src)
180 {
181 base.Copy(src);
182
183 if (src is NoiseParameter)
184 {
186 m_fProb = p.prob;
187 }
188 }
189
195 {
196 NoiseParameter p = new param.ssd.NoiseParameter(Active);
197 p.Copy(this);
198 return p;
199 }
200
206 public override RawProto ToProto(string strName)
207 {
208 RawProto rpBase = base.ToProto("option");
209 RawProtoCollection rgChildren = new RawProtoCollection();
210
211 rgChildren.Add(rpBase);
212 rgChildren.Add(new RawProto("prob", prob.ToString()));
213 rgChildren.Add(new RawProto("hist_eq", hist_eq.ToString()));
214 rgChildren.Add(new RawProto("inverse", inverse.ToString()));
215 rgChildren.Add(new RawProto("decolorize", decolorize.ToString()));
216 rgChildren.Add(new RawProto("gauss_blur", gauss_blur.ToString()));
217 rgChildren.Add(new RawProto("jpeg", jpeg.ToString()));
218 rgChildren.Add(new RawProto("posterize", posterize.ToString()));
219 rgChildren.Add(new RawProto("erode", erode.ToString()));
220 rgChildren.Add(new RawProto("saltpepper", saltpepper.ToString()));
221 rgChildren.Add(m_saltPepper.ToProto("saltpepper_param"));
222 rgChildren.Add(new RawProto("clahe", clahe.ToString()));
223 rgChildren.Add(new RawProto("convert_to_hsv", convert_to_hsv.ToString()));
224 rgChildren.Add(new RawProto("convert_to_lab", convert_to_lab.ToString()));
225
226 return new RawProto(strName, "", rgChildren);
227 }
228
234 public static new NoiseParameter FromProto(RawProto rp)
235 {
236 NoiseParameter p = new NoiseParameter(false);
237 string strVal;
238
239 RawProto rpOption = rp.FindChild("option");
240 if (rpOption != null)
241 ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption));
242
243 if ((strVal = rp.FindValue("prob")) != null)
244 p.prob = BaseParameter.ParseFloat(strVal);
245
246 if ((strVal = rp.FindValue("hist_eq")) != null)
247 p.hist_eq = bool.Parse(strVal);
248
249 if ((strVal = rp.FindValue("inverse")) != null)
250 p.inverse = bool.Parse(strVal);
251
252 if ((strVal = rp.FindValue("decolorize")) != null)
253 p.decolorize = bool.Parse(strVal);
254
255 if ((strVal = rp.FindValue("gauss_blur")) != null)
256 p.gauss_blur = bool.Parse(strVal);
257
258 if ((strVal = rp.FindValue("jpeg")) != null)
259 p.jpeg = BaseParameter.ParseFloat(strVal);
260
261 if ((strVal = rp.FindValue("posterize")) != null)
262 p.posterize = bool.Parse(strVal);
263
264 if ((strVal = rp.FindValue("erode")) != null)
265 p.erode = bool.Parse(strVal);
266
267 if ((strVal = rp.FindValue("saltpepper")) != null)
268 p.saltpepper = bool.Parse(strVal);
269
270 RawProto rp1 = rp.FindChild("saltpepper_param");
271 if (rp1 != null)
273
274 if ((strVal = rp.FindValue("clahe")) != null)
275 p.clahe = bool.Parse(strVal);
276
277 if ((strVal = rp.FindValue("convert_to_hsv")) != null)
278 p.convert_to_hsv = bool.Parse(strVal);
279
280 if ((strVal = rp.FindValue("convert_to_lab")) != null)
281 p.convert_to_lab = bool.Parse(strVal);
282
283 return p;
284 }
285 }
286}
The BaseParameter class is the base class for all other parameter classes.
static float ParseFloat(string strVal)
Parse float values using the US culture if the decimal separator = '.', then using the native culture...
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
RawProto FindChild(string strName)
Searches for a given node.
Definition: RawProto.cs:231
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The OptionalParameter is the base class for parameters that are optional such as the MaskParameter,...
static OptionalParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
OptionalParameter(bool bActive=false)
The constructor.
bool Active
When active, the parameter is used, otherwise it is ignored.
Specifies the parameters for the NoiseParameter used with SSD.
bool convert_to_hsv
Get/set color space conversion to hsv.
bool hist_eq
Get/set histogram equalized.
override void Copy(OptionalParameter src)
Copy the object.
bool saltpepper
Get/set salt-n-pepper noise.
bool inverse
Get/set color inversion.
bool gauss_blur
Get/set gaussian blur.
float prob
Get/set probability of using this resize policy.
static new NoiseParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
float jpeg
Get/set jpeg quality.
bool clahe
Get/set the local histogram equalization.
NoiseParameter(bool bActive)
The constructor.
bool posterize
Get/set posterization.
override RawProto ToProto(string strName)
Convert this object to a raw proto.
bool convert_to_lab
Get/set color space convertion to lab.
bool decolorize
Get/set grayscale.
NoiseParameter Clone()
Return a clone of the object.
SaltPepperParameter saltpepper_param
Get/set the salt-n-pepper parameter.
Specifies the parameters for the SaltPepperParameter used with SSD.
override RawProto ToProto(string strName)
Convert this object to a raw proto.
static new SaltPepperParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param.ssd namespace contains all SSD related parameter objects that correspond to the nat...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12