Evita  0.16
evROI.h
Go to the documentation of this file.
1 /*
2  *
3  * EVITA: Efficient Visualization of Terascale Datasets
4  * Copyright (C) 2000-2016 Team Evita
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
19  * MA 02139, USA.
20  *
21  */
22 
23 
24 #ifndef __evROI_h
25 #define __evROI_h
26 
27 #include "evDataObject.h"
28 #include "evVectorField.h"
29 #include "evSegmentationMap.h"
31 #include "evProgressReporter.h"
32 #include "evVisualizerProp.h"
33 #include "evBoundingBox.h"
34 #include "evAlphaField.h"
35 
36 
37 class evROIList;
38 
39 
40 class evROI : public evDataObject
41 {
42  public:
43  virtual ~evROI(void);
44 
45  virtual const evString GetClassName(void) const
46  {
47  return(evString("evROI"));
48  }
49 
50  void Free(void);
51 
52  void SetNumComponents(const unsigned int num_components);
53  unsigned int GetNumComponents(void) const;
54  void SetOrigin(const evAddress &origin);
55  evAddress GetOrigin(void) const;
56  void SetSize(const evAddress &size);
57  evAddress GetSize(void) const;
58 
59  void SetSize(const unsigned int component,
60  const evAddress &size,
61  const unsigned int vector_dimension);
62  evAddress GetSize(const unsigned int component) const;
63  unsigned int GetVectorDimension(const unsigned int component) const;
64 
65  unsigned int GetTotalSize(unsigned int component) const;
66 
67  int Resize(const unsigned int component,
68  const evAddress &size,
69  const unsigned int vector_dimension,
70  const bool linear = 0);
71 
72  static evROI *Create(const evAddress &size,
73  const evAddress &origin,
74  const int grid_type,
75  const unsigned int num_components);
76  int CreateComponent(const unsigned int component,
77  const evAddress &size,
78  const unsigned int vector_dimension,
79  const int with_alpha_mask);
80  static evROI *Create(const evROI &roi);
81 
82  int Copy(const evROI &roi);
83 
84  void SetROINumber(const int roi_number);
85  unsigned int GetROINumber(void) const;
86  void SetTileNumber(const int tile_number);
87  unsigned int GetTileNumber(void) const;
88 
89  void SetNumScales(const unsigned int component,
90  const unsigned int num_scales);
91  unsigned int GetNumScales(const unsigned int component) const;
92  evAddress GetBasebandSize(const unsigned int component) const;
93  int GetBasebandTotalSize(const unsigned int component) const;
94 
95  void SetCurrentBitplane(unsigned int current_bitplane);
96  unsigned int GetCurrentBitplane(void) const;
97  void IncrementCurrentBitplane(void);
98 
99  void SetCurrentScale(unsigned int current_scale);
100  unsigned int GetCurrentScale(void) const;
101 
102  void CalcMaxNumScales(void);
103  void SetMaxNumScales(unsigned int max_num_scales);
104  unsigned int GetMaxNumScales(void) const;
105 
106  void SetScaleInfo(const unsigned int component,
107  const evFieldScaleInfo &scale_info);
108  evFieldScaleInfo GetScaleInfo(const unsigned int component) const;
109 
110  void CalcCurrentLOD(const double pixel_size);
111  int GetCurrentLOD(void) const;
112  int LODResize(const unsigned int component,
113  const double pixel_size,
114  const bool linear = 0);
115  int LODCreateComponent(const unsigned int component,
116  const double pixel_size,
117  const unsigned int vector_dimension,
118  const int with_alpha_mask);
119 
120  void SetNext(evROI *next);
121  void SetPrevious(evROI *previous);
122  evROI *GetNext(void) const;
123  evROI *GetPrevious(void) const;
124 
125  double GetMax(unsigned int component) const;
126  double GetMin(unsigned int component) const;
127  evVector GetMean(unsigned int component) const;
128  int GetHighestBitplane(unsigned int component) const;
129 
130  evVector SubtractMean(unsigned int component);
131  void AddMean(unsigned int component, const evVector &mean);
132 
133  void SetGridType(const int grid_type);
134  int GetGridType(void) const;
135  // int HasExplicitGrid(void) const;
136 
137  evVectorField *GetComponent(unsigned int component) const;
138  evAlphaField *GetAlphaMask(unsigned int component) const;
139 
140  evVector GetGrid(const evAddress &grid_coordinates) const;
141 
142  void SetVisualizerProp(evVisualizerProp *visualizer_prop);
143  evVisualizerProp *GetVisualizerProp(void) const;
144 
145  void SetBoundingBox(const evBoundingBox &bounding_box);
146  evBoundingBox GetBoundingBox(void) const;
147  int CalcBoundingBox(void);
148  double CalcGridSpacing(void) const;
149 
150  int SubtractUniformGrid(const evBoundingBox &bounding_box);
151  int AddUniformGrid(const evBoundingBox &bounding_box);
152 
153  int Segment(const evSegmentationMap &segmentation_map,
154  evROIList &roi_list,
155  const unsigned int tile_size,
156  evProgressReporter *progress_reporter = NULL) const;
157  int Composite(const unsigned int component, evVectorField &field) const;
158 
159  int MakeOpaque(const unsigned int component);
160  int MakeTransparent(const unsigned int component);
161  int IsTransparent(const unsigned int component, const int index) const;
162  int IsTransparent(const unsigned int component,
163  const evAddress &address) const;
164 
165  int RasterScan(const unsigned int component, evROI &roi) const;
166  int InverseRasterScan(const unsigned int component, evROI &roi) const;
167  int InverseRasterScan(evROI &roi) const;
168  int ForwardTransform(const unsigned int component,
169  const evWaveletTransform &wavelet_transform);
171  &wavelet_transform_collection);
172  int InverseTransform(const unsigned int component,
173  const evWaveletTransform &wavelet_transform);
174 
175  int ExtractSubband(const unsigned int subband, evROI &roi) const;
176  int PreserveBaseband(void);
177 
178  virtual void PrintSelf(const int tabbing) const;
179  static evString GridTypeName(const int grid_type);
180  static int GridTypeName(const evString &grid_type_name);
181  // static int HasExplicitGrid(const int grid_type);
182 
183  protected:
184 
185  private:
186  void Initialize(void);
187  evROI(void);
188 
189  unsigned int ROINumber;
190  unsigned int TileNumber;
191 
192  unsigned int NumDimensions;
196 
197  unsigned int CurrentBitplane;
198  unsigned int CurrentScale;
199 
200  unsigned int MaxNumScales;
202 
203  int GridType;
204 
205  unsigned int NumComponents;
206 
207  std::vector<evVectorField *> Components;
208  std::vector<unsigned int> VectorDimension;
209  std::vector<evFieldScaleInfo> ScaleInfo;
210  std::vector<evAlphaField *> AlphaMask;
211 
214 
216 
220 
221  int SegmentROI(const unsigned int roi_number,
222  const evSegmentationMap &segmentation_map,
223  evROIList &roi_list,
224  const unsigned int tile_size) const;
225  int SegmentTile(const unsigned int roi_number,
226  const unsigned int tile_number,
227  const evAddress &origin,
228  const evAddress &size,
229  const evSegmentationMap &segmentation_map,
230  evROIList &roi_list) const;
231  void SegmentTileCopyInfo(const evROI &roi,
232  const evAddress &address1,
233  const evAddress &address2,
234  const unsigned int previous_inside);
235 };
236 
237 
238 inline void evROI::SetNumComponents(const unsigned int num_components)
239 {
240  this->NumComponents = num_components;
241 
242  if (this->Components.size())
243  {
244  for (unsigned int component = 0; component < this->Components.size();
245  component++)
246  delete this->Components[component];
247  this->Components = std::vector<evVectorField *>();
248  }
249 
250  this->Components.resize(num_components, NULL);
251 
252  if (this->AlphaMask.size())
253  {
254  for (unsigned int component = 0; component < this->AlphaMask.size();
255  component++)
256  delete this->AlphaMask[component];
257  this->AlphaMask = std::vector<evAlphaField *>();
258  }
259 
260  this->AlphaMask.resize(num_components, NULL);
261 
262  if (this->VectorDimension.size())
263  this->VectorDimension = std::vector<unsigned int>();
264 
265  this->VectorDimension.resize(num_components, 0);
266 
267  if (this->ScaleInfo.size())
268  this->ScaleInfo = std::vector<evFieldScaleInfo>();
269 
270  this->ScaleInfo.resize(num_components, evFieldScaleInfo());
271 }
272 
273 
274 inline unsigned int evROI::GetNumComponents(void) const
275 {
276  return(this->NumComponents);
277 }
278 
279 
280 inline void evROI::SetOrigin(const evAddress &origin)
281 {
282  this->Origin = origin;
283 }
284 
285 
286 inline evAddress evROI::GetOrigin(void) const
287 {
288  return(this->Origin);
289 }
290 
291 
292 inline void evROI::SetSize(const evAddress &size)
293 {
294  this->Size = size;
295  this->NumDimensions = size.GetNumDimensions();
296 }
297 
298 
299 inline evAddress evROI::GetSize(void) const
300 {
301  return(this->Size);
302 }
303 
304 
305 inline void evROI::SetSize(const unsigned int component,
306  const evAddress &size,
307  const unsigned int vector_dimension)
308 {
309  if (component >= this->NumComponents)
310  return;
311 
312  if (this->Components[component] == NULL)
313  return;
314 
315  this->Components[component]->SetSize(size, vector_dimension);
316  this->VectorDimension[component] = vector_dimension;
317 
318  if (this->AlphaMask[component] == NULL)
319  return;
320 
321  this->AlphaMask[component]->SetSize(size);
322 }
323 
324 
325 inline evAddress evROI::GetSize(const unsigned int component) const
326 {
327  evAddress size;
328 
329  if (this->Components[component] != NULL)
330  size = this->Components[component]->GetSize();
331 
332  return(size);
333 }
334 
335 
336 inline unsigned int evROI::GetVectorDimension(const unsigned int component)
337  const
338 {
339  unsigned int vector_dimension = 0;
340  if (component < this->NumComponents)
341  vector_dimension = this->VectorDimension[component];
342 
343  return(vector_dimension);
344 }
345 
346 
347 inline unsigned int evROI::GetTotalSize(unsigned int component) const
348 {
349  if (component < this->NumComponents)
350  return(this->Components[component]->GetSize().Product());
351  return(0);
352 }
353 
354 
355 inline evROI *evROI::Create(const evROI &roi)
356 {
357  evROI *new_roi = evROI::Create(roi.Size,
358  roi.Origin,
359  roi.GridType,
360  roi.NumComponents);
361 
362  new_roi->Copy(roi);
363  return(new_roi);
364 }
365 
366 
367 inline void evROI::SetROINumber(const int roi_number)
368 {
369  this->ROINumber = roi_number;
370 }
371 
372 
373 inline unsigned int evROI::GetROINumber(void) const
374 {
375  return(this->ROINumber);
376 }
377 
378 
379 inline void evROI::SetTileNumber(const int tile_number)
380 {
381  this->TileNumber = tile_number;
382 }
383 
384 
385 inline unsigned int evROI::GetTileNumber(void) const
386 {
387  return(this->TileNumber);
388 }
389 
390 
391 inline void evROI::SetNumScales(const unsigned int component,
392  const unsigned int num_scales)
393 {
394  if (this->Components[component] != NULL)
395  this->Components[component]->SetNumScales(num_scales);
396  if (this->AlphaMask[component] != NULL)
397  this->AlphaMask[component]->SetNumScales(num_scales);
398 }
399 
400 
401 inline unsigned int evROI::GetNumScales(const unsigned int component) const
402 {
403  return(this->Components[component]->GetNumScales());
404 }
405 
406 
407 inline int evROI::GetBasebandTotalSize(const unsigned int component) const
408 {
409  return(this->GetBasebandSize(component).Product());
410 }
411 
412 
413 inline void evROI::CalcMaxNumScales(void)
414 {
415  evVector lower_bound = this->BoundingBox.GetLowerBound();
416  evVector upper_bound = this->BoundingBox.GetUpperBound();
417  evVector diff = upper_bound - lower_bound;
418 
419  for (unsigned int i = 0; i < diff.Dimension(); i++)
420  diff[i] =
421  std::max(((int)(std::ceil(std::log(diff[i] + 1) * M_LOG2E) - 1)), 0);
422 
423  this->SetMaxNumScales((unsigned int)diff.Min());
424 }
425 
426 
427 inline void evROI::SetCurrentBitplane(unsigned int current_bitplane)
428 {
429  this->CurrentBitplane = current_bitplane;
430 }
431 
432 
433 inline unsigned int evROI::GetCurrentBitplane(void) const
434 {
435  return(this->CurrentBitplane);
436 }
437 
438 
440 {
441  this->CurrentBitplane++;
442 }
443 
444 
445 inline void evROI::SetCurrentScale(unsigned int current_scale)
446 {
447  this->CurrentScale = current_scale;
448 }
449 
450 
451 inline unsigned int evROI::GetCurrentScale(void) const
452 {
453  return(this->CurrentScale);
454 }
455 
456 
457 inline void evROI::SetMaxNumScales(unsigned int max_num_scales)
458 {
459  this->MaxNumScales = max_num_scales;
460 }
461 
462 
463 inline unsigned int evROI::GetMaxNumScales(void) const
464 {
465  return(this->MaxNumScales);
466 }
467 
468 
469 inline void evROI::SetScaleInfo(const unsigned int component,
470  const evFieldScaleInfo &scale_info)
471 {
472  if (component < this->NumComponents)
473  this->ScaleInfo[component] = scale_info;
474 }
475 
476 
477 inline evFieldScaleInfo evROI::GetScaleInfo(const unsigned int component) const
478 {
479  return(this->ScaleInfo[component]);
480 }
481 
482 
483 inline int evROI::GetCurrentLOD(void) const
484 {
485  return(this->CurrentLOD);
486 }
487 
488 
489 inline void evROI::SetNext(evROI *next)
490 {
491  this->Next = next;
492 }
493 
494 
495 inline void evROI::SetPrevious(evROI *previous)
496 {
497  this->Previous = previous;
498 }
499 
500 
501 inline evROI *evROI::GetNext(void) const
502 {
503  return(this->Next);
504 }
505 
506 
507 inline evROI *evROI::GetPrevious(void) const
508 {
509  return(this->Previous);
510 }
511 
512 
513 inline void evROI::SetGridType(const int grid_type)
514 {
515  this->GridType = grid_type;
516 }
517 
518 
519 inline int evROI::GetGridType(void) const
520 {
521  return(this->GridType);
522 }
523 
524 
525 /*
526 inline int evROI::HasExplicitGrid(void) const
527 {
528  return(this->HasExplicitGrid(this->GridType));
529 }
530 */
531 
532 
533 inline evVectorField *evROI::GetComponent(unsigned int component) const
534 {
535  if (component >= this->NumComponents)
536  return(NULL);
537 
538  return(this->Components[component]);
539 }
540 
541 
542 inline evAlphaField *evROI::GetAlphaMask(unsigned int component) const
543 {
544  return(this->AlphaMask[component]);
545 }
546 
547 
548 inline void evROI::SetVisualizerProp(evVisualizerProp *visualizer_prop)
549 {
550  this->VisualizerProp = visualizer_prop;
551 }
552 
553 
555 {
556  return(this->VisualizerProp);
557 }
558 
559 
560 inline void evROI::SetBoundingBox(const evBoundingBox &bounding_box)
561 {
562  this->BoundingBox = bounding_box;
563 }
564 
565 
567 {
568  return(this->BoundingBox);
569 }
570 
571 
572 #endif
void SetNumScales(const unsigned int component, const unsigned int num_scales)
Definition: evROI.h:391
int MakeOpaque(const unsigned int component)
evAddress Origin
Definition: evROI.h:193
int GetGridType(void) const
Definition: evROI.h:519
evFieldScaleInfo GetScaleInfo(const unsigned int component) const
Definition: evROI.h:477
Definition: evWaveletTransform.h:33
unsigned int GetROINumber(void) const
Definition: evROI.h:373
int SegmentROI(const unsigned int roi_number, const evSegmentationMap &segmentation_map, evROIList &roi_list, const unsigned int tile_size) const
evBoundingBox GetBoundingBox(void) const
Definition: evROI.h:566
int LODCreateComponent(const unsigned int component, const double pixel_size, const unsigned int vector_dimension, const int with_alpha_mask)
unsigned int Dimension(void) const
Definition: evVector.h:149
int CodecHighestBitplane
Definition: evROI.h:218
int RasterScan(const unsigned int component, evROI &roi) const
void SetCurrentScale(unsigned int current_scale)
Definition: evROI.h:445
std::vector< evVectorField * > Components
Definition: evROI.h:207
evVector GetLowerBound(void) const
Definition: evBoundingBox.h:102
evAddress Size
Definition: evROI.h:194
int Copy(const evROI &roi)
std::vector< evAlphaField * > AlphaMask
Definition: evROI.h:210
int InverseTransform(const unsigned int component, const evWaveletTransform &wavelet_transform)
Definition: evProgressReporter.h:32
int GetHighestBitplane(unsigned int component) const
void IncrementCurrentBitplane(void)
Definition: evROI.h:439
int AddUniformGrid(const evBoundingBox &bounding_box)
void SetVisualizerProp(evVisualizerProp *visualizer_prop)
Definition: evROI.h:548
int Segment(const evSegmentationMap &segmentation_map, evROIList &roi_list, const unsigned int tile_size, evProgressReporter *progress_reporter=NULL) const
double GetMax(unsigned int component) const
void Free(void)
unsigned int MaxNumScales
Definition: evROI.h:200
Definition: evAlphaField.h:31
double Min(void) const
Definition: evVector.h:437
void SetNumComponents(const unsigned int num_components)
Definition: evROI.h:238
void SetROINumber(const int roi_number)
Definition: evROI.h:367
void Initialize(void)
unsigned int NumDimensions
Definition: evROI.h:192
int ExtractSubband(const unsigned int subband, evROI &roi) const
int Resize(const unsigned int component, const evAddress &size, const unsigned int vector_dimension, const bool linear=0)
evAlphaField * GetAlphaMask(unsigned int component) const
Definition: evROI.h:542
Definition: evVector.h:36
unsigned int CurrentScale
Definition: evROI.h:198
Definition: evAddress.h:37
void SetTileNumber(const int tile_number)
Definition: evROI.h:379
std::vector< evFieldScaleInfo > ScaleInfo
Definition: evROI.h:209
evROI * Next
Definition: evROI.h:213
int SegmentTile(const unsigned int roi_number, const unsigned int tile_number, const evAddress &origin, const evAddress &size, const evSegmentationMap &segmentation_map, evROIList &roi_list) const
evVector CodecThreshold
Definition: evROI.h:219
Definition: evBoundingBox.h:32
int GetCurrentLOD(void) const
Definition: evROI.h:483
evROI(void)
void CalcMaxNumScales(void)
Definition: evROI.h:413
void SetOrigin(const evAddress &origin)
Definition: evROI.h:280
Definition: evVisualizerProp.h:32
evAddress GetBasebandSize(const unsigned int component) const
Definition: evDataObject.h:31
virtual void PrintSelf(const int tabbing) const
virtual const evString GetClassName(void) const
Definition: evROI.h:45
unsigned int GetVectorDimension(const unsigned int component) const
Definition: evROI.h:336
void SetBoundingBox(const evBoundingBox &bounding_box)
Definition: evROI.h:560
int CreateComponent(const unsigned int component, const evAddress &size, const unsigned int vector_dimension, const int with_alpha_mask)
int Composite(const unsigned int component, evVectorField &field) const
int MakeTransparent(const unsigned int component)
evAddress GetSize(void) const
Definition: evROI.h:299
int InverseRasterScan(const unsigned int component, evROI &roi) const
evVector GetUpperBound(void) const
Definition: evBoundingBox.h:114
void SetCurrentBitplane(unsigned int current_bitplane)
Definition: evROI.h:427
void CalcCurrentLOD(const double pixel_size)
unsigned int TileNumber
Definition: evROI.h:190
evROI * Previous
Definition: evROI.h:212
Definition: evFieldScaleInfo.h:37
unsigned int GetCurrentBitplane(void) const
Definition: evROI.h:433
evBoundingBox BoundingBox
Definition: evROI.h:195
void AddMean(unsigned int component, const evVector &mean)
Definition: evVectorField.h:32
static evString GridTypeName(const int grid_type)
int PreserveBaseband(void)
int CalcBoundingBox(void)
evVector GetMean(unsigned int component) const
static evROI * Create(const evAddress &size, const evAddress &origin, const int grid_type, const unsigned int num_components)
void SetNext(evROI *next)
Definition: evROI.h:489
void SegmentTileCopyInfo(const evROI &roi, const evAddress &address1, const evAddress &address2, const unsigned int previous_inside)
std::vector< unsigned int > VectorDimension
Definition: evROI.h:208
void SetPrevious(evROI *previous)
Definition: evROI.h:495
int GridType
Definition: evROI.h:203
double GetMin(unsigned int component) const
unsigned int GetTotalSize(unsigned int component) const
Definition: evROI.h:347
Definition: evWaveletTransformCollection.h:31
int IsTransparent(const unsigned int component, const int index) const
void SetGridType(const int grid_type)
Definition: evROI.h:513
virtual ~evROI(void)
unsigned int NumComponents
Definition: evROI.h:205
int CurrentLOD
Definition: evROI.h:201
Definition: evSegmentationMap.h:35
evVisualizerProp * GetVisualizerProp(void) const
Definition: evROI.h:554
unsigned int GetNumComponents(void) const
Definition: evROI.h:274
unsigned int GetNumDimensions(void) const
Definition: evAddress.h:148
void SetMaxNumScales(unsigned int max_num_scales)
Definition: evROI.h:457
evVector SubtractMean(unsigned int component)
double CalcGridSpacing(void) const
evAddress GetOrigin(void) const
Definition: evROI.h:286
evROI * GetNext(void) const
Definition: evROI.h:501
void SetSize(const evAddress &size)
Definition: evROI.h:292
int GetBasebandTotalSize(const unsigned int component) const
Definition: evROI.h:407
unsigned int ROINumber
Definition: evROI.h:189
unsigned int GetTileNumber(void) const
Definition: evROI.h:385
evVector GetGrid(const evAddress &grid_coordinates) const
int SubtractUniformGrid(const evBoundingBox &bounding_box)
Definition: evROI.h:40
unsigned int GetCurrentScale(void) const
Definition: evROI.h:451
evROI * GetPrevious(void) const
Definition: evROI.h:507
evVector CodecMean
Definition: evROI.h:217
unsigned int GetNumScales(const unsigned int component) const
Definition: evROI.h:401
Definition: evString.h:30
unsigned int CurrentBitplane
Definition: evROI.h:197
evVisualizerProp * VisualizerProp
Definition: evROI.h:215
void SetScaleInfo(const unsigned int component, const evFieldScaleInfo &scale_info)
Definition: evROI.h:469
Definition: evROIList.h:32
unsigned int GetMaxNumScales(void) const
Definition: evROI.h:463
int ForwardTransform(const unsigned int component, const evWaveletTransform &wavelet_transform)
evVectorField * GetComponent(unsigned int component) const
Definition: evROI.h:533
int LODResize(const unsigned int component, const double pixel_size, const bool linear=0)