擅长:python、mysql、java
<p>如果您使用的是python3,那么将所有print语句替换为print()</p>
<pre><code>img_file = 'baboon.png'
img = cv2.imread(img_file,cv2.IMREAD_COLOR)
alpha_img = cv2.imread(img_file,cv2.IMREAD_UNCHANGED) # rgba
gray_img = cv2.imread(img_file, cv2.IMREAD_GRAYSCALE) # grayscale
print(type(img))
print('RGB shape: ', img.shape) # Rows, cols, channels
print('ARGB shape:', alpha_img.shape)
print('Gray shape:', gray_img.shape)
print('img.dtype: ', img.dtype)
print('img.size: ', img.size)
</code></pre>