Created
September 7, 2013 11:52
-
-
Save ayang/6474956 to your computer and use it in GitHub Desktop.
display opencv image using matplotlib in ipython notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "test" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import cv2\nimport numpy as np\nimport matplotlib.pyplot as plt\n", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "img = cv2.imread('/Users/ayang/Pictures/ForTest/test.jpg')\nimg = cv2.cvtColor(img, cv2.cv.CV_BGR2RGB)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "plt.imshow(img)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 3, | |
"text": "<matplotlib.image.AxesImage at 0x112634150>" | |
} | |
], | |
"prompt_number": 3 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
That's great magic ^ I was confused for a moment
add "plt.show()"
I think cv2.cv.CV_BGR2RGB is replaced with cv2.COLOR_BGR2RGB now. Great gist, really helpful!
image show in jupyter notebook very small. how i can show it bigger?
@Killer1504 use the following
plt.rcParams['figure.figsize'] = [20, 10]
plt.imshow(img)
plt.show()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add this magic command to show matplotlib automatically
%matplotlib inline