I'm using Python, OpenCV and Numpy to read a black and white image. I then iterate over each pixel using numpy.nditer and either change the pixel to 255 (if it is greater than 128), or change it to 0. Through some testing, I think I have that part right. What I cannot figure out is how to use cv2.imshow to 'show' the altered image. Currently, it only seems to show the original image.
import cv2
import numpy as np
image = cv2.imread('someimage', cv2.IMREAD_GRAYSCALE)
it = np.nditer(image)
for (x) in it:
if x > 128:
x = 255
else:
x = 0
cv2.imshow('image',image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Thank you for any advice.