美文网首页
Practical Python and OpenCV ii

Practical Python and OpenCV ii

作者: 专注挖坑的汪 | 来源:发表于2020-02-27 11:28 被阅读0次

    Chapter III     Loading,Displaying,and Saving

    用opencv读图片 然后显示出来

    运行这个代码,会出现未响应 不知道是不是jupyter的原因

    强行关了这张图 会导致jupyter notebook的kernel重新运行,image的numpy表示是(# of rows,# of columns,# of channels)

    https://ppao.pyimagesearch.com/lessons/ppao-chapter-3-loading-displaying-and-saving/ 康康扩展包

    用matplotlib来display图像:

    用matplotlib读,用matplotlib展示

    一开始用cv2读图片 用matplotlib来显示,显示的不同于原图像,原因是

    OpenCV represents RGB images as multi-dimensional NumPy arrays…but in reverse order!

    This means that images are actually represented in BGR order rather than RGB!

    通过cvtColor进行处理就好了

    对于no module named PIL 搜了一下 貌似是缺少pillow的数据包,conda install pillow 问题就解决了

    PIL(Python Imaging Library)是python图像处理库,Pillow是一个对PIL友好的分支.

    Chapter IV     Image Basics

    操作像素,用slicing来显示图像的左上角100 * 100的图片,这么小的图片用cv2imshow 还是会崩,还是用matplotlib来plot好

    读出(0,0)位置的像素 修改左上角的像素

    对比两张图 发现,slicing 前面一组是y坐标(也就是上下) 后面一组是x坐标(也就是左右)

    https://ppao.pyimagesearch.com/lessons/ppao-chapter-4-image-basics/  来康康扩展包

    Even though we specify pixels in terms of (x, y)-coordinates, when it comes to writing code, we access the individual pixel values as image[y, x] . Why does the y-coordinate come first? Well, keep in mind that an image is defined as a matrix. We define a matrix in terms of number of rows and number of columns. Therefore, to access an individual pixel located at (x, y), we first supply y, the row number, followed by x, the column number 

    相关文章

      网友评论

          本文标题:Practical Python and OpenCV ii

          本文链接:https://www.haomeiwen.com/subject/saxthhtx.html