cv2.LINE_AA 反走样线可以有效消除锯齿现象
import cv2
import matplotlib.pyplot as plt
import numpy as np
from queue import PriorityQueue
def main():
img = np.zeros((400, 400), np.uint8)
img2 = np.zeros((400, 400), np.uint8)
img3 = np.zeros((400, 400), np.uint8)
cv2.circle(img, (150, 150), 100, 255, -1)
cv2.circle(img2, (150, 150), 50, 255, 100)
cv2.circle(img3, (150, 150), 50, 255, 100, cv2.LINE_AA)
cv2.imshow("circle", img)
cv2.imshow("circle2", img2)
cv2.imshow("circle3", img3)
cv2.waitKey(0)
if __name__ == "__main__":
main()
函数解释:
C++ :
void cv::circle ( InputOutputArray img,
Point center,
int radius,
const Scalar & color,
int thickness = 1,
int lineType = LINE_8,
int shift = 0
)
Python:
img = cv.circle( img, center, radius, color[, thickness[, lineType[, shift]]] )
Draws a circle.
The function cv::circle draws a simple or filled circle with a given center and radius.
Parameters
img | Image where the circle is drawn. |
center | Center of the circle. |
radius | Radius of the circle. |
color | Circle color. |
thickness | Thickness of the circle outline, if positive. Negative values, like FILLED, mean that a filled circle is to be drawn. |
lineType | Type of the circle boundary. See LineTypes |
shift | Number of fractional bits in the coordinates of the center and in the radius value. |
效果图: