djs_median¶
- pydl.pydlutils.math.djs_median(array, dimension=None, width=None, boundary='none')[source]¶
Compute the median of an array.
Use a filtering box or collapse the image along one dimension.
- Parameters:
- array
numpy.ndarray
input array
- dimension
int
, optional Compute the median over this dimension. It is an error to specify both
dimension
andwidth
.- width
int
, optional Width of the median window. In general, this should be an odd integer. It is an error to specify both
dimension
andwidth
.- boundary{ ‘none’, ‘reflect’, ‘nearest’, ‘wrap’ }, optional
Boundary condition to impose. ‘none’ means no filtering is done within
width
/2 of the boundary. ‘reflect’ means reflect pixel values around the boundary. ‘nearest’ means use the values of the nearest boundary pixel. ‘wrap’ means wrap pixel values around the boundary. ‘nearest’ and ‘wrap’ are not implemented. Ifarray
is one-dimensional, andboundary
is not ‘none’, then it is forced to be ‘reflect’.
- array
- Returns:
numpy.ndarray
The output. If neither
dimension
norwidth
are set, this is a scalar value, just the output ofnumpy.median()
. Ifdimension
is set, then the result simplynumpy.median(array,dimension)
. Ifwidth
is set, the result has the same shape as the input array.