# histogram opencv c++ vs python

I'm converting histogram function which is written in c++ into python.

```
Mat Detection:: histogram(Mat img,bool vis)
{
int bins = 59; // number of bins 256 -1 to ignore the last patterns (background pattern)
Mat hist; // histogram arrays
// Initalize histogram array
hist = Mat::zeros(bins, 1, CV_32FC1);
for (int i = 0; i < img.rows; i++)
{
for (int j = 0; j < img.cols; j++)
{
uchar val =img.at<uchar>(i,j);
hist.at<float>(lookup[val]) += 1; #on this line I'm facing the problem(is it talking about the lookup table? )
}
}
return hist;
}
```

# python conversion

```
def historgram(image):
#cv2.historgram()
bins = 59
row,col,channels = image.shape
hist = np.zeros((bins, 1), dtype = 'float32')
i = 0
j =0
while i < row:
while j < col:
val = image[i,j]
""
""
j = j+1
i = 1+i
return hist
```

**How should I do the conversion in python of this part [hist.at<float>(lookup[val]) += 1]?**

Thankyou

how would we know, without any context ?

I just updated the code Kindly look into it