The thresholds are arbitrary values used by the Canny algorithm to decide on each of the pixels at the final stage of their work. There are only two thresholds: upper and lower.
If the magnitude of the gradient of each individual pixel is greater than the upper threshold, then this pixel is considered the border. If the value of the magnitude of the gradient is less than the lower threshold, then that pixel is discarded (no longer taken into account).
If the magnitude of the pixel gradient is between the thresholds, then in this situation, in different implementations of the algorithm, either a separate check is carried out, focusing on the values and directions of the gradient of adjacent pixels, or, as is the case in OpenCV, mark it as a border provided that the pixel in question is adjacent to a pixel with a gradient magnitude value greater than the upper threshold.
The kernel size ( kernel size or aperture size ) is the size of the square convolution matrixes ( convolution ), which are used to calculate the gradient in the vertical and horizontal directions. In the case of OpenCV, only "3", "5" or "7" can be valid kernel size values. This function is performed by the Sobel operator, which is transparently called in the Canny() function.
Convolution with respect to images is essentially the operation of calculating a new value for each pixel based on the values of other pixels that are its neighbors. In addition to the image itself, a separate matrix, often called a window or filter, is involved in the convolution. Usually use a square, with an equal, but an odd number of rows and columns. Oddness is needed in order to generally get the central element of the matrix or, otherwise, the so-called anchor:
( )( )( ) ( )(x)( ) ( )( )( )
In the process of convolving, an anchor is superimposed on each pixel of the original image, thereby covering all the pixels adjacent to the current one with a filter. Then the sum of the products of the pixel values by the values of the corresponding filter elements is calculated, which will be the new pixel value.