我使用函数cv2.calcHist
并使用RGB的所有通道:
hist1 = cv2.calcHist([image1], [0, 1, 2], None, [8, 8, 8],[0, 256, 0, 256, 0, 256])
我无法理解此功能的输出......有人可以帮助理解吗?
import PIL
images = [ PIL.Image.open(f) for f in glob('blur_data/*') ]
def img2array(im):
if im.mode != 'RGB':
im = im.convert(mode='RGB')
return np.fromstring(im.tobytes(), dtype='uint8').reshape((im.size[1], im.size[0], 3))
np_images = [ img2array(im) for im in images ]
image1 = np_images[0]
hist1 = cv2.calcHist([image1], [0, 1, 2], None, [8, 8, 8],[0, 256, 0, 256, 0, 256])
print hist1
>>
[[[ 2.30000000e+01 8.90000000e+02 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 3.00000000e+00 1.61600000e+03 3.10000000e+01 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 7.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]]
[[ 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 2.20000000e+01 6.64600000e+03 4.33900000e+03 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 5.53000000e+02 3.34100000e+03 1.94000000e+02
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 1.00000000e+00 2.60000000e+01 8.00000000e+01
2.20000000e+01 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 3.20000000e+02 1.60500000e+03 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 1.01500000e+03 3.08020000e+04 2.69100000e+03
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 8.00000000e+01 1.57660000e+04 6.86400000e+03
1.31000000e+02 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 5.00000000e+00 1.33500000e+03
2.00000000e+02 8.60000000e+01 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 1.27000000e+02 3.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]]
[[ 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 3.40000000e+01 2.14700000e+03 1.00000000e+02
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 1.16000000e+02 6.30100000e+03 2.86500000e+03
1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 1.30000000e+01 3.51800000e+03 1.53400000e+04
3.92900000e+03 3.40000000e+01 1.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 2.70000000e+01 3.01200000e+03
3.16900000e+03 2.79000000e+02 2.40000000e+01 1.50000000e+01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
5.19000000e+02 3.90000000e+02 1.29000000e+02 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 2.99000000e+02 3.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]]
[[ 0.00000000e+00 7.00000000e+00 3.50000000e+01 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 1.40000000e+01 5.44700000e+03 9.24000000e+02
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 1.33400000e+03 1.20150000e+04
8.82000000e+02 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 2.78000000e+02 4.69600000e+03
2.86400000e+03 1.80000000e+01 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 2.35700000e+03
4.05900000e+03 4.09000000e+02 9.00000000e+00 1.50000000e+01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.02000000e+02
1.70200000e+03 2.53000000e+03 4.76000000e+02 1.60000000e+01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
1.31000000e+03 3.34300000e+03 2.82000000e+02 3.52000000e+02]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 3.91000000e+02]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 4.63200000e+03 5.25200000e+03
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 6.50000000e+01 1.45970000e+04
3.94000000e+03 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 6.06000000e+02
3.47800000e+03 5.60000000e+01 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.49000000e+02
2.10100000e+03 5.14000000e+02 1.00000000e+01 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 7.00000000e+00
1.68100000e+03 2.39600000e+03 5.56000000e+02 1.70000000e+01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
5.12000000e+02 5.09300000e+03 8.28000000e+02 3.79000000e+02]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 1.82300000e+03 5.22900000e+03 1.10700000e+03]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 1.99000000e+02 7.71600000e+03
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.43930000e+04
7.64800000e+03 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.69000000e+02
7.85000000e+02 8.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 2.00000000e+01
1.16000000e+02 3.20000000e+01 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
5.35000000e+02 4.31000000e+02 1.39000000e+02 1.30000000e+01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
5.86000000e+02 1.30600000e+03 1.16900000e+03 5.65000000e+02]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 8.64000000e+02 1.17400000e+03 5.90000000e+02]]
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 3.50000000e+03
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 8.66700000e+03
2.32430000e+04 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
3.33800000e+03 2.07000000e+02 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
3.00000000e+01 2.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 3.10000000e+01
5.76000000e+02 4.77000000e+02 1.56000000e+02 1.90000000e+01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
3.70000000e+01 4.92000000e+02 1.82900000e+03 4.15200000e+03]]]