Thresholding images

please provide code that can run. that requires proper arguments to imshow and a call to waitKey

the code, with obvious fixes, should exactly result in a binary image being shown

I think you were a little too pseudo with your pseudo code, and you might have mixed up variable names