Source
1
-
<casaxml xsi:schemaLocation="http://casa.nrao.edu/schema/casa.xsd file:///opt/casa/code/xmlcasa/xml/casa.xsd" xmlns="http://casa.nrao.edu/schema/psetTypes.html" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
-
3
-
<task type="function" name="specsmooth" category="analysis">
4
-
5
-
<shortdescription>Smooth an image region in one dimension</shortdescription>
6
-
7
-
<description>
8
-
</description>
9
-
10
-
<input>
11
-
<param type="path" name="imagename" mustexist="true"><shortdescription>Name of the input image</shortdescription><description>Name of the input image</description>
12
-
13
-
<value/>
14
-
<example>imagename='ngc5921_task.image'</example>
15
-
</param>
16
-
<param type="string" name="outfile"><shortdescription>Output image name.</shortdescription><description>Output image name.</description>
17
-
18
-
<value/>
19
-
<example>outfile='mysmoothed.im'</example>
20
-
</param>
21
-
<param type="string" name="box"><shortdescription>Rectangular region to select in direction plane. Default is to use the entire direction plane.</shortdescription><description>Rectangular region to select in direction plane. Default is to use the entire direction plane.</description>
22
-
23
-
<value/>
24
-
<example>box="4,4,10,10"</example>
25
-
</param>
26
-
<param type="string" name="chans"><shortdescription>Channels to use. Channels must be contiguous. Default is to use all channels.</shortdescription><description>Channels to use. Channels must be contiguous. Default is to use all channels.</description>
27
-
28
-
<value/>
29
-
</param>
30
-
<param type="string" name="stokes"><shortdescription>Stokes planes to use. Planes specified must be contiguous. Default is to use all Stokes planes.</shortdescription><description>Stokes planes to use. Planes specified must be contiguous. Default is to use all Stokes planes.</description>
31
-
32
-
<value/>
33
-
<example>stokes="I"</example>
34
-
</param>
35
-
<param type="any" name="region"><shortdescription>Region selection. Default is to use the full image.</shortdescription><description>Region selection. Default is to use the full image.</description>
36
-
<any type="variant"/>
37
-
38
-
<value type="string"/>
39
-
<example>region="myregion.rgn"</example>
40
-
</param>
41
-
<param type="string" name="mask"><shortdescription>Mask to use. Default is none..</shortdescription><description>Mask to use. Default is none..</description>
42
-
43
-
<value/>
44
-
</param>
45
-
<param type="bool" name="overwrite" subparam="true"><shortdescription>Overwrite the output if it exists?</shortdescription><description>Overwrite the output if it exists?</description>
46
-
47
-
<value>False</value>
48
-
</param>
49
-
<param type="bool" name="stretch" subparam="true"><shortdescription>Stretch the mask if necessary and possible? Default False</shortdescription><description>Stretch the mask if necessary and possible? Default False</description>
50
-
51
-
<value>False</value>
52
-
</param>
53
-
<param type="int" name="axis"><shortdescription>The profile axis. Default: use the spectral axis if one exists, axis 0 otherwise (<0).</shortdescription><description>The profile axis. Default: use the spectral axis if one exists, axis 0 otherwise (<0).</description>
54
-
55
-
<value>-1</value>
56
-
<example>axis=3</example>
57
-
</param>
58
-
<param type="string" name="function"><shortdescription>Convolution function. hanning and boxcar are supported functions. Minimum match is supported.</shortdescription><description>Convolution function. hanning and boxcar are supported functions. Minimum match is supported.</description>
59
-
60
-
<value>hanning</value>
61
-
<example>function="boxcar"</example>
62
-
</param>
63
-
<param type="int" name="width" subparam="True"><shortdescription>Width of boxcar, in pixels.</shortdescription><description>Width of boxcar, in pixels.</description>
64
-
65
-
<value>2</value>
66
-
<example>width=2</example>
67
-
</param>
68
-
<param type="string" name="dmethod"><shortdescription>Decimation method. "" means no decimation, "copy" and "mean" are also supported (minimum match).</shortdescription><description>Decimation method. "" means no decimation, "copy" and "mean" are also supported (minimum match).</description>
69
-
70
-
<value>copy</value>
71
-
<example>dmethod="mean"</example>
72
-
</param>
73
-
<constraints>
74
-
<when param="outfile">
75
-
<notequals type="string" value="">
76
-
<default param="overwrite">
77
-
<value>False</value>
78
-
</default>
79
-
</notequals>
80
-
</when>
81
-
<when param="mask">
82
-
<notequals type="string" value="">
83
-
<default param="stretch">
84
-
<value>False</value>
85
-
</default>
86
-
</notequals>
87
-
</when>
88
-
<when param="function">
89
-
<notequals type="string" value="hanning">
90
-
<default param="width">
91
-
<value>2</value>
92
-
</default>
93
-
</notequals>
94
-
</when>
95
-
</constraints>
96
-
</input>
97
-
98
-
<returns type="record"/>
99
-
100
-
<example>
101
-
102
-
Smooth an image region in one dimension.
103
-
104
-
ARAMETER SUMMARY
105
-
imagename Name of the input (CASA, FITS, MIRIAD) image
106
-
box Rectangular region to select in direction plane.
107
-
Default is to use the entire direction plane. Only a single box may be specified.
108
-
chans Channels to use. Channels must be contiguous.
109
-
Default is to use all channels.
110
-
stokes Stokes planes to use. Planes specified must be
111
-
contiguous. Default is to use all Stokes planes.
112
-
region Region selection. Default is to use the full image.
113
-
mask Mask to use. Default is none.
114
-
overwrite If the specified outfile already exists, overwrite it if True.
115
-
stretch Stretch the input mask if necessary and possible? Only used if a mask is specified.
116
-
117
-
axis Pixel axis along which to do the convolution <0 means use the spectral axis.
118
-
function Convolution function to use. Supported values are "boxcar" and "hanning". Minimum
119
-
match is supported.
120
-
width Width of boxcar in pixels. Used only if function parameter minimally matches "boxcar".
121
-
dmethod Plane decimation method. "" means no decimation should be performed. Other supported
122
-
values are "copy" and "mean". Minimal match is supported. See below for details.
123
-
124
-
This application performs one dimensional convolution along a specified axis of an image
125
-
or selected region of an image. Hanning smoothing and boxcar smoothing are supported.
126
-
Both float valued and complex valued images are supported. Masked pixel values are set to
127
-
zero prior to convolution. All nondefault pixel masks are ignored during
128
-
the calculation. The convolution is done in the image domain (i.e., not
129
-
with an FFT).
130
-
131
-
BOXCAR SMOOTHING
132
-
133
-
One dimensional boxcar convolution is defined by
134
-
135
-
z[i] = (y[i] + y[i+i] + ... + y[i+w])/w
136
-
137
-
where z[i] is the value at pixel i in the box car smoothed image, y[k]
138
-
is the pixel value of the input image at pixel k, and w is a postivie integer
139
-
representing the width of the boxcar in pixels. The length of the axis along which the
140
-
convolution is to occur must be at least w pixels in the selected region,
141
-
unless decimation using the mean function is chosen in which case the axis
142
-
length must be at least 2*w (see below).
143
-
144
-
If dmethod="" (no decimation), the length of the output axis will be equal
145
-
to the length of the input axis - w + 1. The pixel mask, ORed with the OTF mask
146
-
if specified, is copied from the selected region of the input image to the
147
-
output image. Thus for example, if the selected region in the input image has
148
-
six planes along the convolution axis, if the specified boxcar width is 2,
149
-
and if the pixel values, which are all unmasked, on a slice along this axis
150
-
are [1, 2, 5, 10, 17, 26], then the corresponding output slice will be of
151
-
length five pixels and the output pixel values will be [1.5, 3.5, 7.5, 13.5, 21.5].
152
-
153
-
If dmethod="copy", the output image is the image calculated
154
-
if dmethod="", except that only every wth plane is kept. Both the pixel and mask
155
-
values of these planes are copied directly to the output image, without further
156
-
processing. Thus for example, if the selected region in the input image has six
157
-
planes along the convolution axis, the boxcar width is chosen to be 2, and if
158
-
the pixel values, which are all unmasked, on a slice along this axis are [1, 2,
159
-
5, 10, 17, 26], the corresponding output pixel values will be [1.5, 7.5, 21.5].
160
-
161
-
If dmethod="mean", first the image described in the dmethod=""
162
-
case is calculated. Then, the ith plane of the output image is calculated by
163
-
averaging the i*w to the (i+1)*w-1 planes of this intermediate image. Thus, for
164
-
example, if the selected region in the input image has six planes along the
165
-
convolution axis, the boxcar width is chosen to be 2, and if the pixel values,
166
-
which are all unmasked, on a slice along this axis are [1, 2, 5, 10, 17, 26],
167
-
then the corresponding output pixel values will be [2.5, 10.5]. Any pixels at the
168
-
end of the convolution axis of the intermediate image that do not fall into a complete bin of
169
-
width w are ignored. Masked values are taken into consideration when forming this
170
-
average, so if one of the values is masked, it is not used in the average. If at
171
-
least one of the values in the intermediate image bin is not masked, the
172
-
corresponding output pixel will not be masked.
173
-
174
-
HANNING SMOOTHING
175
-
176
-
Hanning convolution of one axis of an image is defined by
177
-
178
-
z[i] = 0.25*y[i-1] + 0.5*y[i] + 0.25*y[i+1] (equation 1)
179
-
180
-
where z[i] is the value at pixel i in the hanning smoothed image, and
181
-
y[i-1], y[i], and y[i+1] are the values of the input image at pixels i-1,
182
-
i, and i+1 respectively. The length of the axis along which the convolution is
183
-
to occur must be at least three pixels in the selected region.
184
-
185
-
If dmethod="" (no decimation of image planes), the length of the output axis will
186
-
be the same as that of the input axis. The output pixel values along the convolution
187
-
axis will be related to those of the input values according to equation 1, except
188
-
the first and last pixels. In that case,
189
-
190
-
z[0] = 0.5*(y[0] + y[1])
191
-
192
-
and,
193
-
194
-
z[N-1] = 0.5*(y[N-2] + y[N-1])
195
-
196
-
where N is the number of pixels along the convolution aixs.
197
-
The pixel mask, ORed with the OTF mask if specified, is copied from the selected
198
-
region of the input image to the output image. Thus for example, if the selected
199
-
region in the input image has six planes along the convolution axis, and if the pixel
200
-
values, which are all unmasked, on a slice along this axis are [1, 2, 5, 10, 17, 26],
201
-
the corresponding output pixel values will be [1.5, 2.5, 5.5, 10.5, 17.5, 21.5].
202
-
203
-
If dmethod="copy", the output image is the image calculated if
204
-
dmethod="", except that only the odd-numbered planes are kept. Furthermore, if the
205
-
number of planes along the convolution axis in the selected region of the input image
206
-
is even, the last odd number plane is also discarded. Thus, if the selected region
207
-
has N pixels along the convolution axis in the input image, along the convolution
208
-
axis the output image will have (N-1)/2 planes if N is odd, or (N-2)/2 planes if N
209
-
is even. The pixel and mask values are copied directly, without further
210
-
processing. Thus for example, if the selected region in the input image has six planes
211
-
along the convolution axis, and if the pixel values, which are all unmasked, on a slice
212
-
along this axis are [1, 2, 5, 10, 17, 26], the corresponding output pixel values will be
213
-
[2.5, 10.5].
214
-
215
-
If dmethod="mean", first the image described in the dmethod="" case
216
-
is calculated. The first plane and last plane(s) of that image are then discarded as
217
-
described in the dmethod="copy" case. Then, the ith plane of the output
218
-
image is calculated by averaging the (2*i)th and (2*i + 1)th planes of the intermediate
219
-
image. Thus for example, if the selected region in the input image has six planes
220
-
along the convolution axis, and if the pixel values, which are all unmasked, on a slice
221
-
along this axis are [1, 2, 5, 10, 17, 26], the corresponding output pixel values will be
222
-
[4.0, 14.0]. Masked values are taken into consideration when forming this average, so if
223
-
one of the values is masked, it is not used in the average. If at least one of the values
224
-
in the input pair is not masked, the corresponding output pixel will not be masked.
225
-
226
-
227
-
EXAMPLES
228
-
229
-
# boxcar smooth the spectral axis by 3 pixels, say it's axis 2 and only
230
-
# write every other pixel
231
-
specsmooth(imagename="mynonsmoothed.im", outfile="myboxcarsmoothed.im",
232
-
axis=2, function="boxcar", dmethod="copy", width=3, overwrite=True)
233
-
234
-
# hanning smooth the spectral axis, say it's axis 2 and do not perform decimation
235
-
# of image planes
236
-
specsmooth(imagename="mynonsmoothed.im", outfile="myhanningsmoothed.im",
237
-
axis=2, dmethod=""," overwrite=True)
238
-
</example>
239
-
240
-
</task>
241
-
242
-
</casaxml>