imgcv.filters.linear
Functions
|
Check if the input is a numpy array |
|
Apply convolution operation to the image. |
|
Apply box filter to the image. This is a simple averaging filter. |
|
Apply Laplacian filter to the image. |
|
Apply Robert Cross filter to the image. This uses 2x2 kernels. Extending this to 3x3 kernel will give us Sobel filter. |
|
Apply Sobel filter to the image. This uses 3x3 kernels. This is extension of Robert Cross filter. Center of kerenel is weighted more than the corners. This gives us more accurate edge detection. |
Module Contents
- imgcv.filters.linear.check_image(image)
Check if the input is a numpy array
- Parameters:
image (np.ndarray) – Input image to be transformed
- Raises:
TypeError – If the input is not a numpy array
ValueError – If the input is not a grayscale or color image
- imgcv.filters.linear.apply_convolution(img, kernels, seperate, take_mean=False)
Apply convolution operation to the image.
- Parameters:
img (np.ndarray) – Input Image array
kernels (List[np.ndarray, np.ndarray]) – List of kernels to apply.
seperate (bool) – If True, apply the kernels seperately in x and y direction respectively.
- Raises:
ValueError – If kernels is not a list of length 1 or 2.
ValueError – If seperate is not a boolean value.
ValueError – If both kernels are not of same shape.
- Returns:
Image array after applying convolution.
- Return type:
np.ndarray
- imgcv.filters.linear.box_filter(img, filter_size)
Apply box filter to the image. This is a simple averaging filter.
- Parameters:
img (np.ndarray) – Input Image array
filter_size (Tuple[int, int]) – Size of the filter.
- Raises:
ValueError – If filter_size is not a tuple.
- Returns:
Filtered image array.
- Return type:
np.ndarray
- imgcv.filters.linear.laplacian_filter(img, diagonal=False, return_edges=True)
Apply Laplacian filter to the image.
- Parameters:
img (np.ndarray) – Input Image array
diagonal (bool, optional) – If True, apply diagonal laplacian filter. Defaults to False.
return_edges (bool, optional) – If True, return image with edges detected else return the sharpened image. Defaults to True.
- Raises:
ValueError – If diagonal is not a boolean value.
- Returns:
Image with edges detected
- Return type:
np.ndarray
- imgcv.filters.linear.robert_cross_filter(img)
Apply Robert Cross filter to the image. This uses 2x2 kernels. Extending this to 3x3 kernel will give us Sobel filter.
- Parameters:
img (np.ndarray) – Input Image array
- Returns:
Image with edges detected
- Return type:
np.ndarray
- imgcv.filters.linear.sobel_filter(img)
Apply Sobel filter to the image. This uses 3x3 kernels. This is extension of Robert Cross filter. Center of kerenel is weighted more than the corners. This gives us more accurate edge detection.
- Parameters:
img (np.ndarray) – Input Image array
- Returns:
Image with edges detected
- Return type:
np.ndarray