2017-05-17 36 views
1

下面是我用它來創建新的形象,畫一個圓上它,並顯示它的代碼:爲什麼在繪製灰度圖像時OpenCV不應用抗鋸齒?

import numpy as np 
import cv2 

# create 50x50 image, filled with white 
img = np.ones((50,50)) 
# draw a circle onto the image 
cv2.circle(img, (25,25), 10, 0, 2, lineType=cv2.LINE_AA) 
# show the image on the screen 
cv2.imshow("i", img) 
cv2.waitKey(0)                                                 
cv2.destroyAllWindows()                                               

但是,沒有抗鋸齒似乎也適用(我放大的圖像X10): enter image description here

我究竟做錯了什麼?

回答

4

如果圖像深度不是CV_8Uline_type自動設置爲8

opencv/modules/imgproc/src/drawing.cpp

if(line_type == CV_AA && img.depth() != CV_8U) 
    line_type = 8; 

由於numpy.ones默認爲numpy.float64類型,你失去了抗鋸齒線。