Blur
Transforms
- class Blur(blur_limit: int | Tuple[int, int] = 7, by_slice: bool = False, mode: str = 'constant', cval: float | int = 0, always_apply: bool = False, p: float = 0.5)[source]
Bases:
ImageOnlyTransformBlur the input image using a random-sized kernel.
- Parameters:
blur_limit (int, (int, int)) – maximum kernel size for blurring the input image. Should be in range [3, inf). Default: (3, 7).
by_slice (bool) – Whether the kernel should be applied by slice or the image as a whole. If true, a 2D kernel is convolved along each slice of the image. Otherwise, a 3D kernel is used. Default: False
mode (str) –
scipy parameter to determine how the input image is extended during convolution to maintain image shape. Must be one of the following:
reflect (d c b a | a b c d | d c b a): The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
constant (k k k k | a b c d | k k k k): The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
nearest (a a a a | a b c d | d d d d): The input is extended by replicating the last pixel.
mirror (d c b | a b c d | c b a): The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
wrap (a b c d | a b c d | a b c d): The input is extended by wrapping around to the opposite edge.
Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.median_filter.html
Default: constant
cval (int,float) – The fill value when mode = constant. Default: 0
always_apply (bool) – whether to always apply the transformation. Default: False
p (float) – probability of applying the transform. Default: 0.5.
- Targets:
image
- Image types:
uint8, uint16, float32
- class GaussianBlur(blur_limit: int | Tuple[int, int] = (3, 7), sigma_limit: float | Tuple[float, float] = 0, by_slice: bool = False, always_apply: bool = False, p: float = 0.5, mode: str = 'constant', cval: float | int = 0)[source]
Bases:
ImageOnlyTransformBlur the input image using a Gaussian filter with a random kernel size.
- Parameters:
blur_limit (int, (int, int)) – maximum Gaussian kernel size for blurring the input image. Must be zero or odd and in range [0, inf). If set to 0 it will be computed from sigma as round(sigma * 4 * 2) + 1. If set single value blur_limit will be in range (0, blur_limit). Default: (3, 7).
sigma_limit (float, (float, float)) – Gaussian kernel standard deviation. Must be in range [0, inf). If set single value sigma_limit will be in range (0, sigma_limit). If set to 0 sigma will be computed as sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8. Default: 0.
by_slice (bool) – Whether the kernel should be applied by slice or the image as a whole. If true, a 2D kernel is convolved along each slice of the image. Otherwise, a 3D kernel is used. Default: False
mode (str) –
scipy parameter to determine how the input image is extended during convolution to maintain image shape. Must be one of the following:
reflect (d c b a | a b c d | d c b a): The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
constant (k k k k | a b c d | k k k k): The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
nearest (a a a a | a b c d | d d d d): The input is extended by replicating the last pixel.
mirror (d c b | a b c d | c b a): The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
wrap (a b c d | a b c d | a b c d): The input is extended by wrapping around to the opposite edge.
Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.median_filter.html
Default: constant
cval (int,float) – The fill value when mode = constant. Default: 0
always_apply (bool) – whether to always apply the transformation. Default: False
p (float) – probability of applying the transform. Default: 0.5.
- Targets:
image
- Image types:
uint8, float32
- class MedianBlur(blur_limit: int | Tuple[int, int] = 7, by_slice: bool = False, mode: str = 'constant', cval: float | int = 0, always_apply: bool = False, p: float = 0.5)[source]
Bases:
BlurBlur the input image using a median filter with a random aperture linear size.
- Parameters:
blur_limit (int) – maximum aperture linear size for blurring the input image. Must be odd and in range [3, inf). Default: (3, 7).
by_slice (bool) – Whether the kernel should be applied by slice or the image as a whole. If true, a 2D kernel is convolved along each slice of the image. Otherwise, a 3D kernel is used. Default: False
mode (str) –
scipy parameter to determine how the input image is extended during convolution to maintain image shape. Must be one of the following:
reflect (d c b a | a b c d | d c b a): The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
constant (k k k k | a b c d | k k k k): The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
nearest (a a a a | a b c d | d d d d): The input is extended by replicating the last pixel.
mirror (d c b | a b c d | c b a): The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
wrap (a b c d | a b c d | a b c d): The input is extended by wrapping around to the opposite edge.
Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.median_filter.html
Default: constant
cval (int,float) – The fill value when mode = constant. Default: 0
always_apply (bool) – whether to always apply the transformation. Default: False
p (float) – probability of applying the transform. Default: 0.5.
- Targets:
image
- Image types:
uint8, uint16, float32
Functional
- blur(img: ndarray, ksize: int, by_slice: bool = False, mode: str = 'constant', cval: float | int = 0) ndarray[source]
Blur the input image using an mean kernel.
- Parameters:
ksize (int) – The kernel size for blurring the input image.
by_slice (bool) – Whether the kernel should be applied by slice or the image as a whole. If true, a 2D kernel is convolved along each slice of the image. Otherwise, a 3D kernel is used. Default: False
mode (str) –
scipy parameter to determine how the input image is extended during convolution to maintain image shape. Must be one of the following:
reflect (d c b a | a b c d | d c b a): The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
constant (k k k k | a b c d | k k k k): The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
nearest (a a a a | a b c d | d d d d): The input is extended by replicating the last pixel.
mirror (d c b | a b c d | c b a): The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
wrap (a b c d | a b c d | a b c d): The input is extended by wrapping around to the opposite edge.
Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.median_filter.html
Default: constant
cval (int,float) – The fill value when mode = constant. Default: 0
- gaussian_blur(img: ndarray, ksize: int, sigma: float = 0, by_slice: bool = False, mode: str = 'constant', cval: float | int = 0) ndarray[source]
Blur the input image using a Gaussian kernel.
- Parameters:
ksize (int) – The kernel size for blurring the input image. If 0, then ksize is estimated as round(sigma * 8) + 1
sigma (float) – Gaussian kernel standard deviation. If 0, then sigma is estimated as 0.3 * ((ksize - 1) * 0.5 - 1) + 0.8
by_slice (bool) – Whether the kernel should be applied by slice or the image as a whole. If true, a 2D kernel is convolved along each slice of the image. Otherwise, a 3D kernel is used. Default: False
mode (str) –
scipy parameter to determine how the input image is extended during convolution to maintain image shape. Must be one of the following:
reflect (d c b a | a b c d | d c b a): The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
constant (k k k k | a b c d | k k k k): The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
nearest (a a a a | a b c d | d d d d): The input is extended by replicating the last pixel.
mirror (d c b | a b c d | c b a): The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
wrap (a b c d | a b c d | a b c d): The input is extended by wrapping around to the opposite edge.
Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.median_filter.html
Default: constant
cval (int,float) – The fill value when mode = constant. Default: 0
- median_blur(img: ndarray, ksize: int, by_slice: bool = False, mode: str = 'constant', cval: float | int = 0) ndarray[source]
Blur the input image using median blue technique.
- Parameters:
ksize (int) – The kernel size for blurring the input image.
by_slice (bool) – Whether the kernel should be applied by slice or the image as a whole. If true, a 2D kernel is convolved along each slice of the image. Otherwise, a 3D kernel is used. Default: False
mode (str) –
scipy parameter to determine how the input image is extended during convolution to maintain image shape. Must be one of the following:
reflect (d c b a | a b c d | d c b a): The input is extended by reflecting about the edge of the last pixel. This mode is also sometimes referred to as half-sample symmetric.
constant (k k k k | a b c d | k k k k): The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
nearest (a a a a | a b c d | d d d d): The input is extended by replicating the last pixel.
mirror (d c b | a b c d | c b a): The input is extended by reflecting about the center of the last pixel. This mode is also sometimes referred to as whole-sample symmetric.
wrap (a b c d | a b c d | a b c d): The input is extended by wrapping around to the opposite edge.
Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.median_filter.html
Default: constant
cval (int,float) – The fill value when mode = constant. Default: 0