How to give histogram mask in python
<p>I am new to Python. I found a code to compute histogram of an image online.
I want to compute the histogram of a local area of image and so I tried to use a mask.
Here is my code:</p>

<pre><code> i_rgb1 = cv2.imread(im1)
   img1 = cv2.cvtColor(i_rgb1, cv.CV_BGR2HSV)
   hist2 = np.zeros(img2.shape)

bins = np.arange(256).reshape(256, 1)
color = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]

for labelx in xrange(len(label)):
    temp = labels_map.copy()
    temp[labels_map != label[labelx]] = 0
    temp[labels_map == label[labelx]] = 255
    cv2.imwrite('mask.png', temp)
    for ch, col in enumerate(color):
        hist_item1 = cv2.calcHist([img1], [ch], temp, [256], [0, 255])
</code></pre>

<p>where labels_map is an image matrix consisting a label assignment for each pixel.
But when I run this code, I get an error saying</p>

<pre><code>OpenCV Error: Assertion failed (!mask.data || mask.type() == CV_8UC1) in unknown function
</code></pre>

<p>Please help me fix this error.</p>
