www.mooseframework.org
ImageSampler.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef IMAGESAMPLER_H
16 #define IMAGESAMPLER_H
17 
18 // MOOSE includes
19 #include "FileRangeBuilder.h"
20 #include "ConsoleStream.h"
21 
22 #include "libmesh/bounding_box.h"
23 
24 // VTK includes
25 #ifdef LIBMESH_HAVE_VTK
26 
27 // Some VTK header files have extra semi-colons in them, and clang
28 // loves to warn about it...
29 #include "libmesh/ignore_warnings.h"
30 
31 #include "vtkSmartPointer.h"
32 #include "vtkPNGReader.h"
33 #include "vtkTIFFReader.h"
34 #include "vtkImageData.h"
35 #include "vtkStringArray.h"
36 #include "vtkImageThreshold.h"
37 #include "vtkImageNormalize.h"
38 #include "vtkImageCast.h"
39 #include "vtkImageShiftScale.h"
40 #include "vtkImageMagnitude.h"
41 #include "vtkImageFlip.h"
42 
43 #include "libmesh/restore_warnings.h"
44 
45 #endif
46 
47 // Forward declarations
48 class ImageSampler;
49 class MooseMesh;
50 
51 template <>
53 
58 {
59 public:
68  ImageSampler(const InputParameters & parameters);
69 
74  virtual Real sample(const Point & p);
75 
79  virtual void setupImageSampler(MooseMesh & mesh);
80 
81 protected:
85  void vtkShiftAndScale();
86 
90  void vtkThreshold();
91 
97  void vtkMagnitude();
98 
104  void vtkFlip();
105 
106 private:
107 #ifdef LIBMESH_HAVE_VTK
108 
110  vtkSmartPointer<vtkStringArray> _files;
111 
113  vtkImageData * _data;
114 
116  vtkAlgorithmOutput * _algorithm;
117 
119  vtkSmartPointer<vtkImageReader2> _image;
120 
122  vtkSmartPointer<vtkImageThreshold> _image_threshold;
123 
125  vtkSmartPointer<vtkImageShiftScale> _shift_scale_filter;
126 
128  vtkSmartPointer<vtkImageMagnitude> _magnitude_filter;
129 
131  vtkSmartPointer<vtkImageFlip> _flip_filter;
132 #endif
133 
139 #ifdef LIBMESH_HAVE_VTK
140  vtkSmartPointer<vtkImageFlip> imageFlip(const int & axis);
141 #endif
142 
144  Point _origin;
145 
147  std::vector<int> _dims;
148 
151 
153  std::vector<double> _voxel;
154 
156 #ifdef LIBMESH_HAVE_VTK
157  unsigned int _component;
158 #endif
159 
161  BoundingBox _bounding_box;
162 
165 
168 };
169 
170 #endif // IMAGESAMPLER_H
A helper class for re-directing output streams to Console output objects form MooseObjects.
Definition: ConsoleStream.h:34
unsigned int _component
Component to extract.
Definition: ImageSampler.h:157
InputParameters validParams< ImageSampler >()
Definition: ImageSampler.C:24
vtkAlgorithmOutput * _algorithm
VTK-6 seems to work better in terms of "algorithm outputs" rather than vtkImageData pointers...
Definition: ImageSampler.h:116
virtual void setupImageSampler(MooseMesh &mesh)
Perform initialization of image data.
Definition: ImageSampler.C:80
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
vtkSmartPointer< vtkImageReader2 > _image
Complete image data.
Definition: ImageSampler.h:119
ConsoleStream _is_console
Create a console stream object for this helper class.
Definition: ImageSampler.h:167
vtkSmartPointer< vtkImageFlip > _flip_filter
Pointers to image flipping filter. May be used for x, y, or z.
Definition: ImageSampler.h:131
BoundingBox _bounding_box
Bounding box for testing points.
Definition: ImageSampler.h:161
vtkImageData * _data
Complete image data.
Definition: ImageSampler.h:113
std::vector< double > _voxel
Physical pixel size.
Definition: ImageSampler.h:153
vtkSmartPointer< vtkImageMagnitude > _magnitude_filter
Pointer to the magnitude filter.
Definition: ImageSampler.h:128
void vtkShiftAndScale()
Apply image re-scaling using the vtkImageShiftAndRescale object.
Definition: ImageSampler.C:274
Point _origin
Origin of image.
Definition: ImageSampler.h:144
vtkSmartPointer< vtkImageShiftScale > _shift_scale_filter
Pointer to the shift and scaling filter.
Definition: ImageSampler.h:125
const InputParameters & _is_pars
Parameters for interface.
Definition: ImageSampler.h:164
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
ImageSampler(const InputParameters &parameters)
Constructor.
Definition: ImageSampler.C:62
void vtkThreshold()
Perform thresholding.
Definition: ImageSampler.C:301
vtkSmartPointer< vtkStringArray > _files
List of file names to extract data.
Definition: ImageSampler.h:110
A helper class for reading and sampling images using VTK.
Definition: ImageSampler.h:57
Point _physical_dims
Physical dimensions of image.
Definition: ImageSampler.h:150
Augments an InputParameters object with file range information.
std::vector< int > _dims
Pixel dimension of image.
Definition: ImageSampler.h:147
void vtkFlip()
Perform image flipping.
Definition: ImageSampler.C:337
void vtkMagnitude()
Convert the image to greyscale.
Definition: ImageSampler.C:255
vtkSmartPointer< vtkImageThreshold > _image_threshold
Pointer to thresholding filter.
Definition: ImageSampler.h:122
virtual Real sample(const Point &p)
Return the pixel value for the given point.
Definition: ImageSampler.C:219
vtkSmartPointer< vtkImageFlip > imageFlip(const int &axis)
Helper method for flipping image.
Definition: ImageSampler.C:360