I try again to do better my question (http://stackoverflow.com/questions/14349550/convert-image-in-a-binary-image-with-cv2-module-in-python)
In this code (it's a little bit changed from the first ) I can easily work with my converted binary image , extracting contours, calculating areas.. but it's not again possible to execute this code line: cv2.imshow('gray_image',imgray).
it show me a total grey window and that's all. I have to quit python because goes in loop.
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print('oggetti trovati')
print(len(contours))
cnt = contours[0]
print(len(cnt))
cv2.imshow('gray_image',imgray)
What can I do?