Repository: opencv
Issue: improc drawing: undocumented behavior, unpredictable line thickness, etc...
Labels: category: imgproc,priority: low,RFC

I see issues with cv::line and possibly other drawing primitives, which may be related.

firstly, the expected output (thickness, lineType) isn't documented all that precisely. it may be implementation-defined (depends on operating system or 3rd party graphics library?), but then that should be stated in the docs.

secondly, what it currently does (v4.1.1 on Win10, also 3.4.4 on a raspbian) is unexpected and follows no discernible pattern. Progressions of line thickness cause monotonously widening lines (at least!), but in uneven steps, and don't interpret thickness as either radius or diameter.

Following are a few reproducible examples with halfway visible pixels you can look at.

Questions:
* how much of a concern is this?
* what *should* be the intended behavior?

*(Note: I previously used LINE_4 connectivity here, which was rightfully criticized. The section is fixed now.)*

Here's a link to a notebook with better visualization. For posterity, equivalent code below.
```py
# LINE_8, thickness 3
# thickness=3 actually means radius=3? or what does it mean?
img = np.zeros((16,16), np.uint8)
img = cv.line(img, (4,8), (12,8), color=255, thickness=3, lineType=cv.LINE_8)
```
![image](https://github.com/opencv/opencv/assets/7065108/8efcf3e5-041e-435a-84da-168074d716a9)
```py
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255,   0,   0,   0],
       [  0,   0,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   0,   0],
       [  0,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   0],
       [  0,   0,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   0,   0],
       [  0,   0,   0,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)
```

```py
# straight line, thickness=1 with LINE_AA
# doesn't even produce a line of thickness 1, and the ridge isn't getting full intensity values either
img = np.zeros((16,16), np.uint8)
img = cv.line(img, (4,8), (12,8), color=255, thickness=1, lineType=cv.LINE_AA)
```
![image](https://github.com/opencv/opencv/assets/7065108/e4d5b36b-121d-4af7-9e34-949db67c5943)

```py
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,  25,  51,  53,  53,  53,  53,  53,  53,  27,   0,   0,   0],
       [  0,   0,   0,   0, 143, 230, 232, 232, 232, 232, 232, 232, 151,   2,   0,   0],
       [  0,   0,   0,   0,  29,  58,  58,  58,  58,  58,  58,  58,  31,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)
```

```py
# LINE_AA with thickness=3
# makes it even worse
img = np.zeros((16,16), np.uint8)
img = cv.line(img, (4,8), (12,8), color=255, thickness=3, lineType=cv.LINE_AA)
```
![image](https://github.com/opencv/opencv/assets/7065108/18127bca-23cb-46bd-9a9f-ef084aefca58)

```py
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,  25,  51,  53,  53,  53,  53,  53,  53,  27,   0,   0,   0],
       [  0,   0,   0,  87, 255, 255, 255, 255, 255, 255, 255, 255, 255,  91,   0,   0],
       [  0,   0,   0, 194, 255, 255, 255, 255, 255, 255, 255, 255, 255, 196,   0,   0],
       [  0,   0, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 198,   4],
       [  0,   2,   8, 204, 255, 255, 255, 255, 255, 255, 255, 255, 255, 206,  10,   2],
       [  0,   0,   0,  97, 255, 255, 255, 255, 255, 255, 255, 255, 255, 100,   0,   0],
       [  0,   0,   0,   0,  31,  58,  58,  58,  58,  58,  58,  58,  33,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)
```