casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageHistograms.h
Go to the documentation of this file.
1 //# ImageHistograms.h: generate histograms from an image
2 //# Copyright (C) 1996,1997,1999,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: ImageHistograms.h 20229 2008-01-29 15:19:06Z gervandiepen $
27 
28 #ifndef IMAGES_IMAGEHISTOGRAMS_H
29 #define IMAGES_IMAGEHISTOGRAMS_H
30 
31 
32 //# Includes
33 #include <casa/aips.h>
35 #include <casa/Logging/LogIO.h>
36 #include <casa/BasicSL/String.h>
37 
38 
39 namespace casacore{
40 
41 template <class T> class ImageInterface;
42 class IPosition;
43 }
44 
45 namespace casa {
46 
47 //# Forward Declarations
48 
49 
50 // <summary>
51 // Displays histograms of regions from an image.
52 // </summary>
53 
54 // <use visibility=export>
55 
56 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
57 // </reviewed>
58 
59 // <prerequisite>
60 // <li> <linkto class=casacore::ImageInterface>ImageInterface</linkto>
61 // <li> <linkto class=casacore::LatticeHistograms>LatticeHistograms</linkto>
62 // </prerequisite>
63 
64 // <etymology>
65 // This is a class designed to display histograms from images
66 // </etymology>
67 
68 // <synopsis>
69 // This class enable you to display and/or retrieve histograms evaluated over
70 // specified regions from an image. The dimension of the region is arbitrary, but
71 // the size of each dimension is always the size of the corresponding image axis.
72 // The histograms are displayed as a function of location of the axes not
73 // used to evaluate the histograms over. The axes which you evaluate the histograms
74 // over are called the cursor axes, the others are called the display axwes.
75 //
76 // For example, consider an image cube (call the axes xyz or [0,1,2]). You could
77 // display histograms from xy planes (cursor axes [0,1]) as a function of z (display
78 // axes [2]). Or you could retrieve histograms from the z axis (cursor axes [2])
79 // for each [x,y] location (display axes [0,1]).
80 //
81 // The hard work is done by casacore::LatticeHistograms which this class (clumsily) inherits.
82 // It generates a "storage lattice" into which it writes the histograms.
83 // It is from this storage image that the plotting and retrieval
84 // arrays are drawn. The storage image is either in core or on disk
85 // depending upon its size (if > 10% of memory given by .aipsrc system.resources.memory
86 // then it goes into a disk-based casacore::PagedArray). If on disk, the
87 // storage image is deleted when the <src>ImageHistograms</src>
88 // object destructs.
89 //
90 // See casacore::LatticeHistograms for most of the useful public interface. ImageHistograms
91 // exists only so that it can write some world coordinate information to the plots
92 // and logger.
93 //
94 // <note role=tip>
95 // Note that for complex images, real and imaginary are treated independently.
96 // They are binned and plotted separately.
97 // </note>
98 //
99 // <note role=tip>
100 // If you ignore return error statuses from the functions that set the
101 // state of the class, the internal status of the class is set to bad.
102 // This means it will just keep on returning error conditions until you
103 // explicitly recover the situation. A message describing the last
104 // error condition can be recovered with function errorMessage.
105 
106 // </note>
107 // </synopsis>
108 
109 // <example>
110 // <srcBlock>
112 //
113 // casacore::PagedImage<casacore::Float> inImage(inName);
114 //
116 //
117 // casacore::LogOrigin or("myClass", "myFunction(...)", WHERE);
118 // casacore::LogIO os(or);
119 // ImageHistograms<casacore::Float> histo(inImage, os);
120 //
122 //
123 // casacore::Vector<casacore::Int> cursorAxes(2)
124 // cursorAxes(0) = 1;
125 // cursorAxes(1) = 2;
126 // if (!histo.setAxes(cursorAxes)) return 1;
127 //
129 //
130 // if (!histo.setList(true)) return 1;
131 // casacore::String device = "/xs";
132 // casacore::Vector<casacore::Int> nxy(2);
133 // nxy(0) = 3;
134 // nxy(1) = 3;
135 // if (!histo.setPlotting(device, nxy)) return 1;
136 //
138 //
139 // if (!histo.display ()) return 1;
140 //
142 //
143 // casacore::Array<casacore::Float> values, counts;
144 // if (!histo.getHistograms(values, counts)) return 1;
145 //
146 // </srcBlock>
147 // In this example, a <src>casacore::PagedImage</src> is constructed. We set the cursor axes
148 // to be the y and z axes so we make a histogram of each yz plane as a function
149 // of x location on the device "/xs" (no longer supported) with 9 subplots per page.
150 // After the plotting we also retrieve the histograms into an array.
151 // </example>
152 
153 // <motivation>
154 // The generation of histograms from an image is a basic and necessary capability.
155 // </motivation>
156 //
157 // <todo asof="2000/04/04">
158 // <li> Make ascii listing of histograms as well as plots if desired
159 // </todo>
160 //
161 
162 
163 template <class T> class ImageHistograms : public casacore::LatticeHistograms<T> {
164 public:
165 
166 // Constructor takes the image and a <src>casacore::LogIO</src> object for logging.
167 // You can also specify whether you want to see progress meters or not.
168 // You can force the storage image to be disk based, otherwise
169 // the decision for core or disk is taken for you.
171  casacore::LogIO& os,
172  casacore::Bool showProgress=true,
173  casacore::Bool forceDisk=false);
174 
175 // Constructor takes the image only. In the absence of a logger you get no messages.
176 // This includes error messages and potential listing of statistics.
177 // You can specify whether you want to see progress meters or not.
178 // You can force the storage image to be disk based, otherwise
179 // the decision for core or disk is taken for you.
181  casacore::Bool showProgress=true,
182  casacore::Bool forceDisk=false);
183 
184 // Copy constructor (copy semantics)
185  ImageHistograms(const ImageHistograms<T> &other);
186 
187 // Destructor
188  virtual ~ImageHistograms ();
189 
190 // Assignment operator (copy semantics)
192 
193 // Set a new image. A return value of <src>false</src> indicates the
194 // image had an invalid type or that the internal status of the class is bad.
196 
197 private:
200 
201  // Make a string with pixel and world coordinates of display axes
202  virtual casacore::String writeCoordinates(const casacore::IPosition& histPos) const;
203 
204  //# Make members of parent class known.
205 protected:
211 };
212 
213 }
214 
215 #ifndef CASACORE_NO_AUTO_TEMPLATES
216 #include <imageanalysis/ImageAnalysis/ImageHistograms.tcc>
217 #endif //# CASACORE_NO_AUTO_TEMPLATES
218 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
ImageHistograms< T > & operator=(const ImageHistograms< T > &other)
Assignment operator (copy semantics)
ostream-like interface to creating log messages.
Definition: LogIO.h:167
virtual casacore::String writeCoordinates(const casacore::IPosition &histPos) const
Make a string with pixel and world coordinates of display axes.
casacore::Bool setNewImage(const casacore::ImageInterface< T > &image)
Set a new image.
A base class for astronomical images.
Displays histograms of regions from an image.
const casacore::ImageInterface< T > * pInImage_p
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
ImageHistograms(const casacore::ImageInterface< T > &image, casacore::LogIO &os, casacore::Bool showProgress=true, casacore::Bool forceDisk=false)
Constructor takes the image and a casacore::LogIO object for logging.
virtual ~ImageHistograms()
Destructor.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::LogIO os_p
Displays histograms of regions from a lattice.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42