improc.dsp package¶
Submodules¶
improc.dsp.filters module¶
-
improc.dsp.filters.
filtering2d
(A, K)[source]¶ filter data
filter A with kernel K
Parameters: - A ({ndarray}) – data to be filtered
- K ({2d-array}) – kernel for filtering
Returns: filtered data
Return type: ndarray
-
improc.dsp.filters.
sobelfilter
(A, gmod='absadd', full=False)[source]¶ sobel filtering
filter A with sobel operator
\[G_v=\left[\begin{array}{ccc}{-1} & {-2} & {-1} \\ {0} & {0} & {0} \\ {+1} & {+2} & {+1}\end{array}\right] * A \]\[G_h=\left[\begin{array}{ccc}{-1} & {0} & {+1} \\ {-2} & {0} & {+2} \\ {-1} & {0} & {+1}\end{array}\right] * A \]\[G=\sqrt{G_h^2 + G_v^2} \]Parameters: - A ({2d or 3d array}) – image to be filtered \(H×W×C\).
- gmod ({str}) –
- ‘add’ –> \(G=G_h+G_v\),
- ’absadd’ –> \(G=|G_h|+|G_v|\),
- ’squaddsqrt’ –> \(G=\sqrt{G_h^2 + G_v^2}\),
- hvfilt –> apply sobel filter on hrizontal and vertical
- vhfilt –> apply sobel filter on vertical and hrizontal
- default absadd
- full ({bool}) – If True, then return Gh+Gv, Gh, Gv else return Gh+Gv
Returns: - G ({2d or 3d array}) – 2d-gradient
- Gh ({2d or 3d array}) – gradient in hrizontal
- Gv ({2d or 3d array}) – gradient in vertical
improc.dsp.kernels module¶
-
improc.dsp.kernels.
convolve
(image, kernel)[source]¶ Performs the convolution using provided kernel.
Parameters: - image ({2d or 3d array}) – image to be convolved \(H\times W \times C\). In case when image has multiple channels, the kernel is going to be used for each image channel.
- kernel ({2d array}) – kernel used for convolution
Returns: Convolved image (probably of different dtype)
Return type: ndarray
Raises: - Kernel Bigger Than Image Error - Kernel Shape Not Odd Error - Kernel Not2 DArray
improc.dsp.noise module¶
-
improc.dsp.noise.
awgn
(sig, SNR=30, PEAK=1, pMode='db', measMode='measured', verbose=False)[source]¶ AWGN Add white Gaussian noise to a signal.
Y = AWGN(X,SNR) adds white Gaussian noise to X. The SNR is in dB. The power of X is assumed to be 0 dBW. If X is complex, then AWGN adds complex noise.
Parameters: - sig ({numpy array}) – Signal that will be noised.
- SNR ({float number}, optional) – Signal Noise Ratio (the default is 30)
- PEAK ({float number}, optional) – Peak value (the default is 1)
- pMode ({string}, optional) – [description] (the default is ‘db’)
- measMode ({string}, optional) – [description] (the default is ‘measured’, which [default_description])
- verbose ({bool}) – If True, show log information
Returns: noised data
Return type: {numpy array}
Raises:
-
improc.dsp.noise.
imnoise
(img, noise='wgn', PEAK=None, SNR=30, verbose=False)[source]¶ Add noise to image
Add noise to image
Parameters: - img ({numpy ndarray}) – image aray
- noise ({string}, optional) – noise type (the default is ‘wgn’, which [default_description])
- PEAK ({float number}, optional) – Peak value (the default is None –> auto detection)
- SNR ({float number}, optional) – Signal-to-noise ratio (the default is 30, which [default_description])
- verbose ({bool}) – If True, show log information
Returns: Images with added noise.
Return type: {numpy array}
-
improc.dsp.noise.
matnoise
(mat, noise='wgn', PEAK=None, SNR=30, verbose=False)[source]¶ add noise to an matrix
Add noise to an matrix (real or complex)
Parameters: mat ({numpy array}) – can be real or complex valued
Keyword Arguments: - noise ({string}) – type of noise (default: {‘wgn’})
- PEAK ({float number}, optional) – Peak value (the default is None–> max)
- SNR ({float number}) – Signal-to-noise ratio (default: {30})
- verbose ({bool}) – If True, show log information
Returns: ndarray with added noise.
Return type: {numpy array}
-
improc.dsp.noise.
wgn
(shape, p, PEAK=1, pMode='dbw', dtype='real', seed=None, verbose=False)[source]¶ WGN Generate white Gaussian noise.
Y = WGN((M,N),P) generates an M-by-N matrix of white Gaussian noise. P specifies the power of the output noise in dBW. The unit of measure for the output of the wgn function is Volts. For power calculations, it is assumed that there is a load of 1 Ohm.
Parameters: - shape ({tulpe}) – Shape of noising matrix
- p ({float number}) – P specifies the power of the output noise in dBW.
- PEAK ({float number}, optional) – Peak value (the default is 1)
- pMode ({string}, optional) – Power mode of the output noise (the default is ‘dbw’)
- dtype ({string}, optional) – data type, real or complex (the default is ‘real’, which means real-valued)
- seed ({integer}, optional) – Seed for random number generator. (the default is None, which means different each time)
- verbose ({bool}) – If True, show log information
Returns: Matrix of white Gaussian noise (real or complex).
Return type: numpy array