reconstrue / brightfield

Reconstruction of biocytin-stained neurons detected in brightfield microscopy image stacks
http://reconstrue.com
Apache License 2.0
2 stars 1 forks source link

cv.imshow() has been disabled by colab, defensively #206

Closed JohnTigue closed 4 years ago

JohnTigue commented 4 years ago

https://colab.research.google.com/drive/1i2wiH26PtOhGPC3Sm10AJwYUB_koABBK#scrollTo=MRy0BZGNMko8

# convert the image to grayscale and create a histogram
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow("gray", gray)
hist = cv2.calcHist([gray], [0], None, [256], [0, 256])
plt.figure()
plt.title("Grayscale Histogram")
plt.xlabel("Bins")
plt.ylabel("# of Pixels")
plt.plot(hist)
plt.xlim([0, 256])
DisabledFunctionError: cv2.imshow() is disabled in Colab, because it causes Jupyter sessions
to crash; see https://github.com/jupyter/notebook/issues/3935.
As a substitution, consider using
  from google.colab.patches import cv2_imshow
JohnTigue commented 4 years ago

This is the temp fix that worked:

# TODO: temp patched on 2020-04-24
# See  https://github.com/reconstrue/brightfield/issues/206]
# original that Colab disabled: cv2.imshow("gray", gray)
# They suggested:
from google.colab.patches import cv2_imshow
cv2_imshow(gray)
JohnTigue commented 4 years ago

See https://github.com/JohnTigue/whiteboarder/commit/6eb0cb23376e261c599346e53cfebeb63d897de3