This following doesn't work as there is no x-window in Jupyter or Google Colab.
import cv2cv2.imshow("result", image)
Option 1: Google Colab
If you are using Google Colab
from google.colab.patches import cv2_imshowcv2_imshow(image)
NOTE: source code fro cv2_imshow
Option 2: IPython.display and PIL
from PIL import Imagefrom IPython.display import display, clear_output# convert color from CV2 BGR back to RGBimage = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)display(Image.fromarray(image))
Option 3: matplotlib.pyplot
import matplotlib.pyplot as plt# set sizeplt.figure(figsize=(10,10))plt.axis("off")# convert color from CV2 BGR back to RGBimage = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)plt.imshow(image)plt.show()