Threshold
Thresholding is a type of image segmentation. Using it, pixels are supposed to be changed so that the image becomes easier to analyze. In this pipeline, this is done by first converting the image to different colorspaces and then applying a sobel filter to the colorspaces, which leads to an output which easiert to process in the following steps.
apply_blur(img, kernel_size=3)
Applies gaussian and median blur to the image

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img |
cv.Mat
|
The image to apply the blur to |
required |
kernel_size |
int, optional
|
The size of the kernel for the blur filters, by default 3 |
3
|
Returns:
| Type | Description |
|---|---|
cv.Mat
|
The blurred image |
Source code in src/pipeline/threshold.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
get_inner_line(img_rgb, img_hls, img_hsv)
Mask the base image for red, white and yellow lines
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_rgb |
cv.Mat
|
The base image in RGB color space |
required |
img_hls |
cv.Mat
|
The base image in HLS color space |
required |
img_hsv |
cv.Mat
|
The base image in HSV color space |
required |
Returns:
| Type | Description |
|---|---|
cv.Mat
|
The mask for the base image for inner lines |
Source code in src/pipeline/threshold.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
get_sobel(img_rgb, orient='x', sobel_kernel=3, sobel_threshold=(40, 100))
Apply sobel filtering to the image, scale the result and threshold it
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_rgb |
cv.Mat
|
The base image () |
required |
orient |
str, optional
|
Orientation of filter (x or y), by default "x" |
'x'
|
sobel_kernel |
int, optional
|
Kernel size of sobel filter, by default 3 |
3
|
sobel_threshold |
tuple[int, int], optional
|
Threshold for binary image, by default (40, 100) |
(40, 100)
|
Returns:
| Type | Description |
|---|---|
cv.Mat
|
Thresholded sobel filtered image |
Source code in src/pipeline/threshold.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
thresh_img(img_rgb, kitti)
First convert the base image to HLS, HSV and grayscale color space. Then apply sobel filtering to the grayscale image and mask the base image for red, white and yellow lines. Finally combine the two masks and return the result.

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_rgb |
cv.Mat
|
The base image in RGB color space |
required |
kitti |
bool
|
If the base image is from the KITTI dataset |
required |
Returns:
| Type | Description |
|---|---|
cv.Mat
|
The mask for the base image |
Source code in src/pipeline/threshold.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |