cv2.imshow 64f?

asked 2017-07-27 14:48:23 -0600

updated 2017-07-27 19:07:23 -0600

berak gravatar image

So I'm just playing around right now with opencv3 and I'm wondering why cv2.imshow renders differently than matplotlib.imshow

The code is stupid basic:

import cv2
from matplotlib import pyplot as plt

img = cv2.imread('test1.jpg',cv2.IMREAD_GRAYSCALE)

cv2.imshow('original',img)
sobely = cv2.Sobel(img,cv2.CV_64F,0,1,ksize=17)


cv2.imshow('sobely',sobely)

plt.imshow(sobely, cmap = 'gray', interpolation = 'bicubic')
plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
plt.show()

cv2.waitKey(0)
cv2.destroyAllWindows()

But the result is this: http://i.imgur.com/o9JpY6u.png

Where the sobel "image" is significantly different.

I'm guessing its because its a float64 data type that results for the sobel array but how come imshow isn't able to render it properly then?

edit retag flag offensive close merge delete